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.

Repository:
  rL LLVM

http://reviews.llvm.org/D13959

Files:
  lib/CodeGen/CodeGenModule.cpp

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);
   }
 }
 


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);
   }
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to