r177846 - [analyzer] Teach ConstraintManager to ignore NonLoc <> NonLoc comparisons.
Jordan Rose
jordan_rose at apple.com
Sun Mar 24 13:25:22 PDT 2013
Author: jrose
Date: Sun Mar 24 15:25:22 2013
New Revision: 177846
URL: http://llvm.org/viewvc/llvm-project?rev=177846&view=rev
Log:
[analyzer] Teach ConstraintManager to ignore NonLoc <> NonLoc comparisons.
These aren't generated by default, but they are needed when either side of
the comparison is tainted.
Should fix our internal buildbot.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
cfe/trunk/test/Analysis/taint-generic.c
Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp?rev=177846&r1=177845&r2=177846&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp Sun Mar 24 15:25:22 2013
@@ -50,8 +50,13 @@ bool SimpleConstraintManager::canReasonA
}
if (const SymSymExpr *SSE = dyn_cast<SymSymExpr>(SE)) {
- if (BinaryOperator::isComparisonOp(SSE->getOpcode()))
- return true;
+ if (BinaryOperator::isComparisonOp(SSE->getOpcode())) {
+ // We handle Loc <> Loc comparisons, but not (yet) NonLoc <> NonLoc.
+ if (Loc::isLocType(SSE->getLHS()->getType())) {
+ assert(Loc::isLocType(SSE->getRHS()->getType()));
+ return true;
+ }
+ }
}
return false;
Modified: cfe/trunk/test/Analysis/taint-generic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/taint-generic.c?rev=177846&r1=177845&r2=177846&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/taint-generic.c (original)
+++ cfe/trunk/test/Analysis/taint-generic.c Sun Mar 24 15:25:22 2013
@@ -212,3 +212,14 @@ int SymSymExprWithDiffTypes(void* p) {
return 5/j; // expected-warning {{Division by a tainted value, possibly zero}}
}
+
+void constraintManagerShouldTreatAsOpaque(int rhs) {
+ int i;
+ scanf("%d", &i);
+ // This comparison used to hit an assertion in the constraint manager,
+ // which didn't handle NonLoc sym-sym comparisons.
+ if (i < rhs)
+ return;
+ if (i < rhs)
+ *(volatile int *) 0; // no-warning
+}
More information about the cfe-commits
mailing list