From: George Karpenkov Date: Tue, 24 Oct 2017 23:53:19 +0000 (+0000) Subject: [Analyzer] Store BodyFarm in std::unique_ptr X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de45a2e1b73ff6509f99c707ee553a6319ed25c7;p=clang [Analyzer] Store BodyFarm in std::unique_ptr Differential Revision: https://reviews.llvm.org/D39220 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316536 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/AnalysisDeclContext.h b/include/clang/Analysis/AnalysisDeclContext.h index 1486071891..c9762818ad 100644 --- a/include/clang/Analysis/AnalysisDeclContext.h +++ b/include/clang/Analysis/AnalysisDeclContext.h @@ -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 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 { diff --git a/lib/Analysis/AnalysisDeclContext.cpp b/lib/Analysis/AnalysisDeclContext.cpp index 4408a0e0e4..17749db37c 100644 --- a/lib/Analysis/AnalysisDeclContext.cpp +++ b/lib/Analysis/AnalysisDeclContext.cpp @@ -306,8 +306,8 @@ AnalysisDeclContext *AnalysisDeclContextManager::getContext(const Decl *D) { BodyFarm *AnalysisDeclContextManager::getBodyFarm() { if (!BdyFrm) - BdyFrm = new BodyFarm(ASTCtx, Injector.get()); - return BdyFrm; + BdyFrm = llvm::make_unique(ASTCtx, Injector.get()); + return BdyFrm.get(); } const StackFrameContext * @@ -603,11 +603,6 @@ AnalysisDeclContext::~AnalysisDeclContext() { } } -AnalysisDeclContextManager::~AnalysisDeclContextManager() { - if (BdyFrm) - delete BdyFrm; -} - LocationContext::~LocationContext() {} LocationContextManager::~LocationContextManager() {