From: Adrian Prantl Date: Wed, 19 Jul 2017 00:09:58 +0000 (+0000) Subject: Update for LLVM IR metadata changes (DIImportedEntity now needs a DIFile). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bccfcb990700b1e3434cf594432394131677ddc8;p=clang Update for LLVM IR metadata changes (DIImportedEntity now needs a DIFile). https://bugs.llvm.org/show_bug.cgi?id=33822 Differential Revision: https://reviews.llvm.org/D35583 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308399 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 0b17807fe1..c9c450c32e 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -3970,10 +3970,10 @@ void CGDebugInfo::EmitUsingDirective(const UsingDirectiveDecl &UD) { const NamespaceDecl *NSDecl = UD.getNominatedNamespace(); if (!NSDecl->isAnonymousNamespace() || CGM.getCodeGenOpts().DebugExplicitImport) { + auto Loc = UD.getLocation(); DBuilder.createImportedModule( getCurrentContextDescriptor(cast(UD.getDeclContext())), - getOrCreateNamespace(NSDecl), - getLineNumber(UD.getLocation())); + getOrCreateNamespace(NSDecl), getOrCreateFile(Loc), getLineNumber(Loc)); } } @@ -3996,10 +3996,12 @@ void CGDebugInfo::EmitUsingDecl(const UsingDecl &UD) { if (AT->getDeducedType().isNull()) return; if (llvm::DINode *Target = - getDeclarationOrDefinition(USD.getUnderlyingDecl())) + getDeclarationOrDefinition(USD.getUnderlyingDecl())) { + auto Loc = USD.getLocation(); DBuilder.createImportedDeclaration( getCurrentContextDescriptor(cast(USD.getDeclContext())), Target, - getLineNumber(USD.getLocation())); + getOrCreateFile(Loc), getLineNumber(Loc)); + } } void CGDebugInfo::EmitImportDecl(const ImportDecl &ID) { @@ -4007,10 +4009,11 @@ void CGDebugInfo::EmitImportDecl(const ImportDecl &ID) { return; if (Module *M = ID.getImportedModule()) { auto Info = ExternalASTSource::ASTSourceDescriptor(*M); + auto Loc = ID.getLocation(); DBuilder.createImportedDeclaration( getCurrentContextDescriptor(cast(ID.getDeclContext())), - getOrCreateModuleRef(Info, DebugTypeExtRefs), - getLineNumber(ID.getLocation())); + getOrCreateModuleRef(Info, DebugTypeExtRefs), getOrCreateFile(Loc), + getLineNumber(Loc)); } } @@ -4022,18 +4025,19 @@ CGDebugInfo::EmitNamespaceAlias(const NamespaceAliasDecl &NA) { if (VH) return cast(VH); llvm::DIImportedEntity *R; + auto Loc = NA.getLocation(); if (const auto *Underlying = dyn_cast(NA.getAliasedNamespace())) // This could cache & dedup here rather than relying on metadata deduping. R = DBuilder.createImportedDeclaration( getCurrentContextDescriptor(cast(NA.getDeclContext())), - EmitNamespaceAlias(*Underlying), getLineNumber(NA.getLocation()), - NA.getName()); + EmitNamespaceAlias(*Underlying), getOrCreateFile(Loc), + getLineNumber(Loc), NA.getName()); else R = DBuilder.createImportedDeclaration( getCurrentContextDescriptor(cast(NA.getDeclContext())), getOrCreateNamespace(cast(NA.getAliasedNamespace())), - getLineNumber(NA.getLocation()), NA.getName()); + getOrCreateFile(Loc), getLineNumber(Loc), NA.getName()); VH.reset(R); return R; } diff --git a/test/CodeGen/debug-info-imported-entity.cpp b/test/CodeGen/debug-info-imported-entity.cpp index c7935eda48..398536e581 100644 --- a/test/CodeGen/debug-info-imported-entity.cpp +++ b/test/CodeGen/debug-info-imported-entity.cpp @@ -5,5 +5,6 @@ using std::A; using ::A; // CHECK: [[CompileUnit:![0-9]+]] = distinct !DICompileUnit({{.+}} imports: [[Imports:![0-9]+]] // CHECK: [[Imports]] = !{[[ImportedEntity:![0-9]+]]} -// CHECK: [[ImportedEntity]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[CompileUnit]], entity: [[STDA:![0-9]+]], line: 4) +// CHECK: [[ImportedEntity]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[CompileUnit]], entity: [[STDA:![0-9]+]], file: [[FILE:![0-9]+]], line: 4) // CHECK: [[STDA]] = !DICompositeType(tag: DW_TAG_class_type, name: "A", +// CHECK: [[FILE]] = !DIFile(filename: {{.*}}debug-info-imported-entity.cpp diff --git a/test/CodeGenCXX/debug-info-anon-namespace.cpp b/test/CodeGenCXX/debug-info-anon-namespace.cpp index 79298deaf8..3f4ef2a383 100644 --- a/test/CodeGenCXX/debug-info-anon-namespace.cpp +++ b/test/CodeGenCXX/debug-info-anon-namespace.cpp @@ -21,7 +21,7 @@ int *b2 = &a2; // PS4: [[NS:![0-9]+]] = !DINamespace // PS4: [[CU:![0-9]+]] = distinct !DICompileUnit // PS4: [[NS2:![0-9]+]] = !DINamespace -// PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CU]], entity: [[NS]]) -// PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[NS]], entity: [[NS2]], line: {{[0-9]+}}) +// PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CU]], entity: [[NS]], file: {{![0-9]+}}) +// PS4: !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[NS]], entity: [[NS2]], file: {{![0-9]+}}, line: {{[0-9]+}}) // NON-PS4-NOT: !DIImportedEntity diff --git a/test/CodeGenCXX/debug-info-namespace.cpp b/test/CodeGenCXX/debug-info-namespace.cpp index 95857e3390..296c99efc8 100644 --- a/test/CodeGenCXX/debug-info-namespace.cpp +++ b/test/CodeGenCXX/debug-info-namespace.cpp @@ -81,17 +81,17 @@ void C::c() {} // CHECK: [[CU:![0-9]+]] = distinct !DICompileUnit( // CHECK-SAME: imports: [[MODULES:![0-9]*]] // CHECK: [[MODULES]] = !{[[M1:![0-9]+]], [[M2:![0-9]+]], [[M3:![0-9]+]], [[M4:![0-9]+]], [[M5:![0-9]+]], [[M6:![0-9]+]], [[M7:![0-9]+]], [[M8:![0-9]+]], [[M9:![0-9]+]], [[M10:![0-9]+]], [[M11:![0-9]+]], [[M12:![0-9]+]], [[M13:![0-9]+]], [[M14:![0-9]+]], [[M15:![0-9]+]], [[M16:![0-9]+]], [[M17:![0-9]+]] -// CHECK: [[M1]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CTXT]], entity: [[NS]], line: 15) +// CHECK: [[M1]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CTXT]], entity: [[NS]], file: [[FOOCPP]], line: 15) // CHECK: [[M2]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[CU]], entity: [[CTXT]], -// CHECK: [[M3]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "E", scope: [[CU]], entity: [[CTXT]], line: 19) -// CHECK: [[M4]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[LEX2:![0-9]+]], entity: [[NS]], line: 23) +// CHECK: [[M3]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "E", scope: [[CU]], entity: [[CTXT]], file: [[FOOCPP]], line: 19) +// CHECK: [[M4]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[LEX2:![0-9]+]], entity: [[NS]], file: [[FOOCPP]], line: 23) // CHECK: [[LEX2]] = distinct !DILexicalBlock(scope: [[LEX1:![0-9]+]], file: [[FOOCPP]], // CHECK: [[LEX1]] = distinct !DILexicalBlock(scope: [[FUNC:![0-9]+]], file: [[FOOCPP]], // CHECK: [[FUNC:![0-9]+]] = distinct !DISubprogram(name: "func",{{.*}} isDefinition: true // CHECK: [[M5]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: [[FUNC]], entity: [[CTXT:![0-9]+]], -// CHECK: [[M6]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[FOO:![0-9]+]], line: 27) +// CHECK: [[M6]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[FOO:![0-9]+]], file: [[FOOCPP]], line: 27) // CHECK: [[FOO]] = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", // CHECK-SAME: line: 5 // CHECK-SAME: DIFlagFwdDecl diff --git a/test/Modules/DebugInfoTransitiveImport.m b/test/Modules/DebugInfoTransitiveImport.m index 034a909333..08dfecfb78 100644 --- a/test/Modules/DebugInfoTransitiveImport.m +++ b/test/Modules/DebugInfoTransitiveImport.m @@ -12,9 +12,9 @@ // Definition of left: // CHECK: !DICompileUnit({{.*}}dwoId: -// CHECK: !DIFile({{.*}}diamond_left +// CHECK: ![[LEFT:[0-9]+]] = !DIFile({{.*}}diamond_left.h // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, -// CHECK-SAME: entity: ![[MODULE:.*]], line: 3) +// CHECK-SAME: entity: ![[MODULE:.*]], file: ![[LEFT]], line: 3) // CHECK: ![[MODULE]] = !DIModule(scope: null, name: "diamond_top" // Skeleton for top: diff --git a/test/Modules/ExtDebugInfo.cpp b/test/Modules/ExtDebugInfo.cpp index fd3bb94075..ed9d1e859d 100644 --- a/test/Modules/ExtDebugInfo.cpp +++ b/test/Modules/ExtDebugInfo.cpp @@ -71,6 +71,8 @@ void foo() { anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum; } +// CHECK: ![[CPP:.*]] = !DIFile(filename: {{.*}}ExtDebugInfo.cpp" + // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum", // CHECK-SAME: scope: ![[NS:[0-9]+]], // CHECK-SAME: flags: DIFlagFwdDecl, @@ -201,7 +203,7 @@ void foo() { // CHECK-SAME: name: "InAnonymousNamespace", {{.*}}DIFlagFwdDecl) -// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !{{[0-9]+}}, entity: ![[STRUCT]], line: 27) +// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !{{[0-9]+}}, entity: ![[STRUCT]], file: ![[CPP]], line: 27) // CHECK: !DICompileUnit( // CHECK-SAME: splitDebugFilename: diff --git a/test/Modules/Inputs/DebugObjCImport.h b/test/Modules/Inputs/DebugObjCImport.h new file mode 100644 index 0000000000..b5ef366fca --- /dev/null +++ b/test/Modules/Inputs/DebugObjCImport.h @@ -0,0 +1,2 @@ +@import Empty; +struct DebugObjCImport {}; diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map index c0fe6c557f..4cb3e8a028 100644 --- a/test/Modules/Inputs/module.map +++ b/test/Modules/Inputs/module.map @@ -347,6 +347,12 @@ module DebugObjC { header "DebugObjC.h" } +module DebugObjCImport { + module SubModule { + header "DebugObjCImport.h" + } +} + module ImportNameInDir { header "ImportNameInDir.h" export * diff --git a/test/Modules/debug-info-moduleimport-in-module.m b/test/Modules/debug-info-moduleimport-in-module.m new file mode 100644 index 0000000000..cde46115d2 --- /dev/null +++ b/test/Modules/debug-info-moduleimport-in-module.m @@ -0,0 +1,21 @@ +// Test that an @import inside a module is not represented in the debug info. + +// REQUIRES: asserts + +// RUN: rm -rf %t +// RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \ +// RUN: -fimplicit-module-maps -fmodules-cache-path=%t %s \ +// RUN: -debugger-tuning=lldb -I %S/Inputs -emit-llvm -o %t.ll \ +// RUN: -mllvm -debug-only=pchcontainer &>%t-mod.ll +// RUN: cat %t-mod.ll | FileCheck %s + +@import DebugObjCImport.SubModule; + +// CHECK: distinct !DICompileUnit(language: DW_LANG_ObjC +// CHECK: DW_TAG_structure_type, name: "DebugObjCImport" +// CHECK: ![[HEADER:.*]] = !DIFile(filename: {{.*}}DebugObjCImport.h" +// CHECK: ![[SUBMOD:.*]] = !DIModule({{.*}}name: "SubModule" +// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, +// CHECK-SAME: scope: ![[SUBMOD]], entity: ![[EMPTY:[0-9]+]], +// CHECK-SAME: file: ![[HEADER]], line: 1) +// CHECK: ![[EMPTY]] = !DIModule(scope: null, name: "Empty" diff --git a/test/Modules/debug-info-moduleimport.m b/test/Modules/debug-info-moduleimport.m index bf60690be4..16820baebe 100644 --- a/test/Modules/debug-info-moduleimport.m +++ b/test/Modules/debug-info-moduleimport.m @@ -10,12 +10,13 @@ // CHECK: ![[CU:.*]] = distinct !DICompileUnit @import DebugObjC; // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: ![[CU]], -// CHECK-SAME: entity: ![[MODULE:.*]], line: [[@LINE-2]]) +// CHECK-SAME: entity: ![[MODULE:.*]], file: ![[F:[0-9]+]], +// CHECK-SAME: line: [[@LINE-3]]) // CHECK: ![[MODULE]] = !DIModule(scope: null, name: "DebugObjC", // CHECK-SAME: configMacros: "\22-DGREETING=Hello World\22 \22-UNDEBUG\22", // CHECK-SAME: includePath: "{{.*}}test{{.*}}Modules{{.*}}Inputs", // CHECK-SAME: isysroot: "/tmp/..") - +// CHECK: ![[F]] = !DIFile(filename: {{.*}}debug-info-moduleimport.m // RUN: %clang_cc1 -debug-info-kind=limited -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \ // RUN: %s -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm -o - \