From f992790cdc215ada87dde7680698a7a25430d1d7 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 4 Apr 2014 23:16:44 +0000 Subject: [PATCH] DebugInfo: Place global constants in their appropriate context. We also don't need to duplicate the name in the LinkageName field. Just leave it empty. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205655 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 5 ++++- test/CodeGenCXX/debug-info.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 41f1ddb697..eed2f3c615 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -3230,8 +3230,11 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, // Do not emit separate definitions for function local const/statics. if (isa(VD->getDeclContext())) return; + llvm::DIDescriptor DContext = + getContextDescriptor(dyn_cast(VD->getDeclContext())); llvm::DIGlobalVariable GV = DBuilder.createStaticVariable( - Unit, Name, Name, Unit, getLineNumber(VD->getLocation()), Ty, true, Init, + DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty, + true, Init, getOrCreateStaticDataMemberDeclarationOrNull(cast(VD))); DeclCache.insert(std::make_pair(VD->getCanonicalDecl(), llvm::WeakVH(GV))); } diff --git a/test/CodeGenCXX/debug-info.cpp b/test/CodeGenCXX/debug-info.cpp index 7c89dfc04c..26d647aa35 100644 --- a/test/CodeGenCXX/debug-info.cpp +++ b/test/CodeGenCXX/debug-info.cpp @@ -83,9 +83,16 @@ foo func(foo f) { // CHECK: [[FUNC:![0-9]*]] = {{.*}} metadata !"_ZN7pr147634funcENS_3fooE", i32 {{[0-9]*}}, metadata [[FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func] } +namespace local_const { +const wchar_t lc_c = L'x'; +} + +// CHECK: metadata [[LOCAL_CONST:![0-9]*]], metadata !"lc_c", {{.*}}; [ DW_TAG_variable ] [lc_c] +// CHECK: [[LOCAL_CONST]] = {{.*}}; [ DW_TAG_namespace ] [local_const] + void foo() { const wchar_t c = L'x'; - wchar_t d = c; + wchar_t d = c + local_const::lc_c; } // CHECK-NOT: ; [ DW_TAG_variable ] [c] -- 2.40.0