DebugInfo: Flag type unit references as declarations
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 31 Jan 2014 19:52:26 +0000 (19:52 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 31 Jan 2014 19:52:26 +0000 (19:52 +0000)
This ensures DWARF consumers don't confuse these references for
definitions. I'd argue it might be nice to improve debuggers so we don't
need this, but it's just one field in an abbreviation anyway - so it
doesn't seem worth the fight.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200569 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
test/DebugInfo/X86/generate-odr-hash.ll

index e4188c39b074175645283c128d13b6c66f56ff6b..24beebbd35af98d806dc2b4b2dfc3e3b4318ccbf 100644 (file)
@@ -3016,6 +3016,11 @@ void DwarfDebug::emitDebugStrDWO() {
 void DwarfDebug::addDwarfTypeUnitType(DICompileUnit CUNode,
                                       StringRef Identifier, DIE *RefDie,
                                       DICompositeType CTy) {
+  // Flag the type unit reference as a declaration so that if it contains
+  // members (implicit special members, static data member definitions, member
+  // declarations for definitions in this CU, etc) consumers don't get confused
+  // and think this is a full definition.
+  CUMap.begin()->second->addFlag(RefDie, dwarf::DW_AT_declaration);
 
   const DwarfTypeUnit *&TU = DwarfTypeUnits[CTy];
   if (TU) {
index 2ccbc98d5e088cbc34848deee6a5591acdd21924..74c1699ef8b5dc9f12b4406a16afea04ea3e07b9 100644 (file)
 ; CHECK: Compile Unit: length = [[CU_SIZE:[0-9a-f]+]]
 
 ; CHECK: DW_TAG_structure_type
+; CHECK-NEXT: DW_AT_declaration
 ; CHECK-NEXT: DW_AT_signature
 ; CHECK: DW_TAG_class_type
+; CHECK-NEXT: DW_AT_declaration
 ; CHECK-NEXT: DW_AT_signature
 
 ; Ensure the CU-local type 'walrus' is not placed in a type unit.