r208155 - [analyzer] Use a lazily-initialized BugType in ObjCSelfInitChecker.

Nico Weber thakis at chromium.org
Wed May 7 08:22:10 PDT 2014


Thanks!

On Tue, May 6, 2014 at 8:30 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> Author: jrose
> Date: Tue May  6 22:30:04 2014
> New Revision: 208155
>
> URL: http://llvm.org/viewvc/llvm-project?rev=208155&view=rev
> Log:
> [analyzer] Use a lazily-initialized BugType in ObjCSelfInitChecker.
>
> Follow-up to Nico's leak-stopping patch in r208110.
>
> Modified:
>     cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp?rev=208155&r1=208154&r2=208155&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp Tue May  6 22:30:04 2014
> @@ -55,13 +55,6 @@ static bool isInitMessage(const ObjCMeth
>  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 Check
>                                               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::checkForInvali
>    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);
>  }
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list