Skip to content

Commit e61c1cc

Browse files
authored
Merge pull request #26871 from adrian-prantl/49233932-pch
2 parents 987e2c6 + ce37ddf commit e61c1cc

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,15 +1601,19 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
16011601
auto Idx = ClangDecl->getOwningModuleID();
16021602
auto SubModuleDesc = Reader.getSourceDescriptor(Idx);
16031603
auto TopLevelModuleDesc = getClangModule(*TypeDecl->getModuleContext());
1604-
if (SubModuleDesc && TopLevelModuleDesc) {
1605-
// Describe the submodule, but substitute the cached ASTFile from
1606-
// the toplevel module. The ASTFile pointer in SubModule may be
1607-
// dangling and cant be trusted.
1608-
Scope = getOrCreateModule({SubModuleDesc->getModuleName(),
1609-
SubModuleDesc->getPath(),
1610-
TopLevelModuleDesc->getASTFile(),
1611-
TopLevelModuleDesc->getSignature()},
1612-
SubModuleDesc->getModuleOrNull());
1604+
if (SubModuleDesc) {
1605+
if (TopLevelModuleDesc)
1606+
// Describe the submodule, but substitute the cached ASTFile from
1607+
// the toplevel module. The ASTFile pointer in SubModule may be
1608+
// dangling and cant be trusted.
1609+
Scope = getOrCreateModule({SubModuleDesc->getModuleName(),
1610+
SubModuleDesc->getPath(),
1611+
TopLevelModuleDesc->getASTFile(),
1612+
TopLevelModuleDesc->getSignature()},
1613+
SubModuleDesc->getModuleOrNull());
1614+
else if (SubModuleDesc->getModuleOrNull() == nullptr)
1615+
// This is (bridging header) PCH.
1616+
Scope = getOrCreateModule(*SubModuleDesc, nullptr);
16131617
}
16141618
}
16151619
if (!Scope)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-swift-frontend \
2+
// RUN: -emit-pch %S/Inputs/BridgingHeader.h -o %t.pch
3+
// RUN: %target-swift-frontend \
4+
// RUN: -import-objc-header %t.pch -emit-ir -g %s -o - | %FileCheck %s
5+
6+
// CHECK: !DIModule(scope: null, name: "BridgingHeader.h",
7+
// CHECK: !DICompileUnit(language: DW_LANG_{{ObjC|C99}},{{.*}}splitDebugFilename:
8+
// CHECK-SAME: dwoId:
9+
10+
public let p = Point(x: 1, y: 2)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
struct Point {
2+
int x, y;
3+
};

0 commit comments

Comments
 (0)