]> granicus.if.org Git - clang/commitdiff
Cleanup: Let CGDebugInfo::ModuleRefCache use a TrackingMDNode (NFC).
authorAdrian Prantl <aprantl@apple.com>
Fri, 11 Sep 2015 01:03:19 +0000 (01:03 +0000)
committerAdrian Prantl <aprantl@apple.com>
Fri, 11 Sep 2015 01:03:19 +0000 (01:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247368 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDebugInfo.h

index 83b5e01deefcafa17b3cd4cd6b4edc8486d513f1..693d0f6fdfcd24cb8121dc6f4641996e3916d3db 100644 (file)
@@ -1638,9 +1638,9 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
 
 llvm::DIModule *
 CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod) {
-  auto it = ModuleRefCache.find(Mod.Signature);
-  if (it != ModuleRefCache.end())
-    return it->second;
+  auto &ModRef = ModuleRefCache[Mod.Signature];
+  if (ModRef)
+    return cast<llvm::DIModule>(ModRef);
 
   // Macro definitions that were defined with "-D" on the command line.
   SmallString<128> ConfigMacros;
@@ -1669,12 +1669,12 @@ CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod) {
       TheCU->getSourceLanguage(), internString(Mod.ModuleName),
       internString(Mod.Path), TheCU->getProducer(), true, StringRef(), 0,
       internString(Mod.ASTFile), llvm::DIBuilder::FullDebug, Mod.Signature);
-  llvm::DIModule *ModuleRef =
+  llvm::DIModule *M =
       DIB.createModule(CU, Mod.ModuleName, ConfigMacros, internString(Mod.Path),
                        internString(CGM.getHeaderSearchOpts().Sysroot));
   DIB.finalize();
-  ModuleRefCache.insert(std::make_pair(Mod.Signature, ModuleRef));
-  return ModuleRef;
+  ModRef.reset(M);
+  return M;
 }
 
 llvm::DIType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty,
index e635cb28f1b6db35b17652232c4c8fe3e75c858b..507496ba3a5f69d305c6f332ecafb8b643576859 100644 (file)
@@ -84,7 +84,7 @@ class CGDebugInfo {
   llvm::SmallVector<ObjCInterfaceCacheEntry, 32> ObjCInterfaceCache;
 
   /// Cache of references to AST files such as PCHs or modules.
-  llvm::DenseMap<uint64_t, llvm::DIModule *> ModuleRefCache;
+  llvm::DenseMap<uint64_t, llvm::TrackingMDRef> ModuleRefCache;
 
   /// List of interfaces we want to keep even if orphaned.
   std::vector<void *> RetainedTypes;