]> granicus.if.org Git - clang/commitdiff
CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may
authorAdrian Prantl <aprantl@apple.com>
Tue, 29 Sep 2015 20:44:46 +0000 (20:44 +0000)
committerAdrian Prantl <aprantl@apple.com>
Tue, 29 Sep 2015 20:44:46 +0000 (20:44 +0000)
be modified in between. (NFC)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248826 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp

index c2cc49a0c5edd300995115b616f8c6e20d71d595..443c45cc64a1e81d93f7284a76b67b14af494e14 100644 (file)
@@ -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<llvm::DIModule>(ModRef);
+  auto ModRef = ModuleCache.find(M);
+  if (ModRef != ModuleCache.end())
+    return cast<llvm::DIModule>(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;
 }