Skip to content

Commit a3eaa34

Browse files
committed
[cxx-interop] Do not get private discriminator for private Clang types
When generating debug symbols for private Clang types (which we started importing recently), the compiler crashes due to an assertion failure from ClangModuleUnit::getDiscriminatorForPrivateDecl(), which is called by getFilePrivateScope(). This patch fixes the issue crash by not calling getFilePrivateScope() for Clang types types. A discriminator is usually needed to disambiguate private Swift types declared in different files, but Clang types follow different scoping conventions that make this discriminator unnecessary. rdar://148481025
1 parent 5f07b91 commit a3eaa34

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
25782578
// Scope outermost fileprivate decls in an inline private discriminator
25792579
// namespace.
25802580
if (auto *Decl = DbgTy.getDecl())
2581-
if (Decl->isOutermostPrivateOrFilePrivateScope())
2581+
if (!ClangDecl && Decl->isOutermostPrivateOrFilePrivateScope())
25822582
Scope = getFilePrivateScope(Scope, Decl);
25832583

25842584
return Scope;

test/Interop/Cxx/class/access/private-fileid-irgen.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// RUN: %target-swift-frontend -emit-ir -module-name main %t/blessed.swift -I %S/Inputs -cxx-interoperability-mode=default | %FileCheck %s
66
// RUN: %target-swift-frontend -emit-ir -module-name main %t/blessed.swift -I %S/Inputs -cxx-interoperability-mode=default -Onone | %FileCheck %s
77

8+
// RUN: %target-swift-frontend -emit-ir -module-name main %t/blessed.swift -I %S/Inputs -cxx-interoperability-mode=default -g | %FileCheck %s
9+
// RUN: %target-swift-frontend -emit-ir -module-name main %t/blessed.swift -I %S/Inputs -cxx-interoperability-mode=default -g -Onone | %FileCheck %s
10+
811
import NonPublic
912

1013
// These extension methods are just here to make it clear what we are doing to

0 commit comments

Comments
 (0)