forked from OSchip/llvm-project
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. llvm-svn: 205655
This commit is contained in:
parent
e36fbea175
commit
2f2df07fa4
|
@ -3230,8 +3230,11 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD,
|
|||
// Do not emit separate definitions for function local const/statics.
|
||||
if (isa<FunctionDecl>(VD->getDeclContext()))
|
||||
return;
|
||||
llvm::DIDescriptor DContext =
|
||||
getContextDescriptor(dyn_cast<Decl>(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<VarDecl>(VD)));
|
||||
DeclCache.insert(std::make_pair(VD->getCanonicalDecl(), llvm::WeakVH(GV)));
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue