loplugin:redundantcast: const_cast to same type
Change-Id: I1abdc2ab0b145e12f7fb00db529f52c11e4d7cfd
This commit is contained in:
@@ -52,6 +52,8 @@ public:
|
||||
|
||||
bool VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr const * expr);
|
||||
|
||||
bool VisitCXXConstCastExpr(CXXConstCastExpr const * expr);
|
||||
|
||||
bool VisitCallExpr(CallExpr const * expr);
|
||||
|
||||
bool VisitCXXDeleteExpr(CXXDeleteExpr const * expr);
|
||||
@@ -263,6 +265,23 @@ bool RedundantCast::VisitCXXReinterpretCastExpr(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RedundantCast::VisitCXXConstCastExpr(CXXConstCastExpr const * expr) {
|
||||
if (ignoreLocation(expr)) {
|
||||
return true;
|
||||
}
|
||||
if (expr->getTypeAsWritten().getCanonicalType().getTypePtr()
|
||||
== (expr->getSubExprAsWritten()->getType().getCanonicalType()
|
||||
.getTypePtr()))
|
||||
{
|
||||
report(
|
||||
DiagnosticsEngine::Warning, "redundant const_cast from %0 to %1",
|
||||
expr->getExprLoc())
|
||||
<< expr->getSubExprAsWritten()->getType()
|
||||
<< expr->getTypeAsWritten() << expr->getSourceRange();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RedundantCast::VisitCallExpr(CallExpr const * expr) {
|
||||
if (ignoreLocation(expr)) {
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user