From: Adrian Prantl Date: Wed, 23 Sep 2015 20:44:37 +0000 (+0000) Subject: dsymutil: Don't prune forward declarations inside a module definition. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=54a3f636d86a21c8cc08bff63e2735d7e9ac3e2a;p=oota-llvm.git dsymutil: Don't prune forward declarations inside a module definition. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248428 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/tools/dsymutil/Inputs/modules/1.o b/test/tools/dsymutil/Inputs/modules/1.o index 254ae692a8e..e7a52931b9f 100644 Binary files a/test/tools/dsymutil/Inputs/modules/1.o and b/test/tools/dsymutil/Inputs/modules/1.o differ diff --git a/test/tools/dsymutil/Inputs/modules/Bar.pcm b/test/tools/dsymutil/Inputs/modules/Bar.pcm index 8d3a534667c..bd77ec55826 100644 Binary files a/test/tools/dsymutil/Inputs/modules/Bar.pcm and b/test/tools/dsymutil/Inputs/modules/Bar.pcm differ diff --git a/test/tools/dsymutil/Inputs/modules/Foo.pcm b/test/tools/dsymutil/Inputs/modules/Foo.pcm index 33bca2a6547..a715bfaa7f2 100644 Binary files a/test/tools/dsymutil/Inputs/modules/Foo.pcm and b/test/tools/dsymutil/Inputs/modules/Foo.pcm differ diff --git a/test/tools/dsymutil/X86/modules.m b/test/tools/dsymutil/X86/modules.m index 0e82c999d78..63d628baa5a 100644 --- a/test/tools/dsymutil/X86/modules.m +++ b/test/tools/dsymutil/X86/modules.m @@ -9,8 +9,8 @@ export * } EOF - clang -D BAR_H -E -o Bar.h - clang -D FOO_H -E -o Foo.h + clang -D BAR_H -E -o Bar.h modules.m + clang -D FOO_H -E -o Foo.h modules.m clang -cc1 -emit-obj -fmodules -fmodule-map-file=modules.modulemap \ -fmodule-format=obj -g -dwarf-ext-refs -fmodules-cache-path=. \ -fdisable-module-hash modules.m -o 1.o @@ -32,17 +32,22 @@ // CHECK-NOT: DW_TAG // CHECK: DW_TAG_module // CHECK-NEXT: DW_AT_name{{.*}}"Bar" -// CHECK-NOT: DW_TAG // CHECK: 0x0[[BAR:.*]]: DW_TAG_structure_type +// CHECK-NOT: DW_TAG // CHECK: DW_AT_name {{.*}}"Bar" // CHECK-NOT: DW_TAG // CHECK: DW_TAG_member // CHECK: DW_AT_name {{.*}}"value" +// CHECK: DW_TAG_structure_type +// CHECK-NOT: DW_TAG +// CHECK: DW_AT_name {{.*}}"PruneMeNot" struct Bar { int value; }; +struct PruneMeNot; + #else // --------------------------------------------------------------------- #ifdef FOO_H diff --git a/tools/dsymutil/DwarfLinker.cpp b/tools/dsymutil/DwarfLinker.cpp index 818746dabeb..1aa15c5fb67 100644 --- a/tools/dsymutil/DwarfLinker.cpp +++ b/tools/dsymutil/DwarfLinker.cpp @@ -1764,7 +1764,7 @@ static bool analyzeContextInfo(const DWARFDebugInfoEntryMinimal *DIE, DeclContext *CurrentDeclContext, NonRelocatableStringpool &StringPool, DeclContextTree &Contexts, - bool InTagModule = false) { + bool InImportedModule = false) { unsigned MyIdx = CU.getOrigUnit().getDIEIndex(DIE); CompileUnit::DIEInfo &Info = CU.getInfo(MyIdx); @@ -1780,11 +1780,14 @@ static bool analyzeContextInfo(const DWARFDebugInfoEntryMinimal *DIE, // definitions match)." // // We treat non-C++ modules like namespaces for this reason. - if (DIE->getTag() == dwarf::DW_TAG_module) - InTagModule = true; + if (DIE->getTag() == dwarf::DW_TAG_module && + DIE->getAttributeValueAsString(&CU.getOrigUnit(), dwarf::DW_AT_name, + "") != CU.getClangModuleName()) { + InImportedModule = true; + } Info.ParentIdx = ParentIdx; - if (CU.hasODR() || CU.isClangModule() || InTagModule) { + if (CU.hasODR() || CU.isClangModule() || InImportedModule) { if (CurrentDeclContext) { auto PtrInvalidPair = Contexts.getChildDeclContext(*CurrentDeclContext, DIE, CU, StringPool); @@ -1795,12 +1798,12 @@ static bool analyzeContextInfo(const DWARFDebugInfoEntryMinimal *DIE, Info.Ctxt = CurrentDeclContext = nullptr; } - Info.Prune = InTagModule; + Info.Prune = InImportedModule; if (DIE->hasChildren()) for (auto *Child = DIE->getFirstChild(); Child && !Child->isNULL(); Child = Child->getSibling()) Info.Prune &= analyzeContextInfo(Child, MyIdx, CU, CurrentDeclContext, - StringPool, Contexts, InTagModule); + StringPool, Contexts, InImportedModule); // Prune this DIE if it is either a forward declaration inside a // DW_TAG_module or a DW_TAG_module that contains nothing but