[PATCH] D13959: Fix crash in EmitDeclMetadata mode

Keno Fischer via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 21 14:31:42 PDT 2015

loladiro created this revision.
loladiro added reviewers: rjmccall, labath.
loladiro added a subscriber: cfe-commits.
loladiro set the repository for this revision to rL LLVM.

This fixes a bug that's easily encountered in LLDB (https://llvm.org/bugs/show_bug.cgi?id=22875). The problem here is that we mangle a name during debug info emission, but never actually emit the actual Decl, so we run into problems here. I am not entirely sure this is the right fix. The comment says something about StaticLocalDeclMap, which may be better here, but I checked and that already existed when this functionality was added, which makes me think that there is some reason it wasn't used.




Index: lib/CodeGen/CodeGenModule.cpp
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3710,7 +3710,10 @@
   // StaticLocalDeclMap
   for (auto &I : MangledDeclNames) {
     llvm::GlobalValue *Addr = getModule().getNamedValue(I.second);
-    EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);
+    // Some mangled names don't necessarily have an associated GlobalValue
+    // in this module, e.g. if we mangled it for DebugInfo.
+    if (Addr)
+      EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13959.38049.patch
Type: text/x-patch
Size: 625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151021/f5c5be8c/attachment-0001.bin>

More information about the cfe-commits mailing list