]> granicus.if.org Git - clang/commitdiff
Fix context in class static variable's debugging information entry.
authorDevang Patel <dpatel@apple.com>
Thu, 13 May 2010 23:52:37 +0000 (23:52 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 13 May 2010 23:52:37 +0000 (23:52 +0000)
This fixes bunch of failures in gdb testsuite.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103745 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp

index 30764875396cb5f3898ef4995a6a9374e6e68eb9..019779bd05e236fd854b77b8cd20b091b80b99aa 100644 (file)
@@ -64,7 +64,14 @@ llvm::DIDescriptor CGDebugInfo::getContextDescriptor(const Decl *Context,
   // Check namespace.
   if (const NamespaceDecl *NSDecl = dyn_cast<NamespaceDecl>(Context))
     return llvm::DIDescriptor(getOrCreateNameSpace(NSDecl, CompileUnit));
-  
+
+  if (const RecordDecl *RDecl = dyn_cast<RecordDecl>(Context)) {
+    if (!RDecl->isDependentType()) {
+      llvm::DIType Ty = getOrCreateType(CGM.getContext().getTypeDeclType(RDecl), 
+                                        llvm::DIFile(CompileUnit));
+      return llvm::DIDescriptor(Ty);
+    }
+  }
   return CompileUnit;
 }
 
@@ -1567,11 +1574,13 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
                                            ArrayType::Normal, 0);
   }
   llvm::StringRef DeclName = D->getName();
+  llvm::StringRef LinkageName;
+  if (D->getDeclContext() && isa<FunctionDecl>(D->getDeclContext()))
+    LinkageName = Var->getName();
   llvm::DIDescriptor DContext = 
     getContextDescriptor(dyn_cast<Decl>(D->getDeclContext()), Unit);
-  DebugFactory.CreateGlobalVariable(DContext, DeclName,
-                                    DeclName, llvm::StringRef(), Unit, LineNo,
-                                    getOrCreateType(T, Unit),
+  DebugFactory.CreateGlobalVariable(DContext, DeclName, DeclName, LinkageName,
+                                    Unit, LineNo, getOrCreateType(T, Unit),
                                     Var->hasInternalLinkage(),
                                     true/*definition*/, Var);
 }