Skip to content

Commit 94113f4

Browse files
committed
SE-496: Remove references to features CDecl and CImplementation
1 parent bce585c commit 94113f4

39 files changed

+56
-158
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6701,8 +6701,6 @@ NOTE(not_objc_swift_class,none,
67016701
NOTE(not_objc_swift_struct,none,
67026702
"Swift structs cannot be represented in %" FOREIGN_LANG_SELECT "0",
67036703
(ForeignLanguage))
6704-
NOTE(not_objc_swift_enum,none,
6705-
"non-'@objc' enums cannot be represented in Objective-C", ())
67066704
NOTE(not_cdecl_or_objc_swift_enum,none,
67076705
"Swift enums not marked '@c'%select{| or '@objc'}0 cannot be "
67086706
"represented in %" FOREIGN_LANG_SELECT "0",

include/swift/Basic/Features.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@ LANGUAGE_FEATURE(LifetimeDependenceMutableAccessors, 0, "Support mutable accesso
277277
LANGUAGE_FEATURE(InoutLifetimeDependence, 0, "Support @_lifetime(&)")
278278
SUPPRESSIBLE_LANGUAGE_FEATURE(NonexhaustiveAttribute, 487, "Nonexhaustive Enums")
279279
LANGUAGE_FEATURE(ModuleSelector, 491, "Module selectors (`Module::name` syntax)")
280-
LANGUAGE_FEATURE(CDecl, 495, "C compatible functions and enums with @c")
281-
LANGUAGE_FEATURE(CImplementation, 495, "C compatible functions and enums with @c")
282280

283281
// Swift 6
284282
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ UNINTERESTING_FEATURE(IsolatedAny2)
277277
UNINTERESTING_FEATURE(GlobalActorIsolatedTypesUsability)
278278
UNINTERESTING_FEATURE(ObjCImplementation)
279279
UNINTERESTING_FEATURE(ObjCImplementationWithResilientStorage)
280-
UNINTERESTING_FEATURE(CImplementation)
281280
UNINTERESTING_FEATURE(Sensitive)
282281
UNINTERESTING_FEATURE(DebugDescriptionMacro)
283282
UNINTERESTING_FEATURE(ReinitializeConsumeInMultiBlockDefer)
@@ -322,11 +321,6 @@ static bool usesFeatureClosureBodyMacro(Decl *decl) {
322321
return false;
323322
}
324323

325-
static bool usesFeatureCDecl(Decl *decl) {
326-
auto attr = decl->getAttrs().getAttribute<CDeclAttr>();
327-
return attr && !attr->Underscored;
328-
}
329-
330324
UNINTERESTING_FEATURE(StrictMemorySafety)
331325
UNINTERESTING_FEATURE(LibraryEvolution)
332326
UNINTERESTING_FEATURE(SafeInteropWrappers)

lib/PrintAsClang/ModuleContentsWriter.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -542,16 +542,10 @@ class ModuleWriter {
542542
assert(ED->isCCompatibleEnum() || ED->hasClangNode());
543543

544544
forwardDeclare(ED, [&]{
545-
if (ED->getASTContext().LangOpts.hasFeature(Feature::CDecl)) {
546-
// Forward declare in a way to be compatible with older C standards.
547-
os << "typedef SWIFT_ENUM_FWD_DECL(";
548-
printer.print(ED->getRawType());
549-
os << ", " << getNameForObjC(ED) << ")\n";
550-
} else {
551-
os << "enum " << getNameForObjC(ED) << " : ";
552-
printer.print(ED->getRawType());
553-
os << ";\n";
554-
}
545+
// Forward declare in a way to be compatible with older C standards.
546+
os << "typedef SWIFT_ENUM_FWD_DECL(";
547+
printer.print(ED->getRawType());
548+
os << ", " << getNameForObjC(ED) << ")\n";
555549
});
556550
}
557551

lib/PrintAsClang/PrintAsClang.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,18 @@ static void writePrologue(raw_ostream &out, ASTContext &ctx,
220220
static_assert(SWIFT_MAX_IMPORTED_SIMD_ELEMENTS == 4,
221221
"need to add SIMD typedefs here if max elements is increased");
222222

223-
if (ctx.LangOpts.hasFeature(Feature::CDecl)) {
224-
// For C compilers which don’t support nullability attributes, ignore them;
225-
// for ones which do, suppress warnings about them being an extension.
226-
out << "#if !__has_feature(nullability)\n"
227-
"# define _Nonnull\n"
228-
"# define _Nullable\n"
229-
"# define _Null_unspecified\n"
230-
"#elif !defined(__OBJC__)\n"
231-
"# pragma clang diagnostic ignored \"-Wnullability-extension\"\n"
232-
"#endif\n"
233-
"#if !__has_feature(nullability_nullable_result)\n"
234-
"# define _Nullable_result _Nullable\n"
235-
"#endif\n";
236-
}
223+
// For C compilers which don’t support nullability attributes, ignore them;
224+
// for ones which do, suppress warnings about them being an extension.
225+
out << "#if !__has_feature(nullability)\n"
226+
"# define _Nonnull\n"
227+
"# define _Nullable\n"
228+
"# define _Null_unspecified\n"
229+
"#elif !defined(__OBJC__)\n"
230+
"# pragma clang diagnostic ignored \"-Wnullability-extension\"\n"
231+
"#endif\n"
232+
"#if !__has_feature(nullability_nullable_result)\n"
233+
"# define _Nullable_result _Nullable\n"
234+
"#endif\n";
237235
}
238236

239237
static int compareImportModulesByName(const ImportModuleTy *left,
@@ -618,7 +616,7 @@ bool swift::printAsClangHeader(raw_ostream &os, ModuleDecl *M,
618616

619617
// C content (@c)
620618
std::string moduleContentsScratch;
621-
if (M->getASTContext().LangOpts.hasFeature(Feature::CDecl)) {
619+
{
622620
SmallPtrSet<ImportModuleTy, 8> imports;
623621
llvm::raw_string_ostream cModuleContents{moduleContentsScratch};
624622
printModuleContentsAsC(cModuleContents, imports, *M, interopContext,

lib/Sema/TypeCheckAttr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,9 +1841,6 @@ visitObjCImplementationAttr(ObjCImplementationAttr *attr) {
18411841
}
18421842
}
18431843
else if (auto AFD = dyn_cast<AbstractFunctionDecl>(D)) {
1844-
if (!hasObjCImplementationFeature(D, attr, Feature::CImplementation))
1845-
return;
1846-
18471844
if (!attr->CategoryName.empty()) {
18481845
auto diagnostic =
18491846
diagnose(attr->getLocation(),

lib/Sema/TypeCheckDeclObjC.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,11 @@ static void diagnoseTypeNotRepresentableInObjC(const DeclContext *DC,
222222

223223
// Special diagnostic for enums.
224224
if (T->is<EnumType>()) {
225-
if (DC->getASTContext().LangOpts.hasFeature(Feature::CDecl)) {
226-
// New dialog mentioning @c.
227-
diags.diagnose(TypeRange.Start, diag::not_cdecl_or_objc_swift_enum,
228-
language)
229-
.highlight(TypeRange)
230-
.limitBehavior(behavior);
231-
} else {
232-
diags.diagnose(TypeRange.Start, diag::not_objc_swift_enum)
233-
.highlight(TypeRange)
234-
.limitBehavior(behavior);
235-
}
225+
// New dialog mentioning @c.
226+
diags.diagnose(TypeRange.Start, diag::not_cdecl_or_objc_swift_enum,
227+
language)
228+
.highlight(TypeRange)
229+
.limitBehavior(behavior);
236230
return;
237231
}
238232

@@ -4193,10 +4187,6 @@ class ObjCImplementationChecker {
41934187
!decl->getASTContext().LangOpts.hasFeature(Feature::ObjCImplementation))
41944188
return;
41954189

4196-
if (isa<AbstractFunctionDecl>(decl) &&
4197-
!decl->getASTContext().LangOpts.hasFeature(Feature::CImplementation))
4198-
return;
4199-
42004190
auto diag = diagnose(getAttr()->getLocation(),
42014191
diag::objc_implementation_early_spelling_deprecated);
42024192
diag.fixItReplace(getAttr()->getRangeWithAt(), "@implementation");

test/ASTGen/attrs.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// RUN: -enable-experimental-feature Extern \
55
// RUN: -enable-experimental-feature Lifetimes \
66
// RUN: -enable-experimental-feature RawLayout \
7-
// RUN: -enable-experimental-feature CDecl \
87
// RUN: -enable-experimental-concurrency \
98
// RUN: -enable-experimental-move-only \
109
// RUN: -enable-experimental-feature ParserASTGen \
@@ -14,7 +13,6 @@
1413
// RUN: -enable-experimental-feature Extern \
1514
// RUN: -enable-experimental-feature Lifetimes \
1615
// RUN: -enable-experimental-feature RawLayout \
17-
// RUN: -enable-experimental-feature CDecl \
1816
// RUN: -enable-experimental-concurrency \
1917
// RUN: -enable-experimental-move-only \
2018
// RUN: | %sanitize-address > %t/cpp-parser.ast
@@ -27,7 +25,6 @@
2725
// RUN: -enable-experimental-feature Extern \
2826
// RUN: -enable-experimental-feature Lifetimes \
2927
// RUN: -enable-experimental-feature RawLayout \
30-
// RUN: -enable-experimental-feature CDecl \
3128
// RUN: -enable-experimental-concurrency \
3229
// RUN: -enable-experimental-move-only
3330

@@ -37,7 +34,6 @@
3734
// REQUIRES: swift_feature_Extern
3835
// REQUIRES: swift_feature_Lifetimes
3936
// REQUIRES: swift_feature_RawLayout
40-
// REQUIRES: swift_feature_CDecl
4137

4238
// rdar://116686158
4339
// UNSUPPORTED: asan

test/IRGen/cdecl_implementation.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) \
2-
// RUN: -enable-experimental-feature CImplementation \
3-
// RUN: -enable-experimental-feature CDecl \
42
// RUN: -disable-objc-interop \
53
// RUN: -F %clang-importer-sdk-path/frameworks %s \
64
// RUN: -import-objc-header %S/Inputs/objc_implementation.h -emit-ir \
75
// RUN: -target %target-future-triple > %t.ir
86
// RUN: %FileCheck --input-file %t.ir %s
97

10-
// REQUIRES: swift_feature_CImplementation
11-
// REQUIRES: swift_feature_CDecl
12-
138
@implementation @c
149
public func implFunc(_ param: Int32) {}
1510

test/IRGen/objc_implementation.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// Test doesn't pass on all platforms (rdar://101420862)
22
// REQUIRES: OS=macosx
33

4-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-feature CImplementation -I %S/Inputs/abi -F %clang-importer-sdk-path/frameworks %s -import-objc-header %S/Inputs/objc_implementation.h -emit-ir -target %target-future-triple > %t.ir
4+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/abi -F %clang-importer-sdk-path/frameworks %s -import-objc-header %S/Inputs/objc_implementation.h -emit-ir -target %target-future-triple > %t.ir
55
// RUN: %FileCheck --input-file %t.ir %s
66
// RUN: %FileCheck --input-file %t.ir --check-prefix NEGATIVE %s
77
// REQUIRES: objc_interop
8-
// REQUIRES: swift_feature_CImplementation
98

109
// CHECK-DAG: @"$sSo36ImplClassWithResilientStoredPropertyC19objc_implementationE9beforeInts5Int32VvpWvd" = hidden global i64 8, align 8
1110
// CHECK-DAG: @"$sSo36ImplClassWithResilientStoredPropertyC19objc_implementationE6mirrors6MirrorVSgvpWvd" = hidden global i64 0, align 8

0 commit comments

Comments
 (0)