]> granicus.if.org Git - clang/commitdiff
Fix crash generating debug info for constructor for anonymous struct.
authorEli Friedman <eli.friedman@gmail.com>
Sat, 16 Jan 2010 00:43:13 +0000 (00:43 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sat, 16 Jan 2010 00:43:13 +0000 (00:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93601 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGenCXX/debug-info.cpp

index ab8f6637d6cea875ecf52af46427ea76debbe5f6..cc97d19a5a0ff06025d14ad311a69abcdd41db32 100644 (file)
@@ -1001,7 +1001,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType,
   const Decl *D = GD.getDecl();
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
     Name = getFunctionName(FD);
-    if (Name[0] == '\01')
+    if (!Name.empty() && Name[0] == '\01')
       Name = Name.substr(1);
     // Use mangled name as linkage name for c/c++ functions.
     LinkageName = CGM.getMangledName(GD);
index 705491e3a9b4ed431cb58d0725b32d120a23dc56..cb6e830a49e0e10e3195d12eb594403ec5307bcf 100644 (file)
@@ -18,3 +18,9 @@ void f() {
   int B::*a = 0;
   void (B::*b)() = 0;
 }
+
+namespace EmptyNameCrash {
+  struct A { A(); };
+  typedef struct { A x; } B;
+  B x;
+}