Skip to content

Commit 317a766

Browse files
committed
Module aliasing: use module real name to create DIModule
1 parent b69eac9 commit 317a766

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,12 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
777777
if (Optional<ASTSourceDescriptor> ModuleDesc = getClangModule(*M))
778778
return getOrCreateModule(*ModuleDesc, ModuleDesc->getModuleOrNull());
779779
StringRef Path = getFilenameFromDC(M);
780-
StringRef Name = M->getName().str();
780+
// Use the module 'real' name, which can be different from the name if module
781+
// aliasing was used (swift modules only). For example, if a source file has
782+
// 'import Foo', and '-module-alias Foo=Bar' was passed in, the real name of
783+
// the module on disk is Bar (.swiftmodule or .swiftinterface), and is used
784+
// for loading and mangling.
785+
StringRef Name = M->getRealName().str();
781786
return getOrCreateModule(M, TheCU, Name, Path);
782787
}
783788

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %empty-directory(%t)
2+
3+
/// Create a module Bar
4+
// RUN: echo 'public class Klass {}' > %t/FileBar.swift
5+
// RUN: %target-swift-frontend -module-name Bar %t/FileBar.swift -emit-module -emit-module-path %t/Bar.swiftmodule
6+
// RUN: test -f %t/Bar.swiftmodule
7+
8+
/// Create a module Foo that imports Cat with -module-alias Cat=Bar
9+
// RUN: %target-swift-frontend -emit-ir -module-name Foo -module-alias Cat=Bar %s -I %t -g -o - | %FileCheck %s
10+
11+
// CHECK-DAG: ![[BARMODULE:[0-9]+]] = !DIModule({{.*}}, name: "Bar"
12+
// CHECK-DAG: !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[THISFILE]], entity: ![[BARMODULE]]
13+
14+
import Cat
15+
public func meow() -> Cat.Klass? { return nil }

0 commit comments

Comments
 (0)