File tree Expand file tree Collapse file tree 3 files changed +45
-18
lines changed Expand file tree Collapse file tree 3 files changed +45
-18
lines changed Original file line number Diff line number Diff line change @@ -1111,17 +1111,25 @@ void IRGenerator::emitGlobalTopLevel(bool emitForParallelEmission) {
1111
1111
1112
1112
void IRGenModule::finishEmitAfterTopLevel () {
1113
1113
// Emit the implicit import of the swift standard library.
1114
+ // FIXME: We'd get the exact set of implicit imports if we went through the
1115
+ // SourceFile's getImportedModules instead, but then we'd lose location info
1116
+ // for the explicit imports.
1114
1117
if (DebugInfo) {
1115
- std::pair<swift::Identifier, swift::SourceLoc> AccessPath[] = {
1116
- { Context.StdlibModuleName , swift::SourceLoc () }
1117
- };
1118
+ if (ModuleDecl *TheStdlib = Context.getStdlibModule ()) {
1119
+ if (TheStdlib != getSwiftModule ()) {
1120
+ std::pair<swift::Identifier, swift::SourceLoc> AccessPath[] = {
1121
+ { Context.StdlibModuleName , swift::SourceLoc () }
1122
+ };
1118
1123
1119
- auto Imp = ImportDecl::create (Context,
1120
- getSwiftModule (),
1121
- SourceLoc (),
1122
- ImportKind::Module, SourceLoc (),
1123
- AccessPath);
1124
- DebugInfo->emitImport (Imp);
1124
+ auto Imp = ImportDecl::create (Context,
1125
+ getSwiftModule (),
1126
+ SourceLoc (),
1127
+ ImportKind::Module, SourceLoc (),
1128
+ AccessPath);
1129
+ Imp->setModule (TheStdlib);
1130
+ DebugInfo->emitImport (Imp);
1131
+ }
1132
+ }
1125
1133
}
1126
1134
}
1127
1135
Original file line number Diff line number Diff line change @@ -1696,15 +1696,8 @@ void IRGenDebugInfoImpl::emitImport(ImportDecl *D) {
1696
1696
if (Opts.DebugInfoKind <= IRGenDebugInfoKind::LineTables)
1697
1697
return ;
1698
1698
1699
- swift::ModuleDecl *M = IGM.Context .getModule (D->getModulePath ());
1700
- if (!M &&
1701
- D->getModulePath ()[0 ].first == IGM.Context .TheBuiltinModule ->getName ())
1702
- M = IGM.Context .TheBuiltinModule ;
1703
- if (!M) {
1704
- assert (M && " Could not find module for import decl." );
1705
- return ;
1706
- }
1707
- ModuleDecl::ImportedModule Imported = {D->getModulePath (), M};
1699
+ assert (D->getModule () && " compiler-synthesized ImportDecl is incomplete" );
1700
+ ModuleDecl::ImportedModule Imported = {D->getModulePath (), D->getModule ()};
1708
1701
auto DIMod = getOrCreateModule (Imported);
1709
1702
auto L = getDebugLoc (*this , D);
1710
1703
auto *File = getOrCreateFile (L.Filename );
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+
3
+ // RUN: %target-swift-frontend -emit-ir -parse-stdlib -module-name NotTheStdlib %s -I %t -g -o - > %t.ll
4
+ // RUN: %FileCheck %s < %t.ll
5
+ // RUN: %FileCheck -check-prefix=NEGATIVE %s < %t.ll
6
+
7
+ // RUN: %target-swift-frontend -c -parse-stdlib -module-name NotTheStdlib %s -I %t -g -o %t.o
8
+ // RUN: %llvm-dwarfdump -a %t.o > %t.dump
9
+ // RUN: %FileCheck -check-prefix=DWARF %s < %t.dump
10
+ // RUN: %FileCheck -check-prefix=NEGATIVE-DWARF %s < %t.dump
11
+
12
+ // CHECK-DAG: ![[MODULE:[0-9]+]] = !DIModule({{.*}}, name: "NotTheStdlib", includePath: "{{.*}}test{{.*}}DebugInfo{{.*}}"
13
+ // CHECK-DAG: !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[THISFILE:[0-9]+]], entity: ![[MODULE]]
14
+ // CHECK-DAG: ![[THISFILE]] = !DIFile(filename: "ImportsStdlib.swift", directory: "{{.*}}test/DebugInfo")
15
+
16
+ // NEGATIVE-NOT: !DIFile(filename: "Swift.swiftmodule"
17
+ // NEGATIVE-NOT: !DIModule({{.*}}, name: "Swift"
18
+
19
+ // DWARF: .debug_info
20
+ // DWARF: DW_TAG_module
21
+ // DWARF: DW_AT_name ("NotTheStdlib")
22
+ // DWARF: DW_AT_LLVM_include_path
23
+
24
+ // DWARF: file_names{{.*}} ImportsStdlib.swift
25
+
26
+ // NEGATIVE-DWARF-NOT: DW_AT_name ("Swift")
You can’t perform that action at this time.
0 commit comments