summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2016-11-08 22:11:38 +0000
committerAdrian Prantl <aprantl@apple.com>2016-11-08 22:11:38 +0000
commit3502f2089c216ece680eab79a90d90fe9109e1f1 (patch)
treeff03feb6d0334d76ea2c83a336f0183f596f99ce /llvm/lib
parent0fc15ab5b5905119c4ba3da897464a3f32efb3e6 (diff)
downloadbcm5719-llvm-3502f2089c216ece680eab79a90d90fe9109e1f1.tar.gz
bcm5719-llvm-3502f2089c216ece680eab79a90d90fe9109e1f1.zip
Emit the DW_AT_type for a C++ static member definition
if it is more specific than the one in its DW_AT_specification. If a static member is an array, the translation unit containing the member definition may have a more specific type (including its length) than TUs only seeing the class declaration. This patch adds a DW_AT_type to the member's DW_TAG_variable in addition to the DW_AT_specification in these cases. The member type in the DW_AT_specification still shows the more generic type (without the length) to avoid defeating type uniquing. The DWARF standard discourages “duplicating” a DW_AT_type in a member variable definition but doesn’t explicitly forbid it. Having the more specific type (with the array length) available is what allows the debugger to print the contents of a static array member variable. https://reviews.llvm.org/D26368 rdar://problem/28706946 llvm-svn: 286302
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 8b5df7c7aef..1aabf69cb1a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -99,6 +99,10 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
// We need the declaration DIE that is in the static member's class.
DIE *VariableSpecDIE = getOrCreateStaticMemberDIE(SDMDecl);
addDIEEntry(*VariableDIE, dwarf::DW_AT_specification, *VariableSpecDIE);
+ // If the global variable's type is different from the one in the class
+ // member type, assume that it's more specific and also emit it.
+ if (GTy != DD->resolve(SDMDecl->getBaseType()))
+ addType(*VariableDIE, GTy);
} else {
DeclContext = GV->getScope();
// Add name and type.
OpenPOWER on IntegriCloud