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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308399 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Adrian Prantl 2017-07-19 00:09:58 +00:00
parent 567034c312
commit bccfcb9907
10 changed files with 58 additions and 21 deletions

View File

@ -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<Decl>(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<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 ImportDecl &ID) {
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 NamespaceAliasDecl &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;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -0,0 +1,2 @@
@import Empty;
struct DebugObjCImport {};

View File

@ -347,6 +347,12 @@ module DebugObjC {
header "DebugObjC.h"
}
module DebugObjCImport {
module SubModule {
header "DebugObjCImport.h"
}
}
module ImportNameInDir {
header "ImportNameInDir.h"
export *

View File

@ -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"

View File

@ -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 - \