aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/UndefinedAssignmentChecker.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-11-05 00:42:23 +0000
committerTed Kremenek <kremenek@apple.com>2009-11-05 00:42:23 +0000
commit50ecd1536a2b70327e9eb2c2c2a652cde3dae365 (patch)
tree493b939ce7b3e54edcb9a66006f7a30e4ebc40f1 /lib/Analysis/UndefinedAssignmentChecker.cpp
parent45aa4557fe4210034e85f4a807ff637a9dd146d6 (diff)
Modify GRExprEngine::EvalBind() to take both a "store expression" and
an "assign expression", representing the expressions where the value binding occurs and the assignment takes place respectively. These are largely syntactic clues for better error reporting. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86084 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/UndefinedAssignmentChecker.cpp')
-rw-r--r--lib/Analysis/UndefinedAssignmentChecker.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/lib/Analysis/UndefinedAssignmentChecker.cpp b/lib/Analysis/UndefinedAssignmentChecker.cpp
index c5b2401f47..2e3ac34913 100644
--- a/lib/Analysis/UndefinedAssignmentChecker.cpp
+++ b/lib/Analysis/UndefinedAssignmentChecker.cpp
@@ -22,14 +22,15 @@ void *UndefinedAssignmentChecker::getTag() {
return &x;
}
-void UndefinedAssignmentChecker::PreVisitBind(CheckerContext &C,
- const Stmt *S,
+void UndefinedAssignmentChecker::PreVisitBind(CheckerContext &C,
+ const Stmt *AssignE,
+ const Stmt *StoreE,
SVal location,
SVal val) {
if (!val.isUndef())
return;
- ExplodedNode *N = C.GenerateNode(S, true);
+ ExplodedNode *N = C.GenerateNode(StoreE, true);
if (!N)
return;
@@ -40,20 +41,20 @@ void UndefinedAssignmentChecker::PreVisitBind(CheckerContext &C,
// Generate a report for this bug.
EnhancedBugReport *R = new EnhancedBugReport(*BT, BT->getName().c_str(), N);
- const Expr *ex = 0;
-
- // FIXME: This check needs to be done on the expression doing the
- // assignment, not the "store" expression.
- if (const BinaryOperator *B = dyn_cast<BinaryOperator>(S))
- ex = B->getRHS();
- else if (const DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
- const VarDecl* VD = dyn_cast<VarDecl>(DS->getSingleDecl());
- ex = VD->getInit();
- }
- if (ex) {
- R->addRange(ex->getSourceRange());
- R->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, ex);
+ if (AssignE) {
+ const Expr *ex = 0;
+
+ if (const BinaryOperator *B = dyn_cast<BinaryOperator>(AssignE))
+ ex = B->getRHS();
+ else if (const DeclStmt *DS = dyn_cast<DeclStmt>(AssignE)) {
+ const VarDecl* VD = dyn_cast<VarDecl>(DS->getSingleDecl());
+ ex = VD->getInit();
+ }
+ if (ex) {
+ R->addRange(ex->getSourceRange());
+ R->addVisitorCreator(bugreporter::registerTrackNullOrUndefValue, ex);
+ }
}
C.EmitReport(R);