diff options
| author | Tom Care <tom.care@uqconnect.edu.au> | 2010-09-02 17:49:20 +0000 |
|---|---|---|
| committer | Tom Care <tom.care@uqconnect.edu.au> | 2010-09-02 17:49:20 +0000 |
| commit | 1ce2faca0552fac5ffc039487ca376d412d5468b (patch) | |
| tree | 7fa5611965c8102ceaea76e06be0970dab51efde /clang/lib/Checker/BugReporterVisitors.cpp | |
| parent | 04f3621860d5e41b63802ea6ed0e3009f0e2d38e (diff) | |
| download | bcm5719-llvm-1ce2faca0552fac5ffc039487ca376d412d5468b.tar.gz bcm5719-llvm-1ce2faca0552fac5ffc039487ca376d412d5468b.zip | |
Improved error reporting in IdempotentOperationChecker
- SourceRange highlighting is only given for the relevant side of the operator (assignments give both)
- Added PostVisitBinaryOperator hook to retrieve the ExplodedNode for an operator
- Added a BugReporterVisitor to display the last store to every VarDecl in a Stmt
- Changed bug reporting to use the new BugReporterVisitor
llvm-svn: 112839
Diffstat (limited to 'clang/lib/Checker/BugReporterVisitors.cpp')
| -rw-r--r-- | clang/lib/Checker/BugReporterVisitors.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/clang/lib/Checker/BugReporterVisitors.cpp b/clang/lib/Checker/BugReporterVisitors.cpp index cddc86ee9dc..91cf349107c 100644 --- a/clang/lib/Checker/BugReporterVisitors.cpp +++ b/clang/lib/Checker/BugReporterVisitors.cpp @@ -419,3 +419,40 @@ public: void clang::bugreporter::registerNilReceiverVisitor(BugReporterContext &BRC) { BRC.addVisitor(new NilReceiverVisitor()); } + +// Registers every VarDecl inside a Stmt with a last store vistor. +void clang::bugreporter::registerVarDeclsLastStore(BugReporterContext &BRC, + const void *stmt, + const ExplodedNode *N) { + const Stmt *S = static_cast<const Stmt *>(stmt); + + std::deque<const Stmt *> WorkList; + + WorkList.push_back(S); + + while (!WorkList.empty()) { + const Stmt *Head = WorkList.front(); + WorkList.pop_front(); + + GRStateManager &StateMgr = BRC.getStateManager(); + const GRState *state = N->getState(); + + if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Head)) { + if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) { + const VarRegion *R = + StateMgr.getRegionManager().getVarRegion(VD, N->getLocationContext()); + + // What did we load? + SVal V = state->getSVal(S); + + if (isa<loc::ConcreteInt>(V) || isa<nonloc::ConcreteInt>(V)) { + ::registerFindLastStore(BRC, R, V); + } + } + } + + for (Stmt::const_child_iterator I = Head->child_begin(); + I != Head->child_end(); ++I) + WorkList.push_back(*I); + } +} |

