Extract loplugin:redundantcast from loplugin:cstylecast
Change-Id: I08f17dd9cc092206083ff41bbbc178e0322e86d0
This commit is contained in:
@@ -47,8 +47,6 @@ public:
|
||||
|
||||
bool VisitCStyleCastExpr(const CStyleCastExpr * expr);
|
||||
|
||||
bool VisitImplicitCastExpr(ImplicitCastExpr const * expr);
|
||||
|
||||
private:
|
||||
bool externCFunction;
|
||||
};
|
||||
@@ -135,32 +133,6 @@ bool CStyleCast::VisitCStyleCastExpr(const CStyleCastExpr * expr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStyleCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) {
|
||||
if (ignoreLocation(expr) || expr->getCastKind() != CK_BitCast) {
|
||||
return true;
|
||||
}
|
||||
QualType t = expr->getType();
|
||||
if (!(t->isPointerType()
|
||||
&& t->getAs<PointerType>()->getPointeeType()->isVoidType()
|
||||
&& expr->getSubExpr()->getType()->isPointerType()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Expr const * e = expr->getSubExpr()->IgnoreParenImpCasts();
|
||||
while (isa<CXXConstCastExpr>(e)) {
|
||||
e = dyn_cast<CXXConstCastExpr>(e)->getSubExpr()->IgnoreParenImpCasts();
|
||||
}
|
||||
if (isa<CXXReinterpretCastExpr>(e)) {
|
||||
report(
|
||||
DiagnosticsEngine::Warning,
|
||||
("redundant reinterpret_cast, result is implicitly cast to void"
|
||||
" pointer"),
|
||||
e->getExprLoc())
|
||||
<< e->getSourceRange();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
loplugin::Plugin::Registration< CStyleCast > X("cstylecast");
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user