From: Adrian Prantl Date: Tue, 29 Sep 2015 20:44:46 +0000 (+0000) Subject: CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81c359b957e2c7c097a9c8aeb957c878b67acf2a;p=clang CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may be modified in between. (NFC) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248826 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index c2cc49a0c5..443c45cc64 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1680,9 +1680,9 @@ CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod, // nullptr if the "Module" is a PCH, which is safe because we don't // support chained PCH debug info, so there can only be a single PCH. const Module *M = Mod.getModuleOrNull(); - auto &ModRef = ModuleCache[M]; - if (ModRef) - return cast(ModRef); + auto ModRef = ModuleCache.find(M); + if (ModRef != ModuleCache.end()) + return cast(ModRef->second); // Macro definitions that were defined with "-D" on the command line. SmallString<128> ConfigMacros; @@ -1724,7 +1724,7 @@ CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod, llvm::DIModule *DIMod = DBuilder.createModule(Parent, Mod.getModuleName(), ConfigMacros, Mod.getPath(), CGM.getHeaderSearchOpts().Sysroot); - ModRef.reset(DIMod); + ModuleCache[M].reset(DIMod); return DIMod; }