From: Devang Patel Date: Thu, 13 May 2010 23:52:37 +0000 (+0000) Subject: Fix context in class static variable's debugging information entry. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b90a7804b15b0d203650df123fb236b86da8cc0;p=clang Fix context in class static variable's debugging information entry. 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 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 3076487539..019779bd05 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -64,7 +64,14 @@ llvm::DIDescriptor CGDebugInfo::getContextDescriptor(const Decl *Context, // Check namespace. if (const NamespaceDecl *NSDecl = dyn_cast(Context)) return llvm::DIDescriptor(getOrCreateNameSpace(NSDecl, CompileUnit)); - + + if (const RecordDecl *RDecl = dyn_cast(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(D->getDeclContext())) + LinkageName = Var->getName(); llvm::DIDescriptor DContext = getContextDescriptor(dyn_cast(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); }