diff options
Diffstat (limited to 'compilerplugins/clang/redundantcast.cxx')
-rw-r--r-- | compilerplugins/clang/redundantcast.cxx | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index 862410c6484d..bdac3f3bcc56 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -127,28 +127,21 @@ public: bool VisitCStyleCastExpr(CStyleCastExpr const * expr); - bool VisitBinSub(BinaryOperator const * expr) - { return visitBinOp(expr); } - - bool VisitBinLT(BinaryOperator const * expr) - { return visitBinOp(expr); } - - bool VisitBinGT(BinaryOperator const * expr) - { return visitBinOp(expr); } - - bool VisitBinLE(BinaryOperator const * expr) - { return visitBinOp(expr); } - - bool VisitBinGE(BinaryOperator const * expr) - { return visitBinOp(expr); } - - bool VisitBinEQ(BinaryOperator const * expr) - { return visitBinOp(expr); } - - bool VisitBinNE(BinaryOperator const * expr) - { return visitBinOp(expr); } + bool VisitBinaryOperator(BinaryOperator const * expr) { + auto const op = expr->getOpcode(); + if (op == BO_Sub || expr->isRelationalOp() || expr->isEqualityOp()) { + return visitBinOp(expr); + } + if (op == BO_Assign) { + if (ignoreLocation(expr)) { + return true; + } + visitAssign(expr->getLHS()->getType(), expr->getRHS()); + return true; + } + return true; + } - bool VisitBinAssign(BinaryOperator const * binaryOperator); bool VisitVarDecl(VarDecl const * varDecl); private: @@ -356,14 +349,6 @@ bool RedundantCast::VisitCStyleCastExpr(CStyleCastExpr const * expr) { return true; } -bool RedundantCast::VisitBinAssign(BinaryOperator const * binaryOperator) { - if (ignoreLocation(binaryOperator)) { - return true; - } - visitAssign(binaryOperator->getLHS()->getType(), binaryOperator->getRHS()); - return true; -} - bool RedundantCast::VisitVarDecl(VarDecl const * varDecl) { if (ignoreLocation(varDecl)) { return true; |