Skip to content

Commit 2bfe95e

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 dfff952 commit 2bfe95e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//--- blessed.swift
22
// RUN: split-file %s %t
33
// RUN: %target-swift-frontend -emit-ir -module-name main %t/blessed.swift -I %S/Inputs -cxx-interoperability-mode=default -Onone | %FileCheck %s
4+
// RUN: %target-swift-frontend -emit-ir -module-name main %t/blessed.swift -I %S/Inputs -cxx-interoperability-mode=default -Onone -g | %FileCheck %s
45

56
import NonPublic
67

0 commit comments

Comments
 (0)