[analyzer] Fix a bug in IdenticalExprChecker concerning while loops.
Somehow both Daniel and I missed the fact that while loops are only identical
if they have identical bodies.
Patch by Daniel Fahlgren!
llvm-svn: 201829
diff --git a/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
index a76dff1..6abfc14 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
@@ -361,8 +361,13 @@
const WhileStmt *WStmt1 = cast<WhileStmt>(Stmt1);
const WhileStmt *WStmt2 = cast<WhileStmt>(Stmt2);
- return isIdenticalStmt(Ctx, WStmt1->getCond(), WStmt2->getCond(),
- IgnoreSideEffects);
+ if (!isIdenticalStmt(Ctx, WStmt1->getCond(), WStmt2->getCond(),
+ IgnoreSideEffects))
+ return false;
+ if (!isIdenticalStmt(Ctx, WStmt1->getBody(), WStmt2->getBody(),
+ IgnoreSideEffects))
+ return false;
+ return true;
}
case Stmt::IfStmtClass: {
const IfStmt *IStmt1 = cast<IfStmt>(Stmt1);