<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 29, 2015 at 1:44 PM, Adrian Prantl via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Tue Sep 29 15:44:46 2015<br>
New Revision: 248826<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=248826&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=248826&view=rev</a><br>
Log:<br>
CGDebugInfo: Don't reuse a reference into a DenseMap if the DenseMap may<br>
be modified in between. (NFC)<br>
<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248826&r1=248825&r2=248826&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248826&r1=248825&r2=248826&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Sep 29 15:44:46 2015<br>
@@ -1680,9 +1680,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern<br>
   // nullptr if the "Module" is a PCH, which is safe because we don't<br>
   // support chained PCH debug info, so there can only be a single PCH.<br>
   const Module *M = Mod.getModuleOrNull();<br>
-  auto &ModRef = ModuleCache[M];<br>
-  if (ModRef)<br>
-    return cast<llvm::DIModule>(ModRef);<br>
+  auto ModRef = ModuleCache.find(M);<br>
+  if (ModRef != ModuleCache.end())<br>
+    return cast<llvm::DIModule>(ModRef->second);<br></blockquote><div><br></div><div>Maybe change this to:<br><br>if (const auto *Mod = ModuleCache[M])<br>  return cast<llvm::DIModule>(Mod);<br><br>Or similar, to reduce variable scope, since "ModRef" isn't needed/used after this block.<br><br>It does cause the entry to be created earlier, but that shouldn't make a difference in any real sense - but I could see a preference either way, if you prefer it the way it is, that'd be cool too.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
   // Macro definitions that were defined with "-D" on the command line.<br>
   SmallString<128> ConfigMacros;<br>
@@ -1724,7 +1724,7 @@ CGDebugInfo::getOrCreateModuleRef(Extern<br>
   llvm::DIModule *DIMod =<br>
       DBuilder.createModule(Parent, Mod.getModuleName(), ConfigMacros,<br>
                             Mod.getPath(), CGM.getHeaderSearchOpts().Sysroot);<br>
-  ModRef.reset(DIMod);<br>
+  ModuleCache[M].reset(DIMod);<br>
   return DIMod;<br>
 }<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>