summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-05-11 12:51:57 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-05-11 12:51:57 +0200
commit3f3c4000d44a8b4175e1669a4324e2308b0fd77d (patch)
treed7081bdab3e41ba1b6e1038be79b1aec786033bd
parent7011bf7817e1ed40c3c5a8020698996bf634045f (diff)
loplugin:cstylecast: nop between pointer types of exactly same spelling
Change-Id: I16fdb3a6e92c854f4143b5afd19d33818735222b
-rw-r--r--compilerplugins/clang/cstylecast.cxx9
1 files changed, 5 insertions, 4 deletions
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;
}