<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 4, 2014 at 5:13 PM, Justin Bogner <span dir="ltr"><<a href="mailto:mail@justinbogner.com" target="_blank">mail@justinbogner.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> writes:<br>
> Author: dblaikie<br>
> Date: Thu Sep  4 18:54:33 2014<br>
> New Revision: 217205<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=217205&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=217205&view=rev</a><br>
> Log:<br>
> unique_ptrify BugReporter::visitors<br>
><br>
> Modified:<br>
>     cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h<br>
>     cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h<br>
>     cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp<br>
>     cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp<br>
>     cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp<br>
>     cfe/trunk/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp<br>
>     cfe/trunk/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp<br>
>     cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp<br>
>     cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp<br>
><br>
> Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=217205&r1=217204&r2=217205&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=217205&r1=217204&r2=217205&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h (original)<br>
> +++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Thu Sep  4 18:54:33 2014<br>
> @@ -63,7 +63,7 @@ public:<br>
>    };<br>
><br>
>    typedef const SourceRange *ranges_iterator;<br>
> -  typedef SmallVector<BugReporterVisitor *, 8> VisitorList;<br>
> +  typedef SmallVector<std::unique_ptr<BugReporterVisitor>, 8> VisitorList;<br>
>    typedef VisitorList::iterator visitor_iterator;<br>
>    typedef SmallVector<StringRef, 2> ExtraTextList;<br>
><br>
> @@ -299,9 +299,9 @@ public:<br>
>    /// \sa registerConditionVisitor(), registerTrackNullOrUndefValue(),<br>
>    /// registerFindLastStore(), registerNilReceiverVisitor(), and<br>
>    /// registerVarDeclsLastStore().<br>
> -  void addVisitor(BugReporterVisitor *visitor);<br>
> +  void addVisitor(std::unique_ptr<BugReporterVisitor> visitor);<br>
><br>
> -     /// Iterators through the custom diagnostic visitors.<br>
> +        /// Iterators through the custom diagnostic visitors.<br>
>    visitor_iterator visitor_begin() { return Callbacks.begin(); }<br>
>    visitor_iterator visitor_end() { return Callbacks.end(); }<br>
<br>
</div></div>Spacing looks pretty strange here.<br></blockquote><div><br></div><div>Yeah, I thought I'd at least managed to avoid clang-format modifying that line, though it was weird before (& weird after, but just differently weird... ) but I guess not.<br><br>Fixed it properly in r217209.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><div class="h5"><br>
><br>
><br>
> Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h?rev=217205&r1=217204&r2=217205&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h?rev=217205&r1=217204&r2=217205&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h (original)<br>
> +++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h Thu Sep  4 18:54:33 2014<br>
> @@ -48,7 +48,7 @@ public:<br>
>    /// (Warning: if you have a deep subclass of BugReporterVisitorImpl, the<br>
>    /// default implementation of clone() will NOT do the right thing, and you<br>
>    /// will have to provide your own implementation.)<br>
> -  virtual BugReporterVisitor *clone() const = 0;<br>
> +  virtual std::unique_ptr<BugReporterVisitor> clone() const = 0;<br>
><br>
>    /// \brief Return a diagnostic piece which should be associated with the<br>
>    /// given node.<br>
> @@ -87,8 +87,8 @@ public:<br>
>  /// will have to provide your own implementation.)<br>
>  template <class DERIVED><br>
>  class BugReporterVisitorImpl : public BugReporterVisitor {<br>
> -  BugReporterVisitor *clone() const override {<br>
> -    return new DERIVED(*static_cast<const DERIVED *>(this));<br>
> +  std::unique_ptr<BugReporterVisitor> clone() const override {<br>
> +  4:30pm  return llvm::make_unique<DERIVED>(*static_cast<const DERIVED *>(this));<br>
>    }<br>
>  };<br>
><br>
><br>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp?rev=217205&r1=217204&r2=217205&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp?rev=217205&r1=217204&r2=217205&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp (original)<br>
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp Thu Sep  4 18:54:33 2014<br>
> @@ -270,7 +270,7 @@ void MacOSKeychainAPIChecker::<br>
>    os << "Deallocator doesn't match the allocator: '"<br>
>       << FunctionsToTrack[PDeallocIdx].Name << "' should be used.";<br>
>    BugReport *Report = new BugReport(*BT, os.str(), N);<br>
> -  Report->addVisitor(new SecKeychainBugVisitor(AP.first));<br>
> +  Report->addVisitor(llvm::make_unique<SecKeychainBugVisitor>(AP.first));<br>
>    Report->addRange(ArgExpr->getSourceRange());<br>
>    markInteresting(Report, AP);<br>
>    C.emitReport(Report);<br>
> @@ -311,7 +311,7 @@ void MacOSKeychainAPIChecker::checkPreSt<br>
>                << FunctionsToTrack[DIdx].Name<br>
>                << "'.";<br>
>            BugReport *Report = new BugReport(*BT, os.str(), N);<br>
> -          Report->addVisitor(new SecKeychainBugVisitor(V));<br>
> +          Report->addVisitor(llvm::make_unique<SecKeychainBugVisitor>(V));<br>
>            Report->addRange(ArgExpr->getSourceRange());<br>
>            Report->markInteresting(AS->Region);<br>
>            C.emitReport(Report);<br>
> @@ -430,7 +430,7 @@ void MacOSKeychainAPIChecker::checkPreSt<br>
>      initBugType();<br>
>      BugReport *Report = new BugReport(*BT,<br>
>          "Only call free if a valid (non-NULL) buffer was returned.", N);<br>
> -    Report->addVisitor(new SecKeychainBugVisitor(ArgSM));<br>
> +    Report->addVisitor(llvm::make_unique<SecKeychainBugVisitor>(ArgSM));<br>
>      Report->addRange(ArgExpr->getSourceRange());<br>
>      Report->markInteresting(AS->Region);<br>
>      C.emitReport(Report);<br>
> @@ -540,7 +540,7 @@ BugReport *MacOSKeychainAPIChecker::<br>
>    BugReport *Report = new BugReport(*BT, os.str(), N, LocUsedForUniqueing,<br>
>                                     AllocNode->getLocationContext()->getDecl());<br>
><br>
> -  Report->addVisitor(new SecKeychainBugVisitor(AP.first));<br>
> +  Report->addVisitor(llvm::make_unique<SecKeychainBugVisitor>(AP.first));<br>
>    markInteresting(Report, AP);<br>
>    return Report;<br>
>  }<br>
><br>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=217205&r1=217204&r2=217205&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=217205&r1=217204&r2=217205&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)<br>
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Thu Sep  4 18:54:33 2014<br>
> @@ -1467,7 +1467,7 @@ void MallocChecker::ReportMismatchedDeal<br>
>      BugReport *R = new BugReport(*BT_MismatchedDealloc, os.str(), N);<br>
>      R->markInteresting(Sym);<br>
>      R->addRange(Range);<br>
> -    R->addVisitor(new MallocBugVisitor(Sym));<br>
> +    R->addVisitor(llvm::make_unique<MallocBugVisitor>(Sym));<br>
>      C.emitReport(R);<br>
>    }<br>
>  }<br>
> @@ -1551,7 +1551,7 @@ void MallocChecker::ReportUseAfterFree(C<br>
><br>
>      R->markInteresting(Sym);<br>
>      R->addRange(Range);<br>
> -    R->addVisitor(new MallocBugVisitor(Sym));<br>
> +    R->addVisitor(llvm::make_unique<MallocBugVisitor>(Sym));<br>
>      C.emitReport(R);<br>
>    }<br>
>  }<br>
> @@ -1583,7 +1583,7 @@ void MallocChecker::ReportDoubleFree(Che<br>
>      R->markInteresting(Sym);<br>
>      if (PrevSym)<br>
>        R->markInteresting(PrevSym);<br>
> -    R->addVisitor(new MallocBugVisitor(Sym));<br>
> +    R->addVisitor(llvm::make_unique<MallocBugVisitor>(Sym));<br>
>      C.emitReport(R);<br>
>    }<br>
>  }<br>
> @@ -1607,7 +1607,7 @@ void MallocChecker::ReportDoubleDelete(C<br>
>                                   "Attempt to delete released memory", N);<br>
><br>
>      R->markInteresting(Sym);<br>
> -    R->addVisitor(new MallocBugVisitor(Sym));<br>
> +    R->addVisitor(llvm::make_unique<MallocBugVisitor>(Sym));<br>
>      C.emitReport(R);<br>
>    }<br>
>  }<br>
> @@ -1835,7 +1835,7 @@ void MallocChecker::reportLeak(SymbolRef<br>
>        new BugReport(*BT_Leak[*CheckKind], os.str(), N, LocUsedForUniqueing,<br>
>                      AllocNode->getLocationContext()->getDecl());<br>
>    R->markInteresting(Sym);<br>
> -  R->addVisitor(new MallocBugVisitor(Sym, true));<br>
> +  R->addVisitor(llvm::make_unique<MallocBugVisitor>(Sym, true));<br>
>    C.emitReport(R);<br>
>  }<br>
><br>
><br>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=217205&r1=217204&r2=217205&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=217205&r1=217204&r2=217205&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)<br>
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Thu Sep  4 18:54:33 2014<br>
> @@ -1732,13 +1732,13 @@ namespace {<br>
>                                                      const ExplodedNode *N,<br>
>                                                      BugReport &BR) override;<br>
><br>
> -    BugReporterVisitor *clone() const override {<br>
> +    std::unique_ptr<BugReporterVisitor> clone() const override {<br>
>        // The curiously-recurring template pattern only works for one level of<br>
>        // subclassing. Rather than make a new template base for<br>
>        // CFRefReportVisitor, we simply override clone() to do the right thing.<br>
>        // This could be trouble someday if BugReporterVisitorImpl is ever<br>
>        // used for something else besides a convenient implementation of clone().<br>
> -      return new CFRefLeakReportVisitor(*this);<br>
> +      return llvm::make_unique<CFRefLeakReportVisitor>(*this);<br>
>      }<br>
>    };<br>
><br>
> @@ -1751,7 +1751,7 @@ namespace {<br>
>                  bool registerVisitor = true)<br>
>        : BugReport(D, D.getDescription(), n) {<br>
>        if (registerVisitor)<br>
> -        addVisitor(new CFRefReportVisitor(sym, GCEnabled, Log));<br>
> +        addVisitor(llvm::make_unique<CFRefReportVisitor>(sym, GCEnabled, Log));<br>
>        addGCModeDescription(LOpts, GCEnabled);<br>
>      }<br>
><br>
> @@ -1759,7 +1759,7 @@ namespace {<br>
>                  const SummaryLogTy &Log, ExplodedNode *n, SymbolRef sym,<br>
>                  StringRef endText)<br>
>        : BugReport(D, D.getDescription(), endText, n) {<br>
> -      addVisitor(new CFRefReportVisitor(sym, GCEnabled, Log));<br>
> +      addVisitor(llvm::make_unique<CFRefReportVisitor>(sym, GCEnabled, Log));<br>
>        addGCModeDescription(LOpts, GCEnabled);<br>
>      }<br>
><br>
> @@ -2387,7 +2387,7 @@ CFRefLeakReport::CFRefLeakReport(CFRefBu<br>
>      }<br>
>    }<br>
><br>
> -  addVisitor(new CFRefLeakReportVisitor(sym, GCEnabled, Log));<br>
> +  addVisitor(llvm::make_unique<CFRefLeakReportVisitor>(sym, GCEnabled, Log));<br>
>  }<br>
><br>
>  //===----------------------------------------------------------------------===//<br>
><br>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp?rev=217205&r1=217204&r2=217205&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp?rev=217205&r1=217204&r2=217205&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp (original)<br>
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp Thu Sep  4 18:54:33 2014<br>
> @@ -176,7 +176,8 @@ void TestAfterDivZeroChecker::reportBug(<br>
>                                     "already been used for division",<br>
>                        N);<br>
><br>
> -    R->addVisitor(new DivisionBRVisitor(Val.getAsSymbol(), C.getStackFrame()));<br>
> +    R->addVisitor(llvm::make_unique<DivisionBRVisitor>(Val.getAsSymbol(),<br>
> +                                                       C.getStackFrame()));<br>
>      C.emitReport(R);<br>
>    }<br>
>  }<br>
><br>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp?rev=217205&r1=217204&r2=217205&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp?rev=217205&r1=217204&r2=217205&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp (original)<br>
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp Thu Sep  4 18:54:33 2014<br>
> @@ -92,8 +92,8 @@ UndefCapturedBlockVarChecker::checkPostS<br>
>          BugReport *R = new BugReport(*BT, os.str(), N);<br>
>          if (const Expr *Ex = FindBlockDeclRefExpr(BE->getBody(), VD))<br>
>            R->addRange(Ex->getSourceRange());<br>
> -        R->addVisitor(new FindLastStoreBRVisitor(*V, VR,<br>
> -                                             /*EnableNullFPSuppression*/false));<br>
> +        R->addVisitor(llvm::make_unique<FindLastStoreBRVisitor>(<br>
> +            *V, VR, /*EnableNullFPSuppression*/ false));<br>
>          R->disablePathPruning();<br>
>          // need location of block<br>
>          C.emitReport(R);<br>
><br>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=217205&r1=217204&r2=217205&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=217205&r1=217204&r2=217205&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)<br>
> +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Thu Sep  4 18:54:33 2014<br>
> @@ -499,10 +499,9 @@ PathDiagnosticBuilder::getEnclosingStmtL<br>
>  //===----------------------------------------------------------------------===//<br>
>  // "Visitors only" path diagnostic generation algorithm.<br>
>  //===----------------------------------------------------------------------===//<br>
> -static bool GenerateVisitorsOnlyPathDiagnostic(PathDiagnostic &PD,<br>
> -                                               PathDiagnosticBuilder &PDB,<br>
> -                                               const ExplodedNode *N,<br>
> -                                      ArrayRef<BugReporterVisitor *> visitors) {<br>
> +static bool GenerateVisitorsOnlyPathDiagnostic(<br>
> +    PathDiagnostic &PD, PathDiagnosticBuilder &PDB, const ExplodedNode *N,<br>
> +    ArrayRef<std::unique_ptr<BugReporterVisitor>> visitors) {<br>
>    // All path generation skips the very first node (the error node).<br>
>    // This is because there is special handling for the end-of-path note.<br>
>    N = N->getFirstPred();<br>
> @@ -511,11 +510,9 @@ static bool GenerateVisitorsOnlyPathDiag<br>
><br>
>    BugReport *R = PDB.getBugReport();<br>
>    while (const ExplodedNode *Pred = N->getFirstPred()) {<br>
> -    for (ArrayRef<BugReporterVisitor *>::iterator I = visitors.begin(),<br>
> -                                                  E = visitors.end();<br>
> -         I != E; ++I) {<br>
> +    for (auto &V : visitors) {<br>
>        // Visit all the node pairs, but throw the path pieces away.<br>
> -      PathDiagnosticPiece *Piece = (*I)->VisitNode(N, Pred, PDB, *R);<br>
> +      PathDiagnosticPiece *Piece = V->VisitNode(N, Pred, PDB, *R);<br>
>        delete Piece;<br>
>      }<br>
><br>
> @@ -556,11 +553,10 @@ static void updateStackPiecesWithMessage<br>
><br>
>  static void CompactPathDiagnostic(PathPieces &path, const SourceManager& SM);<br>
><br>
> -static bool GenerateMinimalPathDiagnostic(PathDiagnostic& PD,<br>
> -                                          PathDiagnosticBuilder &PDB,<br>
> -                                          const ExplodedNode *N,<br>
> -                                          LocationContextMap &LCM,<br>
> -                                      ArrayRef<BugReporterVisitor *> visitors) {<br>
> +static bool GenerateMinimalPathDiagnostic(<br>
> +    PathDiagnostic &PD, PathDiagnosticBuilder &PDB, const ExplodedNode *N,<br>
> +    LocationContextMap &LCM,<br>
> +    ArrayRef<std::unique_ptr<BugReporterVisitor>> visitors) {<br>
><br>
>    SourceManager& SMgr = PDB.getSourceManager();<br>
>    const LocationContext *LC = <a href="http://PDB.LC" target="_blank">PDB.LC</a>;<br>
> @@ -870,10 +866,8 @@ static bool GenerateMinimalPathDiagnosti<br>
>      if (NextNode) {<br>
>        // Add diagnostic pieces from custom visitors.<br>
>        BugReport *R = PDB.getBugReport();<br>
> -      for (ArrayRef<BugReporterVisitor *>::iterator I = visitors.begin(),<br>
> -                                                    E = visitors.end();<br>
> -           I != E; ++I) {<br>
> -        if (PathDiagnosticPiece *p = (*I)->VisitNode(N, NextNode, PDB, *R)) {<br>
> +      for (auto &V : visitors) {<br>
> +        if (PathDiagnosticPiece *p = V->VisitNode(N, NextNode, PDB, *R)) {<br>
>            PD.getActivePath().push_front(p);<br>
>            updateStackPiecesWithMessage(p, CallStack);<br>
>          }<br>
> @@ -1392,11 +1386,10 @@ static bool isInLoopBody(ParentMap &PM,<br>
>  // Top-level logic for generating extensive path diagnostics.<br>
>  //===----------------------------------------------------------------------===//<br>
><br>
> -static bool GenerateExtensivePathDiagnostic(PathDiagnostic& PD,<br>
> -                                            PathDiagnosticBuilder &PDB,<br>
> -                                            const ExplodedNode *N,<br>
> -                                            LocationContextMap &LCM,<br>
> -                                      ArrayRef<BugReporterVisitor *> visitors) {<br>
> +static bool GenerateExtensivePathDiagnostic(<br>
> +    PathDiagnostic &PD, PathDiagnosticBuilder &PDB, const ExplodedNode *N,<br>
> +    LocationContextMap &LCM,<br>
> +    ArrayRef<std::unique_ptr<BugReporterVisitor>> visitors) {<br>
>    EdgeBuilder EB(PD, PDB);<br>
>    const SourceManager& SM = PDB.getSourceManager();<br>
>    StackDiagVector CallStack;<br>
> @@ -1573,10 +1566,8 @@ static bool GenerateExtensivePathDiagnos<br>
><br>
>      // Add pieces from custom visitors.<br>
>      BugReport *R = PDB.getBugReport();<br>
> -    for (ArrayRef<BugReporterVisitor *>::iterator I = visitors.begin(),<br>
> -                                                  E = visitors.end();<br>
> -         I != E; ++I) {<br>
> -      if (PathDiagnosticPiece *p = (*I)->VisitNode(N, NextNode, PDB, *R)) {<br>
> +    for (auto &V : visitors) {<br>
> +      if (PathDiagnosticPiece *p = V->VisitNode(N, NextNode, PDB, *R)) {<br>
>          const PathDiagnosticLocation &Loc = p->getLocation();<br>
>          EB.addEdge(Loc, true);<br>
>          PD.getActivePath().push_front(p);<br>
> @@ -1635,12 +1626,10 @@ static const char StrLoopRangeEmpty[] =<br>
>  static const char StrLoopCollectionEmpty[] =<br>
>    "Loop body skipped when collection is empty";<br>
><br>
> -static bool<br>
> -GenerateAlternateExtensivePathDiagnostic(PathDiagnostic& PD,<br>
> -                                         PathDiagnosticBuilder &PDB,<br>
> -                                         const ExplodedNode *N,<br>
> -                                         LocationContextMap &LCM,<br>
> -                                      ArrayRef<BugReporterVisitor *> visitors) {<br>
> +static bool GenerateAlternateExtensivePathDiagnostic(<br>
> +    PathDiagnostic &PD, PathDiagnosticBuilder &PDB, const ExplodedNode *N,<br>
> +    LocationContextMap &LCM,<br>
> +    ArrayRef<std::unique_ptr<BugReporterVisitor>> visitors) {<br>
><br>
>    BugReport *report = PDB.getBugReport();<br>
>    const SourceManager& SM = PDB.getSourceManager();<br>
> @@ -1867,10 +1856,8 @@ GenerateAlternateExtensivePathDiagnostic<br>
>        continue;<br>
><br>
>      // Add pieces from custom visitors.<br>
> -    for (ArrayRef<BugReporterVisitor *>::iterator I = visitors.begin(),<br>
> -         E = visitors.end();<br>
> -         I != E; ++I) {<br>
> -      if (PathDiagnosticPiece *p = (*I)->VisitNode(N, NextNode, PDB, *report)) {<br>
> +    for (auto &V : visitors) {<br>
> +      if (PathDiagnosticPiece *p = V->VisitNode(N, NextNode, PDB, *report)) {<br>
>          addEdgeToPath(PD.getActivePath(), PrevLoc, p->getLocation(), <a href="http://PDB.LC" target="_blank">PDB.LC</a>);<br>
>          PD.getActivePath().push_front(p);<br>
>          updateStackPiecesWithMessage(p, CallStack);<br>
> @@ -2547,7 +2534,7 @@ void BuiltinBug::anchor() {}<br>
><br>
>  void BugReport::NodeResolver::anchor() {}<br>
><br>
> -void BugReport::addVisitor(BugReporterVisitor* visitor) {<br>
> +void BugReport::addVisitor(std::unique_ptr<BugReporterVisitor> visitor) {<br>
>    if (!visitor)<br>
>      return;<br>
><br>
> @@ -2555,20 +2542,15 @@ void BugReport::addVisitor(BugReporterVi<br>
>    visitor->Profile(ID);<br>
>    void *InsertPos;<br>
><br>
> -  if (CallbacksSet.FindNodeOrInsertPos(ID, InsertPos)) {<br>
> -    delete visitor;<br>
> +  if (CallbacksSet.FindNodeOrInsertPos(ID, InsertPos))<br>
>      return;<br>
> -  }<br>
><br>
> -  CallbacksSet.InsertNode(visitor, InsertPos);<br>
> -  Callbacks.push_back(visitor);<br>
> +  CallbacksSet.InsertNode(visitor.get(), InsertPos);<br>
> +  Callbacks.push_back(std::move(visitor));<br>
>    ++ConfigurationChangeToken;<br>
>  }<br>
><br>
>  BugReport::~BugReport() {<br>
> -  for (visitor_iterator I = visitor_begin(), E = visitor_end(); I != E; ++I) {<br>
> -    delete *I;<br>
> -  }<br>
>    while (!interestingSymbols.empty()) {<br>
>      popInterestingSymbolsAndRegions();<br>
>    }<br>
> @@ -3126,9 +3108,9 @@ bool GRBugReporter::generatePathDiagnost<br>
>      const ExplodedNode *N = ErrorGraph.ErrorNode;<br>
><br>
>      // Register additional node visitors.<br>
> -    R->addVisitor(new NilReceiverBRVisitor());<br>
> -    R->addVisitor(new ConditionBRVisitor());<br>
> -    R->addVisitor(new LikelyFalsePositiveSuppressionBRVisitor());<br>
> +    R->addVisitor(llvm::make_unique<NilReceiverBRVisitor>());<br>
> +    R->addVisitor(llvm::make_unique<ConditionBRVisitor>());<br>
> +    R->addVisitor(llvm::make_unique<LikelyFalsePositiveSuppressionBRVisitor>());<br>
><br>
>      BugReport::VisitorList visitors;<br>
>      unsigned origReportConfigToken, finalReportConfigToken;<br>
> @@ -3188,7 +3170,7 @@ bool GRBugReporter::generatePathDiagnost<br>
>        }<br>
><br>
>        // Clean up the visitors we used.<br>
> -      llvm::DeleteContainerPointers(visitors);<br>
> +      visitors.clear();<br>
><br>
>        // Did anything change while generating this path?<br>
>        finalReportConfigToken = R->getConfigurationChangeToken();<br>
><br>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=217205&r1=217204&r2=217205&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=217205&r1=217204&r2=217205&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)<br>
> +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Thu Sep  4 18:54:33 2014<br>
> @@ -218,7 +218,8 @@ public:<br>
>          EnableNullFPSuppression = State->isNull(*RetLoc).isConstrainedTrue();<br>
><br>
>      BR.markInteresting(CalleeContext);<br>
> -    BR.addVisitor(new ReturnVisitor(CalleeContext, EnableNullFPSuppression));<br>
> +    BR.addVisitor(llvm::make_unique<ReturnVisitor>(CalleeContext,<br>
> +                                                   EnableNullFPSuppression));<br>
>    }<br>
><br>
>    /// Returns true if any counter-suppression heuristics are enabled for<br>
> @@ -565,8 +566,8 @@ PathDiagnosticPiece *FindLastStoreBRVisi<br>
>            if (const VarRegion *OriginalR = BDR->getOriginalRegion(VR)) {<br>
>              if (Optional<KnownSVal> KV =<br>
>                  State->getSVal(OriginalR).getAs<KnownSVal>())<br>
> -              BR.addVisitor(new FindLastStoreBRVisitor(*KV, OriginalR,<br>
> -                                                      EnableNullFPSuppression));<br>
> +              BR.addVisitor(llvm::make_unique<FindLastStoreBRVisitor>(<br>
> +                  *KV, OriginalR, EnableNullFPSuppression));<br>
>            }<br>
>          }<br>
>        }<br>
> @@ -975,8 +976,8 @@ bool bugreporter::trackNullOrUndefValue(<br>
>        // got initialized.<br>
>        if (const MemRegion *RR = getLocationRegionIfReference(Inner, N)) {<br>
>          if (Optional<KnownSVal> KV = LVal.getAs<KnownSVal>())<br>
> -          report.addVisitor(new FindLastStoreBRVisitor(*KV, RR,<br>
> -                                                      EnableNullFPSuppression));<br>
> +          report.addVisitor(llvm::make_unique<FindLastStoreBRVisitor>(<br>
> +              *KV, RR, EnableNullFPSuppression));<br>
>        }<br>
>      }<br>
><br>
> @@ -986,30 +987,26 @@ bool bugreporter::trackNullOrUndefValue(<br>
><br>
>        report.markInteresting(R);<br>
>        report.markInteresting(V);<br>
> -      report.addVisitor(new UndefOrNullArgVisitor(R));<br>
> +      report.addVisitor(llvm::make_unique<UndefOrNullArgVisitor>(R));<br>
><br>
>        // If the contents are symbolic, find out when they became null.<br>
> -      if (V.getAsLocSymbol(/*IncludeBaseRegions*/ true)) {<br>
> -        BugReporterVisitor *ConstraintTracker =<br>
> -          new TrackConstraintBRVisitor(V.castAs<DefinedSVal>(), false);<br>
> -        report.addVisitor(ConstraintTracker);<br>
> -      }<br>
> +      if (V.getAsLocSymbol(/*IncludeBaseRegions*/ true))<br>
> +        report.addVisitor(llvm::make_unique<TrackConstraintBRVisitor>(<br>
> +            V.castAs<DefinedSVal>(), false));<br>
><br>
>        // Add visitor, which will suppress inline defensive checks.<br>
>        if (Optional<DefinedSVal> DV = V.getAs<DefinedSVal>()) {<br>
> -        if (!DV->isZeroConstant() &&<br>
> -          LVState->isNull(*DV).isConstrainedTrue() &&<br>
> -          EnableNullFPSuppression) {<br>
> -          BugReporterVisitor *IDCSuppressor =<br>
> -            new SuppressInlineDefensiveChecksVisitor(*DV,<br>
> -                                                     LVNode);<br>
> -          report.addVisitor(IDCSuppressor);<br>
> +        if (!DV->isZeroConstant() && LVState->isNull(*DV).isConstrainedTrue() &&<br>
> +            EnableNullFPSuppression) {<br>
> +          report.addVisitor(<br>
> +              llvm::make_unique<SuppressInlineDefensiveChecksVisitor>(*DV,<br>
> +                                                                      LVNode));<br>
>          }<br>
>        }<br>
><br>
>        if (Optional<KnownSVal> KV = V.getAs<KnownSVal>())<br>
> -        report.addVisitor(new FindLastStoreBRVisitor(*KV, R,<br>
> -                                                     EnableNullFPSuppression));<br>
> +        report.addVisitor(llvm::make_unique<FindLastStoreBRVisitor>(<br>
> +            *KV, R, EnableNullFPSuppression));<br>
>        return true;<br>
>      }<br>
>    }<br>
> @@ -1040,12 +1037,12 @@ bool bugreporter::trackNullOrUndefValue(<br>
>        RVal = state->getSVal(L->getRegion());<br>
><br>
>      const MemRegion *RegionRVal = RVal.getAsRegion();<br>
> -    report.addVisitor(new UndefOrNullArgVisitor(L->getRegion()));<br>
> +    report.addVisitor(llvm::make_unique<UndefOrNullArgVisitor>(L->getRegion()));<br>
><br>
>      if (RegionRVal && isa<SymbolicRegion>(RegionRVal)) {<br>
>        report.markInteresting(RegionRVal);<br>
> -      report.addVisitor(new TrackConstraintBRVisitor(<br>
> -        loc::MemRegionVal(RegionRVal), false));<br>
> +      report.addVisitor(llvm::make_unique<TrackConstraintBRVisitor>(<br>
> +          loc::MemRegionVal(RegionRVal), false));<br>
>      }<br>
>    }<br>
><br>
> @@ -1128,8 +1125,8 @@ void FindLastStoreBRVisitor::registerSta<br>
><br>
>          if (V.getAs<loc::ConcreteInt>() || V.getAs<nonloc::ConcreteInt>()) {<br>
>            // Register a new visitor with the BugReport.<br>
> -          BR.addVisitor(new FindLastStoreBRVisitor(V.castAs<KnownSVal>(), R,<br>
> -                                                   EnableNullFPSuppression));<br>
> +          BR.addVisitor(llvm::make_unique<FindLastStoreBRVisitor>(<br>
> +              V.castAs<KnownSVal>(), R, EnableNullFPSuppression));<br>
>          }<br>
>        }<br>
>      }<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>