diff options
author | Jordan Rose <jordan_rose@apple.com> | 2014-05-07 03:30:04 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2014-05-07 03:30:04 +0000 |
commit | 49afeb072f4d36e7c78c3e151d7860c28e106dd6 (patch) | |
tree | f0a6ded89e88eacde4148edccce179705f1a9083 /clang/lib/StaticAnalyzer | |
parent | 2741654b89c7b3f945d41dfc0c85f2dc4c1c1e58 (diff) | |
download | bcm5719-llvm-49afeb072f4d36e7c78c3e151d7860c28e106dd6.tar.gz bcm5719-llvm-49afeb072f4d36e7c78c3e151d7860c28e106dd6.zip |
[analyzer] Use a lazily-initialized BugType in ObjCSelfInitChecker.
Follow-up to Nico's leak-stopping patch in r208110.
llvm-svn: 208155
Diffstat (limited to 'clang/lib/StaticAnalyzer')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp index 3eec6815c90..51bc7e66dce 100644 --- a/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp @@ -55,13 +55,6 @@ static bool isInitMessage(const ObjCMethodCall &Msg); static bool isSelfVar(SVal location, CheckerContext &C); namespace { -class InitSelfBug : public BugType { -public: - InitSelfBug(const CheckerBase *Checker) - : BugType(Checker, "Missing \"self = [(super or self) init...]\"", - categories::CoreFoundationObjectiveC) {} -}; - class ObjCSelfInitChecker : public Checker< check::PostObjCMessage, check::PostStmt<ObjCIvarRefExpr>, check::PreStmt<ReturnStmt>, @@ -69,13 +62,13 @@ class ObjCSelfInitChecker : public Checker< check::PostObjCMessage, check::PostCall, check::Location, check::Bind > { - mutable InitSelfBug InitSelfBugType; + mutable std::unique_ptr<BugType> BT; void checkForInvalidSelf(const Expr *E, CheckerContext &C, const char *errorStr) const; public: - ObjCSelfInitChecker() : InitSelfBugType(this) {} + ObjCSelfInitChecker() {} void checkPostObjCMessage(const ObjCMethodCall &Msg, CheckerContext &C) const; void checkPostStmt(const ObjCIvarRefExpr *E, CheckerContext &C) const; void checkPreStmt(const ReturnStmt *S, CheckerContext &C) const; @@ -164,7 +157,10 @@ void ObjCSelfInitChecker::checkForInvalidSelf(const Expr *E, CheckerContext &C, if (!N) return; - BugReport *report = new BugReport(InitSelfBugType, errorStr, N); + if (!BT) + BT.reset(new BugType(this, "Missing \"self = [(super or self) init...]\"", + categories::CoreFoundationObjectiveC)); + BugReport *report = new BugReport(*BT, errorStr, N); C.emitReport(report); } |