diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-08-18 01:05:30 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-08-18 01:05:30 +0000 |
commit | 9b2c79de593e6e8ef0e4761ad5e963c3fdab3509 (patch) | |
tree | 83fbd2a4d1af8ec7d8c5ba4dc9bac985db004a17 /clang/lib/Analysis/GRExprEngineInternalChecks.cpp | |
parent | 1105cbc2702e87179f0c1e6e9c3474024b6a0205 (diff) | |
download | bcm5719-llvm-9b2c79de593e6e8ef0e4761ad5e963c3fdab3509.tar.gz bcm5719-llvm-9b2c79de593e6e8ef0e4761ad5e963c3fdab3509.zip |
Enhance static analyzer diagnostics by introducing a new 'EnhancedBugReporter'
which allows custom checks to register callback creator functions for creating
BugReporterVisitor objects. This allows various checks to include diagnostics
such as 'assuming value is null' with little extra work. Eventually this API
should be refactored to be cleaner and more simple.
llvm-svn: 79302
Diffstat (limited to 'clang/lib/Analysis/GRExprEngineInternalChecks.cpp')
-rw-r--r-- | clang/lib/Analysis/GRExprEngineInternalChecks.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/Analysis/GRExprEngineInternalChecks.cpp b/clang/lib/Analysis/GRExprEngineInternalChecks.cpp index 3c316eb3e90..d22f276a55c 100644 --- a/clang/lib/Analysis/GRExprEngineInternalChecks.cpp +++ b/clang/lib/Analysis/GRExprEngineInternalChecks.cpp @@ -583,7 +583,7 @@ public: if (stateNull && !stateNotNull) { // Generate an error node. Check for a null node in case // we cache out. - if (ExplodedNode *errorNode = C.generateNode(CE, stateNull)) { + if (ExplodedNode *errorNode = C.generateNode(CE, stateNull, true)) { // Lazily allocate the BugType object if it hasn't already been // created. Ownership is transferred to the BugReporter object once @@ -592,12 +592,15 @@ public: BT = new BugType("Argument with 'nonnull' attribute passed null", "API"); - RangedBugReport *R = - new RangedBugReport(*BT, "Null pointer passed as an argument to a " - "'nonnull' parameter", errorNode); + EnhancedBugReport *R = + new EnhancedBugReport(*BT, + "Null pointer passed as an argument to a " + "'nonnull' parameter", errorNode); // Highlight the range of the argument that was null. - R->addRange((*I)->getSourceRange()); + const Expr *arg = *I; + R->addRange(arg->getSourceRange()); + R->addVisitorCreator(registerTrackNullOrUndefValue, arg); // Emit the bug report. C.EmitReport(R); |