r196938 - [analyzer] Misc. tidying in IdenticalExprChecker.

Jordan Rose jordan_rose at apple.com
Tue Dec 10 10:18:10 PST 2013


Author: jrose
Date: Tue Dec 10 12:18:10 2013
New Revision: 196938

URL: http://llvm.org/viewvc/llvm-project?rev=196938&view=rev
Log:
[analyzer] Misc. tidying in IdenticalExprChecker.

Some things I missed when this first went in.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp?rev=196938&r1=196937&r2=196938&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp Tue Dec 10 12:18:10 2013
@@ -166,7 +166,7 @@ static bool isIdenticalExpr(const ASTCon
   // 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 ASTCon
   case Stmt::ParenExprClass:
     return true;
   case Stmt::BinaryOperatorClass: {
-    const BinaryOperator *BinOp1 = dyn_cast<BinaryOperator>(Expr1);
-    const BinaryOperator *BinOp2 = dyn_cast<BinaryOperator>(Expr2);
+    const BinaryOperator *BinOp1 = cast<BinaryOperator>(Expr1);
+    const BinaryOperator *BinOp2 = cast<BinaryOperator>(Expr2);
     return BinOp1->getOpcode() == BinOp2->getOpcode();
   }
   case Stmt::CharacterLiteralClass: {
-    const CharacterLiteral *CharLit1 = dyn_cast<CharacterLiteral>(Expr1);
-    const CharacterLiteral *CharLit2 = dyn_cast<CharacterLiteral>(Expr2);
+    const CharacterLiteral *CharLit1 = cast<CharacterLiteral>(Expr1);
+    const CharacterLiteral *CharLit2 = cast<CharacterLiteral>(Expr2);
     return CharLit1->getValue() == CharLit2->getValue();
   }
   case Stmt::DeclRefExprClass: {
-    const DeclRefExpr *DeclRef1 = dyn_cast<DeclRefExpr>(Expr1);
-    const DeclRefExpr *DeclRef2 = dyn_cast<DeclRefExpr>(Expr2);
+    const DeclRefExpr *DeclRef1 = cast<DeclRefExpr>(Expr1);
+    const DeclRefExpr *DeclRef2 = cast<DeclRefExpr>(Expr2);
     return DeclRef1->getDecl() == DeclRef2->getDecl();
   }
   case Stmt::IntegerLiteralClass: {
-    const IntegerLiteral *IntLit1 = dyn_cast<IntegerLiteral>(Expr1);
-    const IntegerLiteral *IntLit2 = dyn_cast<IntegerLiteral>(Expr2);
+    const IntegerLiteral *IntLit1 = cast<IntegerLiteral>(Expr1);
+    const IntegerLiteral *IntLit2 = cast<IntegerLiteral>(Expr2);
     return IntLit1->getValue() == IntLit2->getValue();
   }
   case Stmt::FloatingLiteralClass: {
-    const FloatingLiteral *FloatLit1 = dyn_cast<FloatingLiteral>(Expr1);
-    const FloatingLiteral *FloatLit2 = dyn_cast<FloatingLiteral>(Expr2);
+    const FloatingLiteral *FloatLit1 = cast<FloatingLiteral>(Expr1);
+    const FloatingLiteral *FloatLit2 = cast<FloatingLiteral>(Expr2);
     return FloatLit1->getValue().bitwiseIsEqual(FloatLit2->getValue());
   }
   case Stmt::MemberExprClass: {
-    const MemberExpr *MemberExpr1 = dyn_cast<MemberExpr>(Expr1);
-    const MemberExpr *MemberExpr2 = dyn_cast<MemberExpr>(Expr2);
+    const MemberExpr *MemberExpr1 = cast<MemberExpr>(Expr1);
+    const MemberExpr *MemberExpr2 = cast<MemberExpr>(Expr2);
     return MemberExpr1->getMemberDecl() == MemberExpr2->getMemberDecl();
   }
   case Stmt::UnaryOperatorClass: {
-    const UnaryOperator *UnaryOp1 = dyn_cast<UnaryOperator>(Expr1);
-    const UnaryOperator *UnaryOp2 = dyn_cast<UnaryOperator>(Expr2);
-    if (UnaryOp1->getOpcode() != UnaryOp2->getOpcode())
-      return false;
-    return IgnoreSideEffects || !UnaryOp1->isIncrementDecrementOp();
+    const UnaryOperator *UnaryOp1 = cast<UnaryOperator>(Expr1);
+    const UnaryOperator *UnaryOp2 = cast<UnaryOperator>(Expr2);
+    return UnaryOp1->getOpcode() == UnaryOp2->getOpcode();
   }
   }
 }





More information about the cfe-commits mailing list