diff options
author | Anna Zaks <ganna@apple.com> | 2011-10-26 21:06:39 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2011-10-26 21:06:39 +0000 |
commit | 48468dfeb3ccf099ed51ff5dcb8ae0fe783692fd (patch) | |
tree | 53220c6cfd6702bd1111f965f5a9ac05cc5c0acf /lib/StaticAnalyzer | |
parent | 0bd6b110e908892d4b5c8671a9f435a1d72ad16a (diff) |
[analyzer] Remove EmitBasicReport form CheckerContext.
The path sensitive checkers should use EmitBasicReport, which provides the
node information.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143060 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp b/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp index 4eabd7aaf3..a86f586d1d 100644 --- a/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp @@ -19,6 +19,7 @@ #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h" @@ -31,7 +32,7 @@ using namespace ento; namespace { class NSAutoreleasePoolChecker : public Checker<check::PreObjCMessage> { - + mutable llvm::OwningPtr<BugType> BT; mutable Selector releaseS; public: @@ -65,16 +66,21 @@ void NSAutoreleasePoolChecker::checkPreObjCMessage(ObjCMessage msg, // Sending 'release' message? if (msg.getSelector() != releaseS) return; - - SourceRange R = msg.getSourceRange(); - const LocationContext *LC = C.getPredecessor()->getLocationContext(); - const SourceManager &SM = C.getSourceManager(); - const Expr *E = msg.getMsgOrPropExpr(); - PathDiagnosticLocation L = PathDiagnosticLocation::createBegin(E, SM, LC); - C.EmitBasicReport("Use -drain instead of -release", - "API Upgrade (Apple)", - "Use -drain instead of -release when using NSAutoreleasePool " - "and garbage collection", L, &R, 1); + + if (!BT) + BT.reset(new BugType("Use -drain instead of -release", + "API Upgrade (Apple)")); + + ExplodedNode *N = C.addTransition(); + if (!N) { + assert(0); + return; + } + + BugReport *Report = new BugReport(*BT, "Use -drain instead of -release when " + "using NSAutoreleasePool and garbage collection", N); + Report->addRange(msg.getSourceRange()); + C.EmitReport(Report); } void ento::registerNSAutoreleasePoolChecker(CheckerManager &mgr) { |