Skip to content

Commit 510eeaa

Browse files
committed
Remove references to features CDecl and CImplementation
1 parent 025af55 commit 510eeaa

39 files changed

+56
-157
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6684,8 +6684,6 @@ NOTE(not_objc_swift_class,none,
66846684
NOTE(not_objc_swift_struct,none,
66856685
"Swift structs cannot be represented in %" FOREIGN_LANG_SELECT "0",
66866686
(ForeignLanguage))
6687-
NOTE(not_objc_swift_enum,none,
6688-
"non-'@objc' enums cannot be represented in Objective-C", ())
66896687
NOTE(not_cdecl_or_objc_swift_enum,none,
66906688
"Swift enums not marked '@c'%select{| or '@objc'}0 cannot be "
66916689
"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
@@ -276,8 +276,6 @@ LANGUAGE_FEATURE(InlineArrayTypeSugar, 483, "Type sugar for InlineArray")
276276
LANGUAGE_FEATURE(LifetimeDependenceMutableAccessors, 0, "Support mutable accessors returning ~Escapable results")
277277
LANGUAGE_FEATURE(InoutLifetimeDependence, 0, "Support @_lifetime(&)")
278278
SUPPRESSIBLE_LANGUAGE_FEATURE(NonexhaustiveAttribute, 487, "Nonexhaustive Enums")
279-
LANGUAGE_FEATURE(CDecl, 495, "C compatible functions and enums with @c")
280-
LANGUAGE_FEATURE(CImplementation, 495, "C compatible functions and enums with @c")
281279

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

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,6 @@ static bool usesFeatureClosureBodyMacro(Decl *decl) {
323323
return false;
324324
}
325325

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

lib/PrintAsClang/ModuleContentsWriter.cpp

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

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

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
@@ -1817,9 +1817,6 @@ visitObjCImplementationAttr(ObjCImplementationAttr *attr) {
18171817
}
18181818
}
18191819
else if (auto AFD = dyn_cast<AbstractFunctionDecl>(D)) {
1820-
if (!hasObjCImplementationFeature(D, attr, Feature::CImplementation))
1821-
return;
1822-
18231820
if (!attr->CategoryName.empty()) {
18241821
auto diagnostic =
18251822
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
@@ -5,7 +5,6 @@
55
// RUN: -enable-experimental-feature Lifetimes \
66
// RUN: -enable-experimental-feature RawLayout \
77
// RUN: -enable-experimental-feature SymbolLinkageMarkers \
8-
// RUN: -enable-experimental-feature CDecl \
98
// RUN: -enable-experimental-concurrency \
109
// RUN: -enable-experimental-move-only \
1110
// RUN: -enable-experimental-feature ParserASTGen \
@@ -16,7 +15,6 @@
1615
// RUN: -enable-experimental-feature Lifetimes \
1716
// RUN: -enable-experimental-feature RawLayout \
1817
// RUN: -enable-experimental-feature SymbolLinkageMarkers \
19-
// RUN: -enable-experimental-feature CDecl \
2018
// RUN: -enable-experimental-concurrency \
2119
// RUN: -enable-experimental-move-only \
2220
// RUN: | %sanitize-address > %t/cpp-parser.ast
@@ -30,7 +28,6 @@
3028
// RUN: -enable-experimental-feature Lifetimes \
3129
// RUN: -enable-experimental-feature RawLayout \
3230
// RUN: -enable-experimental-feature SymbolLinkageMarkers \
33-
// RUN: -enable-experimental-feature CDecl \
3431
// RUN: -enable-experimental-concurrency \
3532
// RUN: -enable-experimental-move-only
3633

@@ -41,7 +38,6 @@
4138
// REQUIRES: swift_feature_Lifetimes
4239
// REQUIRES: swift_feature_RawLayout
4340
// REQUIRES: swift_feature_SymbolLinkageMarkers
44-
// REQUIRES: swift_feature_CDecl
4541

4642
// rdar://116686158
4743
// 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)