From 506ecbb946e504bf8b181f9b6c961c9e44087643 Mon Sep 17 00:00:00 2001 From: George Karpenkov Date: Tue, 24 Oct 2017 23:53:19 +0000 Subject: [PATCH] [Analyzer] Store BodyFarm in std::unique_ptr Differential Revision: https://reviews.llvm.org/D39220 llvm-svn: 316536 --- clang/include/clang/Analysis/AnalysisDeclContext.h | 4 +--- clang/lib/Analysis/AnalysisDeclContext.cpp | 9 ++------- 2 files changed, 3 insertions(+), 10 deletions(-) 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() { -- 2.7.4