diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-11-05 00:42:23 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-11-05 00:42:23 +0000 |
commit | 209e31b883a3bbab932f78ede6c8e6ed99713c38 (patch) | |
tree | a12c30abf77c0bbe885829a78c888b67d429de97 /clang/lib/Analysis/UndefinedAssignmentChecker.cpp | |
parent | 644a4181c947bfc0dc7775fc4843c7c1e599ed7c (diff) | |
download | bcm5719-llvm-209e31b883a3bbab932f78ede6c8e6ed99713c38.tar.gz bcm5719-llvm-209e31b883a3bbab932f78ede6c8e6ed99713c38.zip |
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.
llvm-svn: 86084
Diffstat (limited to 'clang/lib/Analysis/UndefinedAssignmentChecker.cpp')
-rw-r--r-- | clang/lib/Analysis/UndefinedAssignmentChecker.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/clang/lib/Analysis/UndefinedAssignmentChecker.cpp b/clang/lib/Analysis/UndefinedAssignmentChecker.cpp index c5b2401f47c..2e3ac34913a 100644 --- a/clang/lib/Analysis/UndefinedAssignmentChecker.cpp +++ b/clang/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); |