[PATCH] D25426: [Analysis] Use unique_ptr in AnalyaisDeclContextManager's ContextMap.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 9 22:26:05 PDT 2016


jlebar created this revision.
jlebar added a reviewer: timshen.
jlebar added a subscriber: cfe-commits.

https://reviews.llvm.org/D25426

Files:
  clang/include/clang/Analysis/AnalysisContext.h
  clang/lib/Analysis/AnalysisDeclContext.cpp


Index: clang/lib/Analysis/AnalysisDeclContext.cpp
===================================================================
--- clang/lib/Analysis/AnalysisDeclContext.cpp
+++ clang/lib/Analysis/AnalysisDeclContext.cpp
@@ -81,9 +81,7 @@
   cfgBuildOptions.AddCXXNewAllocator = addCXXNewAllocator;
 }
 
-void AnalysisDeclContextManager::clear() {
-  llvm::DeleteContainerSeconds(Contexts);
-}
+void AnalysisDeclContextManager::clear() { Contexts.clear(); }
 
 static BodyFarm &getBodyFarm(ASTContext &C, CodeInjector *injector = nullptr) {
   static BodyFarm *BF = new BodyFarm(C, injector);
@@ -307,10 +305,10 @@
     D = FD;
   }
 
-  AnalysisDeclContext *&AC = Contexts[D];
+  std::unique_ptr<AnalysisDeclContext> &AC = Contexts[D];
   if (!AC)
-    AC = new AnalysisDeclContext(this, D, cfgBuildOptions);
-  return AC;
+    AC = llvm::make_unique<AnalysisDeclContext>(this, D, cfgBuildOptions);
+  return AC.get();
 }
 
 const StackFrameContext *
@@ -606,9 +604,7 @@
   }
 }
 
-AnalysisDeclContextManager::~AnalysisDeclContextManager() {
-  llvm::DeleteContainerSeconds(Contexts);
-}
+AnalysisDeclContextManager::~AnalysisDeclContextManager() {}
 
 LocationContext::~LocationContext() {}
 
Index: clang/include/clang/Analysis/AnalysisContext.h
===================================================================
--- clang/include/clang/Analysis/AnalysisContext.h
+++ clang/include/clang/Analysis/AnalysisContext.h
@@ -406,7 +406,8 @@
 };
 
 class AnalysisDeclContextManager {
-  typedef llvm::DenseMap<const Decl*, AnalysisDeclContext*> ContextMap;
+  typedef llvm::DenseMap<const Decl *, std::unique_ptr<AnalysisDeclContext>>
+      ContextMap;
 
   ContextMap Contexts;
   LocationContextManager LocContexts;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25426.74104.patch
Type: text/x-patch
Size: 1707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161010/0e84e41b/attachment.bin>


More information about the cfe-commits mailing list