summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-03-24 20:25:22 +0000
committerJordan Rose <jordan_rose@apple.com>2013-03-24 20:25:22 +0000
commitd1d8929370ec3904e4b53364ed5fcc59968bd9cd (patch)
treec05f30a62357d98ebf211aa4c7685a4a9728cccf /clang
parent9619fc0bd133810acbb4d342630e9d9784242a84 (diff)
downloadbcm5719-llvm-d1d8929370ec3904e4b53364ed5fcc59968bd9cd.tar.gz
bcm5719-llvm-d1d8929370ec3904e4b53364ed5fcc59968bd9cd.zip
[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. llvm-svn: 177846
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp9
-rw-r--r--clang/test/Analysis/taint-generic.c11
2 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
index f6404f0f777..9b759df48f2 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
@@ -50,8 +50,13 @@ bool SimpleConstraintManager::canReasonAbout(SVal X) const {
}
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;
diff --git a/clang/test/Analysis/taint-generic.c b/clang/test/Analysis/taint-generic.c
index 696db67713a..fe27070026b 100644
--- a/clang/test/Analysis/taint-generic.c
+++ b/clang/test/Analysis/taint-generic.c
@@ -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
+}
OpenPOWER on IntegriCloud