From: Adrian Prantl Date: Fri, 11 Sep 2015 01:03:19 +0000 (+0000) Subject: Cleanup: Let CGDebugInfo::ModuleRefCache use a TrackingMDNode (NFC). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a2252c1af3ee6531efdb22dd9762b1dcbd1db86;p=clang Cleanup: Let CGDebugInfo::ModuleRefCache use a TrackingMDNode (NFC). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247368 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 83b5e01dee..693d0f6fdf 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -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(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, diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h index e635cb28f1..507496ba3a 100644 --- a/lib/CodeGen/CGDebugInfo.h +++ b/lib/CodeGen/CGDebugInfo.h @@ -84,7 +84,7 @@ class CGDebugInfo { llvm::SmallVector ObjCInterfaceCache; /// Cache of references to AST files such as PCHs or modules. - llvm::DenseMap ModuleRefCache; + llvm::DenseMap ModuleRefCache; /// List of interfaces we want to keep even if orphaned. std::vector RetainedTypes;