From 3f3c4000d44a8b4175e1669a4324e2308b0fd77d Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 11 May 2015 12:51:57 +0200 Subject: loplugin:cstylecast: nop between pointer types of exactly same spelling Change-Id: I16fdb3a6e92c854f4143b5afd19d33818735222b --- compilerplugins/clang/cstylecast.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'compilerplugins/clang') diff --git a/compilerplugins/clang/cstylecast.cxx b/compilerplugins/clang/cstylecast.cxx index d34e7299eded..afbcacd9f15c 100644 --- a/compilerplugins/clang/cstylecast.cxx +++ b/compilerplugins/clang/cstylecast.cxx @@ -53,7 +53,6 @@ private: static const char * recommendedFix(clang::CastKind ck) { switch(ck) { - case CK_NoOp: return "const_cast"; case CK_IntegralToPointer: return "reinterpret_cast"; case CK_PointerToIntegral: return "reinterpret_cast"; case CK_BaseToDerived: return "static_cast"; @@ -101,9 +100,11 @@ bool CStyleCast::VisitCStyleCastExpr(const CStyleCastExpr * expr) { } else { return true; } - if (!t1.isMoreQualifiedThan(t2) - || (t1.getUnqualifiedType().getCanonicalType().getTypePtr() - != t2.getUnqualifiedType().getCanonicalType().getTypePtr())) + if (expr->getSubExprAsWritten()->getType() != expr->getType() + && (!t1.isMoreQualifiedThan(t2) + || (t1.getUnqualifiedType().getCanonicalType().getTypePtr() + != (t2.getUnqualifiedType().getCanonicalType() + .getTypePtr())))) { return true; } -- cgit v1.2.3