From: Jordan Rose Date: Tue, 10 Dec 2013 18:18:10 +0000 (+0000) Subject: [analyzer] Misc. tidying in IdenticalExprChecker. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4325503b4413baf5893b2a684433c98f3ca86a3d;p=clang [analyzer] Misc. tidying in IdenticalExprChecker. Some things I missed when this first went in. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196938 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp b/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp index b17d799fc1..88f9f20a63 100644 --- a/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp @@ -166,7 +166,7 @@ static bool isIdenticalExpr(const ASTContext &Ctx, const Expr *Expr1, // are identical. if (!IgnoreSideEffects && Expr1->HasSideEffects(Ctx)) return false; - // Is expression is based on macro then don't warn even if + // If either expression comes from a macro then don't warn even if // the expressions are identical. if ((Expr1->getExprLoc().isMacroID()) || (Expr2->getExprLoc().isMacroID())) return false; @@ -199,41 +199,39 @@ static bool isIdenticalExpr(const ASTContext &Ctx, const Expr *Expr1, case Stmt::ParenExprClass: return true; case Stmt::BinaryOperatorClass: { - const BinaryOperator *BinOp1 = dyn_cast(Expr1); - const BinaryOperator *BinOp2 = dyn_cast(Expr2); + const BinaryOperator *BinOp1 = cast(Expr1); + const BinaryOperator *BinOp2 = cast(Expr2); return BinOp1->getOpcode() == BinOp2->getOpcode(); } case Stmt::CharacterLiteralClass: { - const CharacterLiteral *CharLit1 = dyn_cast(Expr1); - const CharacterLiteral *CharLit2 = dyn_cast(Expr2); + const CharacterLiteral *CharLit1 = cast(Expr1); + const CharacterLiteral *CharLit2 = cast(Expr2); return CharLit1->getValue() == CharLit2->getValue(); } case Stmt::DeclRefExprClass: { - const DeclRefExpr *DeclRef1 = dyn_cast(Expr1); - const DeclRefExpr *DeclRef2 = dyn_cast(Expr2); + const DeclRefExpr *DeclRef1 = cast(Expr1); + const DeclRefExpr *DeclRef2 = cast(Expr2); return DeclRef1->getDecl() == DeclRef2->getDecl(); } case Stmt::IntegerLiteralClass: { - const IntegerLiteral *IntLit1 = dyn_cast(Expr1); - const IntegerLiteral *IntLit2 = dyn_cast(Expr2); + const IntegerLiteral *IntLit1 = cast(Expr1); + const IntegerLiteral *IntLit2 = cast(Expr2); return IntLit1->getValue() == IntLit2->getValue(); } case Stmt::FloatingLiteralClass: { - const FloatingLiteral *FloatLit1 = dyn_cast(Expr1); - const FloatingLiteral *FloatLit2 = dyn_cast(Expr2); + const FloatingLiteral *FloatLit1 = cast(Expr1); + const FloatingLiteral *FloatLit2 = cast(Expr2); return FloatLit1->getValue().bitwiseIsEqual(FloatLit2->getValue()); } case Stmt::MemberExprClass: { - const MemberExpr *MemberExpr1 = dyn_cast(Expr1); - const MemberExpr *MemberExpr2 = dyn_cast(Expr2); + const MemberExpr *MemberExpr1 = cast(Expr1); + const MemberExpr *MemberExpr2 = cast(Expr2); return MemberExpr1->getMemberDecl() == MemberExpr2->getMemberDecl(); } case Stmt::UnaryOperatorClass: { - const UnaryOperator *UnaryOp1 = dyn_cast(Expr1); - const UnaryOperator *UnaryOp2 = dyn_cast(Expr2); - if (UnaryOp1->getOpcode() != UnaryOp2->getOpcode()) - return false; - return IgnoreSideEffects || !UnaryOp1->isIncrementDecrementOp(); + const UnaryOperator *UnaryOp1 = cast(Expr1); + const UnaryOperator *UnaryOp2 = cast(Expr2); + return UnaryOp1->getOpcode() == UnaryOp2->getOpcode(); } } }