Skip to content

Commit 6947993

Browse files
[c-interop] Rename @_extern to @extern
Now the feature is gated by experimental feature flag. It's not shipped in any language release, so this rename should be fine.
1 parent 03ed46a commit 6947993

26 files changed

+116
-114
lines changed

docs/ReferenceGuides/UnderscoredAttributes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,19 +437,19 @@ the export name.
437437

438438
It's the equivalent of clang's `__attribute__((export_name))`.
439439

440-
## `@_extern(<language>)`
440+
## `@extern(<language>)`
441441

442442
Indicates that a particular declaration should be imported
443443
from the external environment.
444444

445-
### `@_extern(wasm, module: <"moduleName">, name: <"fieldName">)`
445+
### `@extern(wasm, module: <"moduleName">, name: <"fieldName">)`
446446

447447
Indicates that a particular declaration should be imported
448448
through WebAssembly's import interface.
449449

450450
It's the equivalent of clang's `__attribute__((import_module("module"), import_name("field")))`.
451451

452-
### `@_extern(c, [, <"cName">])`
452+
### `@extern(c, [, <"cName">])`
453453

454454
Indicates that a particular declaration should refer to a
455455
C declaration with the given name. If the optional "cName"
@@ -462,7 +462,7 @@ C declarations from Swift, while `@_cdecl` is used to define
462462
Swift functions that can be referenced from C.
463463

464464
Also similar to `@_silgen_name`, but a function declared with
465-
`@_extern(c)` is assumed to use the C ABI, while `@_silgen_name`
465+
`@extern(c)` is assumed to use the C ABI, while `@_silgen_name`
466466
assumes the Swift ABI.
467467

468468
## `@_fixed_layout`

include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ DECL_ATTR(_section, Section,
420420
DECL_ATTR(_rawLayout, RawLayout,
421421
OnStruct | UserInaccessible | ABIBreakingToAdd | ABIBreakingToRemove | APIStableToAdd | APIStableToRemove,
422422
146)
423-
DECL_ATTR(_extern, Extern,
423+
DECL_ATTR(extern, Extern,
424424
OnFunc | AllowMultipleAttributes | ABIBreakingToAdd | ABIBreakingToRemove | APIStableToAdd | APIStableToRemove,
425425
147)
426426
SIMPLE_DECL_ATTR(_nonEscapable, NonEscapable,

include/swift/AST/Attr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,7 +2339,7 @@ class ExposeAttr : public DeclAttribute {
23392339
}
23402340
};
23412341

2342-
/// Define the `@_extern` attribute, used to import external declarations in
2342+
/// Define the `@extern` attribute, used to import external declarations in
23432343
/// the specified way to interoperate with Swift.
23442344
class ExternAttr : public DeclAttribute {
23452345
SourceLoc LParenLoc, RParenLoc;
@@ -2364,7 +2364,7 @@ class ExternAttr : public DeclAttribute {
23642364
const llvm::Optional<StringRef> ModuleName;
23652365

23662366
/// The declaration name to import
2367-
/// std::nullopt if the declaration name is not specified with @_extern(c)
2367+
/// std::nullopt if the declaration name is not specified with @extern(c)
23682368
const llvm::Optional<StringRef> Name;
23692369

23702370
SourceLoc getLParenLoc() const { return LParenLoc; }

include/swift/AST/AttrKind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ enum class ExposureKind: uint8_t {
112112
enum : unsigned { NumExposureKindBits =
113113
countBitsUsed(static_cast<unsigned>(ExposureKind::Last_ExposureKind)) };
114114

115-
/// This enum represents the possible values of the @_extern attribute.
115+
/// This enum represents the possible values of the @extern attribute.
116116
enum class ExternKind: uint8_t {
117117
/// Reference an externally defined C function.
118118
/// The imported function has C function pointer representation,

include/swift/AST/DiagnosticsParse.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,7 @@ ERROR(attr_rawlayout_expected_params,none,
18681868
"expected %1 argument after %0 argument in @_rawLayout attribute", (StringRef, StringRef))
18691869

18701870
ERROR(attr_extern_expected_label,none,
1871-
"expected %0 argument to @_extern attribute", (StringRef))
1871+
"expected %0 argument to @extern attribute", (StringRef))
18721872
//------------------------------------------------------------------------------
18731873
// MARK: Generics parsing diagnostics
18741874
//------------------------------------------------------------------------------

include/swift/AST/DiagnosticsSema.def

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,17 +1871,17 @@ ERROR(section_not_at_top_level,none,
18711871
ERROR(section_empty_name,none,
18721872
"@_section section name cannot be empty", ())
18731873

1874-
// @_extern
1874+
// @extern
18751875
ERROR(attr_extern_experimental,none,
1876-
"@_extern requires '-enable-experimental-feature Extern'", ())
1876+
"@extern requires '-enable-experimental-feature Extern'", ())
18771877
ERROR(extern_not_at_top_level_func,none,
1878-
"@_extern attribute can only be applied to global functions", ())
1878+
"@extern attribute can only be applied to global functions", ())
18791879
ERROR(extern_empty_c_name,none,
1880-
"expected non-empty C name in @_extern attribute", ())
1880+
"expected non-empty C name in @extern attribute", ())
18811881
ERROR(extern_only_non_other_attr,none,
1882-
"@_extern attribute cannot be applied to an '@%0' declaration", (StringRef))
1882+
"@extern attribute cannot be applied to an '@%0' declaration", (StringRef))
18831883
WARNING(extern_c_maybe_invalid_name, none,
1884-
"C name '%0' may be invalid; explicitly specify the name in @_extern(c) to suppress this warning",
1884+
"C name '%0' may be invalid; explicitly specify the name in @extern(c) to suppress this warning",
18851885
(StringRef))
18861886

18871887
ERROR(c_func_variadic, none,

include/swift/Basic/Features.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ EXPERIMENTAL_FEATURE(StructLetDestructuring, true)
256256
/// lifetime-dependent results.
257257
EXPERIMENTAL_FEATURE(NonEscapableTypes, false)
258258

259-
/// Enable the `@_extern` attribute.
259+
/// Enable the `@extern` attribute.
260260
EXPERIMENTAL_FEATURE(Extern, true)
261261

262262
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE

include/swift/Parse/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ class Parser {
10951095
ParserResult<DifferentiableAttr> parseDifferentiableAttribute(SourceLoc AtLoc,
10961096
SourceLoc Loc);
10971097

1098-
/// Parse the @_extern attribute.
1098+
/// Parse the @extern attribute.
10991099
bool parseExternAttribute(DeclAttributes &Attributes, bool &DiscardAttribute,
11001100
StringRef AttrName, SourceLoc AtLoc, SourceLoc Loc);
11011101

include/swift/SIL/SILFunction.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ class SILFunction
303303
/// empty.
304304
StringRef WasmExportName;
305305

306-
/// Name of a Wasm import module and field if @_extern(wasm) attribute
306+
/// Name of a Wasm import module and field if @extern(wasm) attribute
307307
llvm::Optional<std::pair<StringRef, StringRef>> WasmImportModuleAndField;
308308

309309
/// Has value if there's a profile for this function
@@ -1293,14 +1293,14 @@ class SILFunction
12931293
StringRef wasmExportName() const { return WasmExportName; }
12941294
void setWasmExportName(StringRef value) { WasmExportName = value; }
12951295

1296-
/// Return Wasm import module name if @_extern(wasm) was used otherwise empty
1296+
/// Return Wasm import module name if @extern(wasm) was used otherwise empty
12971297
StringRef wasmImportModuleName() const {
12981298
if (WasmImportModuleAndField)
12991299
return WasmImportModuleAndField->first;
13001300
return StringRef();
13011301
}
13021302

1303-
/// Return Wasm import field name if @_extern(wasm) was used otherwise empty
1303+
/// Return Wasm import field name if @extern(wasm) was used otherwise empty
13041304
StringRef wasmImportFieldName() const {
13051305
if (WasmImportModuleAndField)
13061306
return WasmImportModuleAndField->second;

lib/AST/Attr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
11411141

11421142
case DAK_Extern: {
11431143
auto *Attr = cast<ExternAttr>(this);
1144-
Printer.printAttrName("@_extern");
1144+
Printer.printAttrName("@extern");
11451145
Printer << "(";
11461146
switch (Attr->getExternKind()) {
11471147
case ExternKind::C:
@@ -1152,7 +1152,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
11521152
break;
11531153
case ExternKind::Wasm:
11541154
Printer << "wasm";
1155-
// @_extern(wasm) always has names.
1155+
// @extern(wasm) always has names.
11561156
Printer << ", module: \"" << *Attr->ModuleName << "\"";
11571157
Printer << ", name: \"" << *Attr->Name << "\")";
11581158
break;
@@ -1731,7 +1731,7 @@ StringRef DeclAttribute::getAttrName() const {
17311731
case DAK_RawLayout:
17321732
return "_rawLayout";
17331733
case DAK_Extern:
1734-
return "_extern";
1734+
return "extern";
17351735
}
17361736
llvm_unreachable("bad DeclAttrKind");
17371737
}

0 commit comments

Comments
 (0)