Author: adrian Date: Tue Jul 18 17:09:58 2017 New Revision: 308399 URL: http://llvm.org/viewvc/llvm-project?rev=308399&view=rev Log: Update for LLVM IR metadata changes (DIImportedEntity now needs a DIFile).
<rdar://problem/33357889> https://bugs.llvm.org/show_bug.cgi?id=33822 Differential Revision: https://reviews.llvm.org/D35583 Added: cfe/trunk/test/Modules/Inputs/DebugObjCImport.h cfe/trunk/test/Modules/debug-info-moduleimport-in-module.m Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/test/CodeGen/debug-info-imported-entity.cpp cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp cfe/trunk/test/Modules/DebugInfoTransitiveImport.m cfe/trunk/test/Modules/ExtDebugInfo.cpp cfe/trunk/test/Modules/Inputs/module.map cfe/trunk/test/Modules/debug-info-moduleimport.m Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=308399&r1=308398&r2=308399&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Jul 18 17:09:58 2017 @@ -3970,10 +3970,10 @@ void CGDebugInfo::EmitUsingDirective(con const NamespaceDecl *NSDecl = UD.getNominatedNamespace(); if (!NSDecl->isAnonymousNamespace() || CGM.getCodeGenOpts().DebugExplicitImport) { + auto Loc = UD.getLocation(); DBuilder.createImportedModule( getCurrentContextDescriptor(cast<Decl>(UD.getDeclContext())), - getOrCreateNamespace(NSDecl), - getLineNumber(UD.getLocation())); + getOrCreateNamespace(NSDecl), getOrCreateFile(Loc), getLineNumber(Loc)); } } @@ -3996,10 +3996,12 @@ void CGDebugInfo::EmitUsingDecl(const Us if (AT->getDeducedType().isNull()) return; if (llvm::DINode *Target = - getDeclarationOrDefinition(USD.getUnderlyingDecl())) + getDeclarationOrDefinition(USD.getUnderlyingDecl())) { + auto Loc = USD.getLocation(); DBuilder.createImportedDeclaration( getCurrentContextDescriptor(cast<Decl>(USD.getDeclContext())), Target, - getLineNumber(USD.getLocation())); + getOrCreateFile(Loc), getLineNumber(Loc)); + } } void CGDebugInfo::EmitImportDecl(const ImportDecl &ID) { @@ -4007,10 +4009,11 @@ void CGDebugInfo::EmitImportDecl(const I return; if (Module *M = ID.getImportedModule()) { auto Info = ExternalASTSource::ASTSourceDescriptor(*M); + auto Loc = ID.getLocation(); DBuilder.createImportedDeclaration( getCurrentContextDescriptor(cast<Decl>(ID.getDeclContext())), - getOrCreateModuleRef(Info, DebugTypeExtRefs), - getLineNumber(ID.getLocation())); + getOrCreateModuleRef(Info, DebugTypeExtRefs), getOrCreateFile(Loc), + getLineNumber(Loc)); } } @@ -4022,18 +4025,19 @@ CGDebugInfo::EmitNamespaceAlias(const Na if (VH) return cast<llvm::DIImportedEntity>(VH); llvm::DIImportedEntity *R; + auto Loc = NA.getLocation(); if (const auto *Underlying = dyn_cast<NamespaceAliasDecl>(NA.getAliasedNamespace())) // This could cache & dedup here rather than relying on metadata deduping. R = DBuilder.createImportedDeclaration( getCurrentContextDescriptor(cast<Decl>(NA.getDeclContext())), - EmitNamespaceAlias(*Underlying), getLineNumber(NA.getLocation()), - NA.getName()); + EmitNamespaceAlias(*Underlying), getOrCreateFile(Loc), + getLineNumber(Loc), NA.getName()); else R = DBuilder.createImportedDeclaration( getCurrentContextDescriptor(cast<Decl>(NA.getDeclContext())), getOrCreateNamespace(cast<NamespaceDecl>(NA.getAliasedNamespace())), - getLineNumber(NA.getLocation()), NA.getName()); + getOrCreateFile(Loc), getLineNumber(Loc), NA.getName()); VH.reset(R); return R; } Modified: cfe/trunk/test/CodeGen/debug-info-imported-entity.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-imported-entity.cpp?rev=308399&r1=308398&r2=308399&view=diff ============================================================================== --- cfe/trunk/test/CodeGen/debug-info-imported-entity.cpp (original) +++ cfe/trunk/test/CodeGen/debug-info-imported-entity.cpp Tue Jul 18 17:09:58 2017 @@ -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 Modified: cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp?rev=308399&r1=308398&r2=308399&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp (original) +++ cfe/trunk/test/CodeGenCXX/debug-info-anon-namespace.cpp Tue Jul 18 17:09:58 2017 @@ -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 Modified: cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp?rev=308399&r1=308398&r2=308399&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp (original) +++ cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp Tue Jul 18 17:09:58 2017 @@ -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 Modified: cfe/trunk/test/Modules/DebugInfoTransitiveImport.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/DebugInfoTransitiveImport.m?rev=308399&r1=308398&r2=308399&view=diff ============================================================================== --- cfe/trunk/test/Modules/DebugInfoTransitiveImport.m (original) +++ cfe/trunk/test/Modules/DebugInfoTransitiveImport.m Tue Jul 18 17:09:58 2017 @@ -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: Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=308399&r1=308398&r2=308399&view=diff ============================================================================== --- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original) +++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Tue Jul 18 17:09:58 2017 @@ -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: Added: cfe/trunk/test/Modules/Inputs/DebugObjCImport.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugObjCImport.h?rev=308399&view=auto ============================================================================== --- cfe/trunk/test/Modules/Inputs/DebugObjCImport.h (added) +++ cfe/trunk/test/Modules/Inputs/DebugObjCImport.h Tue Jul 18 17:09:58 2017 @@ -0,0 +1,2 @@ +@import Empty; +struct DebugObjCImport {}; Modified: cfe/trunk/test/Modules/Inputs/module.map URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=308399&r1=308398&r2=308399&view=diff ============================================================================== --- cfe/trunk/test/Modules/Inputs/module.map (original) +++ cfe/trunk/test/Modules/Inputs/module.map Tue Jul 18 17:09:58 2017 @@ -347,6 +347,12 @@ module DebugObjC { header "DebugObjC.h" } +module DebugObjCImport { + module SubModule { + header "DebugObjCImport.h" + } +} + module ImportNameInDir { header "ImportNameInDir.h" export * Added: cfe/trunk/test/Modules/debug-info-moduleimport-in-module.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/debug-info-moduleimport-in-module.m?rev=308399&view=auto ============================================================================== --- cfe/trunk/test/Modules/debug-info-moduleimport-in-module.m (added) +++ cfe/trunk/test/Modules/debug-info-moduleimport-in-module.m Tue Jul 18 17:09:58 2017 @@ -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" Modified: cfe/trunk/test/Modules/debug-info-moduleimport.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/debug-info-moduleimport.m?rev=308399&r1=308398&r2=308399&view=diff ============================================================================== --- cfe/trunk/test/Modules/debug-info-moduleimport.m (original) +++ cfe/trunk/test/Modules/debug-info-moduleimport.m Tue Jul 18 17:09:58 2017 @@ -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 - \ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits