Skip to content

Commit f73ae1d

Browse files
authored
Merge pull request #2057 from swiftwasm/main
[pull] swiftwasm from main
2 parents 181fbbd + ada53b1 commit f73ae1d

File tree

92 files changed

+792
-743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+792
-743
lines changed

cmake/modules/StandaloneOverlay.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,17 @@ set(SWIFT_NATIVE_CLANG_TOOLS_PATH "${TOOLCHAIN_DIR}/usr/bin" CACHE STRING
5858
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "${TOOLCHAIN_DIR}/usr/bin" CACHE STRING
5959
"Path to Swift tools that are executable on the build machine.")
6060

61+
# NOTE: The initialization in stdlib/CMakeLists.txt will be bypassed if we
62+
# directly invoke CMake for this directory, so we initialize the variables
63+
# related to library evolution here as well.
64+
65+
option(SWIFT_STDLIB_STABLE_ABI
66+
"Should stdlib be built with stable ABI (library evolution, resilience)."
67+
TRUE)
68+
6169
option(SWIFT_ENABLE_MODULE_INTERFACES
6270
"Generate .swiftinterface files alongside .swiftmodule files."
63-
TRUE)
71+
"${SWIFT_STDLIB_STABLE_ABI}")
6472

6573
set(SWIFT_STDLIB_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
6674
"Build type for the Swift standard library and SDK overlays.")

docs/LibraryEvolution.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ No other changes are permitted; the following are particularly of note:
159159
not they have default arguments.
160160
- An ABI-public function that throws may not become non-throwing or vice versa.
161161
- The ``@escaping`` attribute may not be added to or removed from a parameter.
162-
- Adding or removing a function builder from a parameter is a
162+
- Adding or removing a result builder from a parameter is a
163163
`binary-compatible source-breaking change`.
164164

165165

include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SWIFT_TYPEID(AncestryFlags)
2020
SWIFT_TYPEID(BodyInitKind)
2121
SWIFT_TYPEID(BodyInitKindAndExpr)
2222
SWIFT_TYPEID(CtorInitializerKind)
23-
SWIFT_TYPEID(FunctionBuilderBodyPreCheck)
23+
SWIFT_TYPEID(ResultBuilderBodyPreCheck)
2424
SWIFT_TYPEID(GenericSignature)
2525
SWIFT_TYPEID(ImplicitImportList)
2626
SWIFT_TYPEID(ImplicitMemberAction)

include/swift/AST/ASTTypeIDs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CustomAttr;
3535
class Decl;
3636
class EnumDecl;
3737
class FuncDecl;
38-
enum class FunctionBuilderBodyPreCheck : uint8_t;
38+
enum class ResultBuilderBodyPreCheck : uint8_t;
3939
class GenericParamList;
4040
class GenericSignature;
4141
class GenericTypeParamType;

include/swift/AST/Attr.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ SIMPLE_DECL_ATTR(_disfavoredOverload, DisfavoredOverload,
493493
OnAbstractFunction | OnVar | OnSubscript | UserInaccessible |
494494
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
495495
87)
496-
SIMPLE_DECL_ATTR(_functionBuilder, FunctionBuilder,
497-
OnNominalType | UserInaccessible |
496+
SIMPLE_DECL_ATTR(resultBuilder, ResultBuilder,
497+
OnNominalType |
498498
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
499499
88)
500500
DECL_ATTR(_projectedValueProperty, ProjectedValueProperty,

include/swift/AST/Decl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,12 +2402,12 @@ class ValueDecl : public Decl {
24022402
OpaqueReturnTypeRepr *getOpaqueResultTypeRepr() const;
24032403

24042404
/// Retrieve the attribute associating this declaration with a
2405-
/// function builder, if there is one.
2406-
CustomAttr *getAttachedFunctionBuilder() const;
2405+
/// result builder, if there is one.
2406+
CustomAttr *getAttachedResultBuilder() const;
24072407

2408-
/// Retrieve the @functionBuilder type attached to this declaration,
2408+
/// Retrieve the @resultBuilder type attached to this declaration,
24092409
/// if there is one.
2410-
Type getFunctionBuilderType() const;
2410+
Type getResultBuilderType() const;
24112411

24122412
/// If this value or its backing storage is annotated
24132413
/// @_dynamicReplacement(for: ...), compute the original declaration

include/swift/AST/DiagnosticsSema.def

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5352,83 +5352,83 @@ ERROR(property_wrapper_missing_arg_init, none, "missing argument for parameter "
53525352
"arguments in '@%1(...)'", (Identifier, StringRef))
53535353

53545354
//------------------------------------------------------------------------------
5355-
// MARK: function builder diagnostics
5355+
// MARK: result builder diagnostics
53565356
//------------------------------------------------------------------------------
5357-
ERROR(function_builder_decl, none,
5358-
"closure containing a declaration cannot be used with function "
5357+
ERROR(result_builder_decl, none,
5358+
"closure containing a declaration cannot be used with result "
53595359
"builder %0", (DeclName))
5360-
NOTE(note_function_builder_decl, none,
5361-
"closure containing a declaration cannot be used with function "
5360+
NOTE(note_result_builder_decl, none,
5361+
"closure containing a declaration cannot be used with result "
53625362
"builder %0", (DeclName))
5363-
ERROR(function_builder_control_flow, none,
5364-
"closure containing control flow statement cannot be used with function "
5363+
ERROR(result_builder_control_flow, none,
5364+
"closure containing control flow statement cannot be used with result "
53655365
"builder %0", (DeclName))
5366-
NOTE(note_function_builder_control_flow, none,
5367-
"closure containing control flow statement cannot be used with function "
5366+
NOTE(note_result_builder_control_flow, none,
5367+
"closure containing control flow statement cannot be used with result "
53685368
"builder %0", (DeclName))
5369-
ERROR(function_builder_attribute_not_allowed_here, none,
5370-
"function builder attribute %0 can only be applied to a parameter, "
5369+
ERROR(result_builder_attribute_not_allowed_here, none,
5370+
"result builder attribute %0 can only be applied to a parameter, "
53715371
"function, or computed property", (Identifier))
5372-
ERROR(function_builder_attribute_on_storage_without_getter, none,
5373-
"function builder attribute %0 can only be applied to a "
5372+
ERROR(result_builder_attribute_on_storage_without_getter, none,
5373+
"result builder attribute %0 can only be applied to a "
53745374
"%select{subscript|property|constant|variable}1 if it defines a getter",
53755375
(DeclName, unsigned))
5376-
ERROR(function_builder_parameter_not_of_function_type, none,
5377-
"function builder attribute %0 can only be applied to a parameter of "
5376+
ERROR(result_builder_parameter_not_of_function_type, none,
5377+
"result builder attribute %0 can only be applied to a parameter of "
53785378
"function type",
53795379
(Identifier))
5380-
ERROR(function_builder_parameter_autoclosure, none,
5381-
"function builder attribute %0 cannot be applied to an autoclosure "
5380+
ERROR(result_builder_parameter_autoclosure, none,
5381+
"result builder attribute %0 cannot be applied to an autoclosure "
53825382
"parameter",
53835383
(Identifier))
5384-
ERROR(function_builder_multiple, none,
5385-
"only one function builder attribute can be attached to a "
5384+
ERROR(result_builder_multiple, none,
5385+
"only one result builder attribute can be attached to a "
53865386
"%select{declaration|parameter}0", (bool))
5387-
NOTE(previous_function_builder_here, none,
5388-
"previous function builder specified here", ())
5389-
ERROR(function_builder_arguments, none,
5390-
"function builder attributes cannot have arguments", ())
5391-
WARNING(function_builder_disabled_by_return, none,
5392-
"application of function builder %0 disabled by explicit 'return' "
5387+
NOTE(previous_result_builder_here, none,
5388+
"previous result builder specified here", ())
5389+
ERROR(result_builder_arguments, none,
5390+
"result builder attributes cannot have arguments", ())
5391+
WARNING(result_builder_disabled_by_return, none,
5392+
"application of result builder %0 disabled by explicit 'return' "
53935393
"statement", (Type))
5394-
NOTE(function_builder_remove_attr, none,
5395-
"remove the attribute to explicitly disable the function builder", ())
5396-
NOTE(function_builder_remove_returns, none,
5397-
"remove 'return' statements to apply the function builder", ())
5398-
ERROR(function_builder_infer_ambig, none,
5399-
"ambiguous function builder inferred for %0: %1 or %2",
5394+
NOTE(result_builder_remove_attr, none,
5395+
"remove the attribute to explicitly disable the result builder", ())
5396+
NOTE(result_builder_remove_returns, none,
5397+
"remove 'return' statements to apply the result builder", ())
5398+
ERROR(result_builder_infer_ambig, none,
5399+
"ambiguous result builder inferred for %0: %1 or %2",
54005400
(DeclName, Type, Type))
5401-
NOTE(function_builder_infer_add_return, none,
5402-
"add an explicit 'return' statement to not use a function builder", ())
5403-
NOTE(function_builder_infer_pick_specific, none,
5404-
"apply function builder %0 (inferred from %select{protocol|dynamic replacement of}1 %2)",
5401+
NOTE(result_builder_infer_add_return, none,
5402+
"add an explicit 'return' statement to not use a result builder", ())
5403+
NOTE(result_builder_infer_pick_specific, none,
5404+
"apply result builder %0 (inferred from %select{protocol|dynamic replacement of}1 %2)",
54055405
(Type, unsigned, DeclName))
5406-
WARNING(function_builder_missing_limited_availability, none,
5407-
"function builder %0 does not implement 'buildLimitedAvailability'; "
5406+
WARNING(result_builder_missing_limited_availability, none,
5407+
"result builder %0 does not implement 'buildLimitedAvailability'; "
54085408
"this code may crash on earlier versions of the OS",
54095409
(Type))
5410-
ERROR(function_builder_static_buildblock, none,
5411-
"function builder must provide at least one static 'buildBlock' "
5410+
ERROR(result_builder_static_buildblock, none,
5411+
"result builder must provide at least one static 'buildBlock' "
54125412
"method", ())
5413-
NOTE(function_builder_non_static_buildblock, none,
5413+
NOTE(result_builder_non_static_buildblock, none,
54145414
"did you mean to make instance method 'buildBlock' static?", ())
5415-
NOTE(function_builder_buildblock_enum_case, none,
5416-
"enum case 'buildBlock' cannot be used to satisfy the function builder "
5415+
NOTE(result_builder_buildblock_enum_case, none,
5416+
"enum case 'buildBlock' cannot be used to satisfy the result builder "
54175417
"requirement", ())
5418-
NOTE(function_builder_buildblock_not_static_method, none,
5418+
NOTE(result_builder_buildblock_not_static_method, none,
54195419
"potential match 'buildBlock' is not a static method", ())
54205420

5421-
NOTE(function_builder_missing_build_optional, none,
5422-
"add 'buildOptional(_:)' to the function builder %0 to add support for "
5421+
NOTE(result_builder_missing_build_optional, none,
5422+
"add 'buildOptional(_:)' to the result builder %0 to add support for "
54235423
"'if' statements without an 'else'", (Type))
5424-
NOTE(function_builder_missing_build_either, none,
5425-
"add 'buildEither(first:)' and 'buildEither(second:)' to the function "
5424+
NOTE(result_builder_missing_build_either, none,
5425+
"add 'buildEither(first:)' and 'buildEither(second:)' to the result "
54265426
"builder %0 to add support for 'if'-'else' and 'switch'", (Type))
5427-
NOTE(function_builder_missing_build_array, none,
5428-
"add 'buildArray(_:)' to the function builder %0 to add support for "
5427+
NOTE(result_builder_missing_build_array, none,
5428+
"add 'buildArray(_:)' to the result builder %0 to add support for "
54295429
"'for'..'in' loops", (Type))
5430-
NOTE(function_builder_missing_build_limited_availability, none,
5431-
"add 'buildLimitedAvailability(_:)' to the function "
5430+
NOTE(result_builder_missing_build_limited_availability, none,
5431+
"add 'buildLimitedAvailability(_:)' to the result "
54325432
"builder %0 to erase type information for less-available types", (Type))
54335433

54345434
//------------------------------------------------------------------------------

include/swift/AST/EducationalNotes.def

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ EDUCATIONAL_NOTES(type_cannot_conform, "protocol-type-non-conformance.md")
8181
EDUCATIONAL_NOTES(unlabeled_trailing_closure_deprecated,
8282
"trailing-closure-matching.md")
8383

84-
EDUCATIONAL_NOTES(function_builder_static_buildblock,
85-
"function-builder-methods.md")
86-
EDUCATIONAL_NOTES(function_builder_missing_limited_availability,
87-
"function-builder-methods.md")
88-
EDUCATIONAL_NOTES(function_builder_missing_build_optional,
89-
"function-builder-methods.md")
90-
EDUCATIONAL_NOTES(function_builder_missing_build_either,
91-
"function-builder-methods.md")
92-
EDUCATIONAL_NOTES(function_builder_missing_build_array,
93-
"function-builder-methods.md")
84+
EDUCATIONAL_NOTES(result_builder_static_buildblock,
85+
"result-builder-methods.md")
86+
EDUCATIONAL_NOTES(result_builder_missing_limited_availability,
87+
"result-builder-methods.md")
88+
EDUCATIONAL_NOTES(result_builder_missing_build_optional,
89+
"result-builder-methods.md")
90+
EDUCATIONAL_NOTES(result_builder_missing_build_either,
91+
"result-builder-methods.md")
92+
EDUCATIONAL_NOTES(result_builder_missing_build_array,
93+
"result-builder-methods.md")
9494

9595
#undef EDUCATIONAL_NOTES

include/swift/AST/Expr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3695,7 +3695,7 @@ class ClosureExpr : public AbstractClosureExpr {
36953695
ReadyForTypeChecking,
36963696

36973697
/// The body was typechecked with the enclosing closure.
3698-
/// i.e. single expression closure or function builder closure.
3698+
/// i.e. single expression closure or result builder closure.
36993699
TypeCheckedWithSignature,
37003700

37013701
/// The body was type checked separately from the enclosing closure.

include/swift/AST/TypeCheckRequests.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -735,10 +735,10 @@ void simple_display(llvm::raw_ostream &out, FragileFunctionKind value);
735735

736736
void simple_display(llvm::raw_ostream &out, ResilienceExpansion value);
737737

738-
/// Request the custom attribute which attaches a function builder to the
738+
/// Request the custom attribute which attaches a result builder to the
739739
/// given declaration.
740-
class AttachedFunctionBuilderRequest :
741-
public SimpleRequest<AttachedFunctionBuilderRequest,
740+
class AttachedResultBuilderRequest :
741+
public SimpleRequest<AttachedResultBuilderRequest,
742742
CustomAttr *(ValueDecl *),
743743
RequestFlags::Cached> {
744744
public:
@@ -756,10 +756,10 @@ class AttachedFunctionBuilderRequest :
756756
bool isCached() const;
757757
};
758758

759-
/// Request the function builder type attached to the given declaration,
759+
/// Request the result builder type attached to the given declaration,
760760
/// if any.
761-
class FunctionBuilderTypeRequest :
762-
public SimpleRequest<FunctionBuilderTypeRequest,
761+
class ResultBuilderTypeRequest :
762+
public SimpleRequest<ResultBuilderTypeRequest,
763763
Type(ValueDecl *),
764764
RequestFlags::Cached> {
765765
public:
@@ -1960,7 +1960,7 @@ class ValueWitnessRequest
19601960
void cacheResult(Witness value) const;
19611961
};
19621962

1963-
struct PreCheckFunctionBuilderDescriptor {
1963+
struct PreCheckResultBuilderDescriptor {
19641964
AnyFunctionRef Fn;
19651965
bool SuppressDiagnostics;
19661966

@@ -1972,35 +1972,35 @@ struct PreCheckFunctionBuilderDescriptor {
19721972
BraceStmt *Body;
19731973

19741974
public:
1975-
PreCheckFunctionBuilderDescriptor(AnyFunctionRef Fn, bool suppressDiagnostics)
1975+
PreCheckResultBuilderDescriptor(AnyFunctionRef Fn, bool suppressDiagnostics)
19761976
: Fn(Fn), SuppressDiagnostics(suppressDiagnostics), Body(Fn.getBody()) {}
19771977

19781978
friend llvm::hash_code
1979-
hash_value(const PreCheckFunctionBuilderDescriptor &owner) {
1979+
hash_value(const PreCheckResultBuilderDescriptor &owner) {
19801980
return llvm::hash_combine(owner.Fn, owner.Body);
19811981
}
19821982

1983-
friend bool operator==(const PreCheckFunctionBuilderDescriptor &lhs,
1984-
const PreCheckFunctionBuilderDescriptor &rhs) {
1983+
friend bool operator==(const PreCheckResultBuilderDescriptor &lhs,
1984+
const PreCheckResultBuilderDescriptor &rhs) {
19851985
return lhs.Fn == rhs.Fn && lhs.Body == rhs.Body;
19861986
}
19871987

1988-
friend bool operator!=(const PreCheckFunctionBuilderDescriptor &lhs,
1989-
const PreCheckFunctionBuilderDescriptor &rhs) {
1988+
friend bool operator!=(const PreCheckResultBuilderDescriptor &lhs,
1989+
const PreCheckResultBuilderDescriptor &rhs) {
19901990
return !(lhs == rhs);
19911991
}
19921992

1993-
friend SourceLoc extractNearestSourceLoc(PreCheckFunctionBuilderDescriptor d) {
1993+
friend SourceLoc extractNearestSourceLoc(PreCheckResultBuilderDescriptor d) {
19941994
return extractNearestSourceLoc(d.Fn);
19951995
}
19961996

19971997
friend void simple_display(llvm::raw_ostream &out,
1998-
const PreCheckFunctionBuilderDescriptor &d) {
1998+
const PreCheckResultBuilderDescriptor &d) {
19991999
simple_display(out, d.Fn);
20002000
}
20012001
};
20022002

2003-
enum class FunctionBuilderBodyPreCheck : uint8_t {
2003+
enum class ResultBuilderBodyPreCheck : uint8_t {
20042004
/// There were no problems pre-checking the closure.
20052005
Okay,
20062006

@@ -2011,10 +2011,10 @@ enum class FunctionBuilderBodyPreCheck : uint8_t {
20112011
HasReturnStmt,
20122012
};
20132013

2014-
class PreCheckFunctionBuilderRequest
2015-
: public SimpleRequest<PreCheckFunctionBuilderRequest,
2016-
FunctionBuilderBodyPreCheck(
2017-
PreCheckFunctionBuilderDescriptor),
2014+
class PreCheckResultBuilderRequest
2015+
: public SimpleRequest<PreCheckResultBuilderRequest,
2016+
ResultBuilderBodyPreCheck(
2017+
PreCheckResultBuilderDescriptor),
20182018
RequestFlags::Cached> {
20192019
public:
20202020
using SimpleRequest::SimpleRequest;
@@ -2023,8 +2023,8 @@ class PreCheckFunctionBuilderRequest
20232023
friend SimpleRequest;
20242024

20252025
// Evaluation.
2026-
FunctionBuilderBodyPreCheck
2027-
evaluate(Evaluator &evaluator, PreCheckFunctionBuilderDescriptor owner) const;
2026+
ResultBuilderBodyPreCheck
2027+
evaluate(Evaluator &evaluator, PreCheckResultBuilderDescriptor owner) const;
20282028

20292029
public:
20302030
// Separate caching.
@@ -2759,7 +2759,7 @@ AnyValue::Holder<GenericSignature>::equals(const HolderBase &other) const {
27592759
void simple_display(llvm::raw_ostream &out, Type value);
27602760
void simple_display(llvm::raw_ostream &out, const TypeRepr *TyR);
27612761
void simple_display(llvm::raw_ostream &out, ImplicitMemberAction action);
2762-
void simple_display(llvm::raw_ostream &out, FunctionBuilderBodyPreCheck pck);
2762+
void simple_display(llvm::raw_ostream &out, ResultBuilderBodyPreCheck pck);
27632763

27642764
#define SWIFT_TYPEID_ZONE TypeChecker
27652765
#define SWIFT_TYPEID_HEADER "swift/AST/TypeCheckerTypeIDZone.def"

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SWIFT_REQUEST(TypeChecker, AbstractGenericSignatureRequest,
2020
SmallVector<GenericTypeParamType *, 2>,
2121
SmallVector<Requirement, 2>),
2222
Cached, NoLocationInfo)
23-
SWIFT_REQUEST(TypeChecker, AttachedFunctionBuilderRequest,
23+
SWIFT_REQUEST(TypeChecker, AttachedResultBuilderRequest,
2424
CustomAttr *(ValueDecl *), Cached, NoLocationInfo)
2525
SWIFT_REQUEST(TypeChecker, AttachedPropertyWrapperTypeRequest,
2626
Type(VarDecl *, unsigned), Cached, NoLocationInfo)
@@ -81,7 +81,7 @@ SWIFT_REQUEST(TypeChecker, ExistentialTypeSupportedRequest,
8181
bool(ProtocolDecl *), SeparatelyCached, NoLocationInfo)
8282
SWIFT_REQUEST(TypeChecker, ExtendedTypeRequest, Type(ExtensionDecl *), Cached,
8383
NoLocationInfo)
84-
SWIFT_REQUEST(TypeChecker, FunctionBuilderTypeRequest, Type(ValueDecl *),
84+
SWIFT_REQUEST(TypeChecker, ResultBuilderTypeRequest, Type(ValueDecl *),
8585
Cached, NoLocationInfo)
8686
SWIFT_REQUEST(TypeChecker, IsAsyncHandlerRequest, bool(FuncDecl *),
8787
Cached, NoLocationInfo)
@@ -249,8 +249,8 @@ SWIFT_REQUEST(TypeChecker, HasUserDefinedDesignatedInitRequest,
249249
bool(NominalTypeDecl *), Cached, NoLocationInfo)
250250
SWIFT_REQUEST(TypeChecker, HasMemberwiseInitRequest,
251251
bool(StructDecl *), Cached, NoLocationInfo)
252-
SWIFT_REQUEST(TypeChecker, PreCheckFunctionBuilderRequest,
253-
FunctionBuilderClosurePreCheck(PreCheckFunctionBuilderDescriptor),
252+
SWIFT_REQUEST(TypeChecker, PreCheckResultBuilderRequest,
253+
ResultBuilderBodyPreCheck(PreCheckResultBuilderDescriptor),
254254
Cached, NoLocationInfo)
255255
SWIFT_REQUEST(TypeChecker, ResolveImplicitMemberRequest,
256256
evaluator::SideEffect(NominalTypeDecl *, ImplicitMemberAction),

0 commit comments

Comments
 (0)