summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-10-23 16:39:49 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-10-23 16:39:49 +0000
commit3813b2650f57043cb52654615bdd486d7027a558 (patch)
treeed0df058a5ce12860bc9908607a2a016b300f3ce /clang/lib/CodeGen
parentbcfa8a56b14261230338701369ed693e958475a0 (diff)
downloadbcm5719-llvm-3813b2650f57043cb52654615bdd486d7027a558.tar.gz
bcm5719-llvm-3813b2650f57043cb52654615bdd486d7027a558.zip
DebugInfo: Correctly describe the lexical decl context of static member variable definitions.
The previous IR representation used the non-lexical decl context, which placed the definitions in the same scope as the declarations (ie: within the class) - this was hidden by the fact that LLVM currently doesn't respect the context of global variable definitions at all, and always puts them at the top level (as direct children of the compile_unit). Having the correct lexical scope improves source fidelity and simplify backend global variable emission (with changes coming shortly). Doing something similar for non-member global variables would help simplify/cleanup things further (see FIXME in the commit) and provide similar source fidelity benefits to the final debug info. llvm-svn: 220488
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 0d662372a11..a5ad633233e 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3186,8 +3186,15 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
if (LinkageName == DeclName)
LinkageName = StringRef();
- llvm::DIDescriptor DContext =
- getContextDescriptor(dyn_cast<Decl>(D->getDeclContext()));
+ // Since we emit declarations (DW_AT_members) for static members, place the
+ // definition of those static members in the namespace they were declared in
+ // in the source code (the lexical decl context).
+ // FIXME: Generalize this for even non-member global variables where the
+ // declaration and definition may have different lexical decl contexts, once
+ // we have support for emitting declarations of (non-member) global variables.
+ llvm::DIDescriptor DContext = getContextDescriptor(
+ dyn_cast<Decl>(D->isStaticDataMember() ? D->getLexicalDeclContext()
+ : D->getDeclContext()));
// Attempt to store one global variable for the declaration - even if we
// emit a lot of fields.
OpenPOWER on IntegriCloud