From: George Karpenkov Date: Tue, 24 Oct 2017 23:53:19 +0000 (+0000) Subject: [Analyzer] Store BodyFarm in std::unique_ptr X-Git-Tag: llvmorg-6.0.0-rc1~4959 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=506ecbb946e504bf8b181f9b6c961c9e44087643;p=platform%2Fupstream%2Fllvm.git [Analyzer] Store BodyFarm in std::unique_ptr Differential Revision: https://reviews.llvm.org/D39220 llvm-svn: 316536 --- diff --git a/clang/include/clang/Analysis/AnalysisDeclContext.h b/clang/include/clang/Analysis/AnalysisDeclContext.h index 1486071..c976281 100644 --- a/clang/include/clang/Analysis/AnalysisDeclContext.h +++ b/clang/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/clang/lib/Analysis/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp index 4408a0e..17749db 100644 --- a/clang/lib/Analysis/AnalysisDeclContext.cpp +++ b/clang/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() {