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