aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-08-03 23:08:42 +0000
committerJordan Rose <jordan_rose@apple.com>2012-08-03 23:08:42 +0000
commit20165e796c16311a83911db74c04d797e93471b2 (patch)
treee78d8854010b202378fbd8f8f3135ed2a48422b1
parent51e87c5fa1d506058ed594b4290b06775ec74a8e (diff)
[analyzer] FindLastStoreBRVisitor was not actually finding stores.
The visitor walks back through the ExplodedGraph as expected, but it wasn't actually keeping track of when a value was assigned. This meant that it only worked when the value was assigned when the variable was defined. Tests in the next commit (dependent on another change). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161276 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/StaticAnalyzer/Core/BugReporterVisitors.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 4afc874f20..ded341caf9 100644
--- a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -63,14 +63,6 @@ const Stmt *bugreporter::GetDenomExpr(const ExplodedNode *N) {
return NULL;
}
-const Stmt *bugreporter::GetCalleeExpr(const ExplodedNode *N) {
- // Callee is checked as a PreVisit to the CallExpr.
- const Stmt *S = N->getLocationAs<PreStmt>()->getStmt();
- if (const CallExpr *CE = dyn_cast<CallExpr>(S))
- return CE->getCallee();
- return NULL;
-}
-
const Stmt *bugreporter::GetRetValExpr(const ExplodedNode *N) {
const Stmt *S = N->getLocationAs<PostStmt>()->getStmt();
if (const ReturnStmt *RS = dyn_cast<ReturnStmt>(S))
@@ -127,10 +119,16 @@ PathDiagnosticPiece *FindLastStoreBRVisitor::VisitNode(const ExplodedNode *N,
return NULL;
if (!StoreSite) {
- const ExplodedNode *Node = N, *Last = NULL;
+ // Make sure the region is actually bound to value V here.
+ // This is necessary because the region may not actually be live at the
+ // report's error node.
+ if (N->getState()->getSVal(R) != V)
+ return NULL;
- for ( ; Node ; Node = Node->getFirstPred()) {
+ const ExplodedNode *Node = N, *Last = N;
+ // Now look for the store of V.
+ for ( ; Node ; Node = Node->getFirstPred()) {
if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
if (const PostStmt *P = Node->getLocationAs<PostStmt>())
if (const DeclStmt *DS = P->getStmtAs<DeclStmt>())
@@ -145,9 +143,11 @@ PathDiagnosticPiece *FindLastStoreBRVisitor::VisitNode(const ExplodedNode *N,
// looking for store sites.
if (Node->getState()->getSVal(R) != V)
break;
+
+ Last = Node;
}
- if (!Node || !Last) {
+ if (!Node) {
satisfied = true;
return NULL;
}