Index: include/clang/Analysis/AnalysisDeclContext.h =================================================================== --- include/clang/Analysis/AnalysisDeclContext.h +++ include/clang/Analysis/AnalysisDeclContext.h @@ -421,7 +421,7 @@ /// 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. Index: lib/Analysis/AnalysisDeclContext.cpp =================================================================== --- lib/Analysis/AnalysisDeclContext.cpp +++ lib/Analysis/AnalysisDeclContext.cpp @@ -306,8 +306,8 @@ 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,10 +603,7 @@ } } -AnalysisDeclContextManager::~AnalysisDeclContextManager() { - if (BdyFrm) - delete BdyFrm; -} +AnalysisDeclContextManager::~AnalysisDeclContextManager() {} LocationContext::~LocationContext() {}