Could this be a value rather than indirected through a unique_ptr? Simply: BodyFarm BdyFrm;
& initialized in the ctors init list? On Tue, Oct 24, 2017 at 4:53 PM George Karpenkov via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: george.karpenkov > Date: Tue Oct 24 16:53:19 2017 > New Revision: 316536 > > URL: http://llvm.org/viewvc/llvm-project?rev=316536&view=rev > Log: > [Analyzer] Store BodyFarm in std::unique_ptr > > Differential Revision: https://reviews.llvm.org/D39220 > > Modified: > cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h > cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp > > Modified: cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h?rev=316536&r1=316535&r2=316536&view=diff > > ============================================================================== > --- cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h (original) > +++ cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h Tue Oct 24 > 16:53:19 2017 > @@ -421,7 +421,7 @@ class AnalysisDeclContextManager { > > /// Pointer to a factory for creating and caching implementations for > common > /// methods during the analysis. > - BodyFarm *BdyFrm = nullptr; > + std::unique_ptr<BodyFarm> BdyFrm; > > /// Flag to indicate whether or not bodies should be synthesized > /// for well-known functions. > @@ -438,8 +438,6 @@ public: > bool addCXXNewAllocator = true, > CodeInjector *injector = nullptr); > > - ~AnalysisDeclContextManager(); > - > AnalysisDeclContext *getContext(const Decl *D); > > bool getUseUnoptimizedCFG() const { > > Modified: cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp?rev=316536&r1=316535&r2=316536&view=diff > > ============================================================================== > --- cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp (original) > +++ cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp Tue Oct 24 16:53:19 2017 > @@ -306,8 +306,8 @@ AnalysisDeclContext *AnalysisDeclContext > > BodyFarm *AnalysisDeclContextManager::getBodyFarm() { > if (!BdyFrm) > - BdyFrm = new BodyFarm(ASTCtx, Injector.get()); > - return BdyFrm; > + BdyFrm = llvm::make_unique<BodyFarm>(ASTCtx, Injector.get()); > + return BdyFrm.get(); > } > > const StackFrameContext * > @@ -603,11 +603,6 @@ AnalysisDeclContext::~AnalysisDeclContex > } > } > > -AnalysisDeclContextManager::~AnalysisDeclContextManager() { > - if (BdyFrm) > - delete BdyFrm; > -} > - > LocationContext::~LocationContext() {} > > LocationContextManager::~LocationContextManager() { > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits