<div dir="ltr">Any chance of a test case here?<br><br>(I don't know much about this code, but I am a bit confused about why we'd ever need to visit a list of mangled names & look them up... )</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 5, 2015 at 3:18 PM, Keno Fischer 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: kfischer<br>
Date: Thu Nov 5 17:18:44 2015<br>
New Revision: 252229<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=252229&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=252229&view=rev</a><br>
Log:<br>
Fix crash in EmitDeclMetadata mode<br>
<br>
Summary: This fixes a bug that's easily encountered in LLDB<br>
(<a href="https://llvm.org/bugs/show_bug.cgi?id=22875" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_bug.cgi?id=22875</a>). The problem here is that we<br>
mangle a name during debug info emission, but never actually emit the actual<br>
Decl, so we run into problems in EmitDeclMetadata (which assumes such a Decl<br>
exists). Fix that by just skipping metadata emissions for mangled names that<br>
don't have associated Decls.<br>
<br>
Reviewers: rjmccall<br>
<br>
Subscribers: labath, cfe-commits<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D13959" rel="noreferrer" target="_blank">http://reviews.llvm.org/D13959</a><br>
<br>
Modified:<br>
cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=252229&r1=252228&r2=252229&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=252229&r1=252228&r2=252229&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Nov 5 17:18:44 2015<br>
@@ -3707,10 +3707,12 @@ bool CodeGenModule::lookupRepresentative<br>
void CodeGenModule::EmitDeclMetadata() {<br>
llvm::NamedMDNode *GlobalMetadata = nullptr;<br>
<br>
- // StaticLocalDeclMap<br>
for (auto &I : MangledDeclNames) {<br>
llvm::GlobalValue *Addr = getModule().getNamedValue(I.second);<br>
- EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);<br>
+ // Some mangled names don't necessarily have an associated GlobalValue<br>
+ // in this module, e.g. if we mangled it for DebugInfo.<br>
+ if (Addr)<br>
+ EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);<br>
}<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>