Skip to content

Commit 67a24cc

Browse files
committed
TBDGen: Don't skip extensions on clang types.
Fixes a regression introduced with #68216. Some nominal types belonging to clang modules don't have a clang node in the AST, so make sure we match the logic used when computing IR linkage to determine whether a nominal type is a clang type. Resolves rdar://115308770
1 parent bc7139b commit 67a24cc

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

lib/SIL/IR/SILSymbolVisitor.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "swift/AST/PropertyWrappers.h"
2626
#include "swift/AST/SynthesizedFileUnit.h"
2727
#include "swift/Basic/Defer.h"
28+
#include "swift/ClangImporter/ClangModule.h"
2829
#include "swift/SIL/FormalLinkage.h"
2930
#include "swift/SIL/SILLinkage.h"
3031
#include "swift/SIL/SILModule.h"
@@ -372,7 +373,9 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
372373
if (!Ctx.getOpts().PublicSymbolsOnly)
373374
return false;
374375

375-
if (NTD->hasClangNode())
376+
// Don't skip nominals from clang modules; they have PublicNonUnique
377+
// linkage.
378+
if (isa<ClangModuleUnit>(NTD->getDeclContext()->getModuleScopeContext()))
376379
return false;
377380

378381
return getDeclLinkage(NTD) != FormalLinkage::PublicUnique;

test/TBD/Inputs/custom-error.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@import Foundation;
2+
3+
extern NSString *const CustomErrorDomain;
4+
5+
// typedef NS_ERROR_ENUM(CustomErrorDomain, CustomErrorCode) { ... }
6+
typedef enum CustomErrorCode : long CustomErrorCode;
7+
enum __attribute__((ns_error_domain(CustomErrorDomain))) CustomErrorCode : long {
8+
CustomErrorA,
9+
};

test/TBD/Inputs/module.modulemap

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module CustomError {
2+
header "custom-error.h"
3+
}

test/TBD/custom_objc_error.swift

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// REQUIRES: VENDOR=apple
2+
// RUN: %empty-directory(%t)
3+
4+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=missing %s -I %S/Inputs/ -disable-objc-attr-requires-foundation-module -emit-tbd -emit-tbd-path %t/test.tbd
5+
6+
import Foundation
7+
@_exported import CustomError
8+
9+
extension CustomError : CustomStringConvertible {
10+
public var description: String {
11+
let nsError = self as NSError
12+
return nsError.description
13+
}
14+
}

0 commit comments

Comments
 (0)