Skip to content

Commit a0c920c

Browse files
Merge pull request #4490 from swiftwasm/katei/merge-main-2022-04-29
Merge main 2022-04-29
2 parents 43f2c9e + deab2c1 commit a0c920c

File tree

87 files changed

+1681
-688
lines changed

Some content is hidden

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

87 files changed

+1681
-688
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ function(add_swift_host_tool executable)
709709
if(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
710710
# Add in the toolchain directory so we can grab compatibility libraries
711711
get_filename_component(TOOLCHAIN_BIN_DIR ${SWIFT_EXEC_FOR_SWIFT_MODULES} DIRECTORY)
712-
get_filename_component(TOOLCHAIN_LIB_DIR "${TOOLCHAIN_BIN_DIR}/../lib/swift/macosx" ABSOLUTE)
712+
get_filename_component(TOOLCHAIN_LIB_DIR "${TOOLCHAIN_BIN_DIR}/../lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}" ABSOLUTE)
713713
target_link_directories(${executable} PUBLIC ${TOOLCHAIN_LIB_DIR})
714714
715715
# Add the SDK directory for the host platform.

cmake/modules/Libdispatch.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ foreach(sdk ${DISPATCH_SDKS})
7474
set(SWIFT_LIBDISPATCH_COMPILER_TRIPLE_CMAKE_ARGS -DCMAKE_C_COMPILER_TARGET=${SWIFT_SDK_WINDOWS_ARCH_${arch}_TRIPLE};-DCMAKE_CXX_COMPILER_TARGET=${SWIFT_SDK_WINDOWS_ARCH_${arch}_TRIPLE})
7575
endif()
7676

77-
78-
if(NOT sdk STREQUAL ANDROID)
77+
if("${sdk}" STREQUAL "ANDROID")
78+
file(TO_CMAKE_PATH "${SWIFT_ANDROID_NDK_PATH}" _ANDROID_NDK)
79+
set(SWIFT_LIBDISPATCH_ANDROID_NDK -DCMAKE_ANDROID_NDK=${_ANDROID_NDK})
80+
else()
7981
set(SWIFT_LIBDISPATCH_SYSTEM_PROCESSOR -DCMAKE_SYSTEM_PROCESSOR=${arch})
8082
endif()
8183

@@ -100,7 +102,7 @@ foreach(sdk ${DISPATCH_SDKS})
100102
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
101103
-DCMAKE_SYSTEM_NAME=${SWIFT_SDK_${sdk}_NAME}
102104
${SWIFT_LIBDISPATCH_SYSTEM_PROCESSOR}
103-
"-DCMAKE_ANDROID_NDK=${SWIFT_ANDROID_NDK_PATH}"
105+
"${SWIFT_LIBDISPATCH_ANDROID_NDK}"
104106
-DCMAKE_ANDROID_ARCH_ABI=${SWIFT_SDK_ANDROID_ARCH_${arch}_ABI}
105107
-DCMAKE_ANDROID_API=${SWIFT_ANDROID_API_LEVEL}
106108
-DBUILD_SHARED_LIBS=YES

docs/RequirementMachine/RequirementMachine.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
%
1111
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1212

13-
\documentclass[headsepline,bibliography=totoc]{scrreport}
13+
\documentclass[headsepline,bibliography=totoc]{scrreprt}
1414

1515
\usepackage{imakeidx}
1616

include/swift/AST/DiagnosticsClangImporter.def

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ WARNING(import_multiple_mainactor_attr,none,
106106
"this attribute for global actor '%0' is invalid; the declaration already has attribute for global actor '%1'",
107107
(StringRef, StringRef))
108108

109+
WARNING(contradicting_mutation_attrs,none,
110+
"attribute 'nonmutating' is ignored when combined with attribute 'mutating'", ())
111+
112+
WARNING(nonmutating_without_const,none,
113+
"attribute 'nonmutating' has no effect on non-const method", ())
114+
115+
WARNING(nonmutating_without_mutable_fields,none,
116+
"attribute 'nonmutating' has no effect without any mutable fields", ())
117+
109118
ERROR(module_map_not_found, none, "module map file '%0' not found", (StringRef))
110119

111120
NOTE(macro_not_imported_unsupported_operator, none, "operator not supported in macro arithmetic", ())

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ namespace swift {
223223
/// Emit a remark after loading a module.
224224
bool EnableModuleLoadingRemarks = false;
225225

226-
/// Resolve main function as though it were called from an async context
227-
bool EnableAsyncMainResolution = false;
228-
229226
///
230227
/// Support for alternate usage modes
231228
///

include/swift/ClangImporter/ClangImporter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,8 @@ class ClangImporter final : public ClangModuleLoader {
516516

517517
bool isCXXMethodMutating(const clang::CXXMethodDecl *method) override;
518518

519+
bool isAnnotatedWith(const clang::CXXMethodDecl *method, StringRef attr);
520+
519521
/// Find the lookup table that corresponds to the given Clang module.
520522
///
521523
/// \param clangModule The module, or null to indicate that we're talking

include/swift/Option/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,6 @@ def pch_output_dir: Separate<["-"], "pch-output-dir">,
270270
Flags<[FrontendOption, HelpHidden, ArgumentIsPath]>,
271271
HelpText<"Directory to persist automatically created precompiled bridging headers">;
272272

273-
def async_main: Flag<["-"], "async-main">,
274-
Flags<[FrontendOption]>,
275-
HelpText<"Resolve main function as if it were called from an asynchronous context">;
276-
277273
// FIXME: Unhide this once it doesn't depend on an output file map.
278274
def incremental : Flag<["-"], "incremental">,
279275
Flags<[NoInteractiveOption, HelpHidden, DoesNotAffectIncrementalBuild]>,

include/swift/Runtime/Heap.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,72 @@
2020
#include <cstddef>
2121
#include <cstdint>
2222
#include <cstdlib>
23+
#include <new>
2324
#include <type_traits>
25+
#include <utility>
26+
27+
#include "swift/Runtime/Config.h"
2428

2529
#if defined(_WIN32)
2630
#include <malloc.h>
2731
#endif
2832

2933
namespace swift {
34+
// Allocate plain old memory. This is the generalized entry point
35+
// Never returns nil. The returned memory is uninitialized.
36+
//
37+
// An "alignment mask" is just the alignment (a power of 2) minus 1.
38+
SWIFT_RUNTIME_EXPORT
39+
void *swift_slowAlloc(size_t bytes, size_t alignMask);
40+
41+
// If the caller cannot promise to zero the object during destruction,
42+
// then call these corresponding APIs:
43+
SWIFT_RUNTIME_EXPORT
44+
void swift_slowDealloc(void *ptr, size_t bytes, size_t alignMask);
45+
46+
/// Allocate and construct an instance of type \c T.
47+
///
48+
/// \param args The arguments to pass to the constructor for \c T.
49+
///
50+
/// \returns A pointer to a new, fully constructed instance of \c T. This
51+
/// function never returns \c nullptr. The caller is responsible for
52+
/// eventually destroying the resulting object by passing it to
53+
/// \c swift_cxx_deleteObject().
54+
///
55+
/// This function avoids the use of the global \c operator \c new (which may be
56+
/// overridden by other code in a process) in favor of calling
57+
/// \c swift_slowAlloc() and constructing the new object with placement new.
58+
///
59+
/// This function is capable of returning well-aligned memory even on platforms
60+
/// that do not implement the C++17 "over-aligned new" feature.
61+
template <typename T, typename... Args>
62+
static inline T *swift_cxx_newObject(Args &&... args) {
63+
auto result = reinterpret_cast<T *>(swift_slowAlloc(sizeof(T),
64+
alignof(T) - 1));
65+
::new (result) T(std::forward<Args>(args)...);
66+
return result;
67+
}
68+
69+
/// Destruct and deallocate an instance of type \c T.
70+
///
71+
/// \param ptr A pointer to an instance of type \c T previously created with a
72+
/// call to \c swift_cxx_newObject().
73+
///
74+
/// This function avoids the use of the global \c operator \c delete (which may
75+
/// be overridden by other code in a process) in favor of directly calling the
76+
/// destructor for \a *ptr and then freeing its memory by calling
77+
/// \c swift_slowDealloc().
78+
///
79+
/// The effect of passing a pointer to this function that was \em not returned
80+
/// from \c swift_cxx_newObject() is undefined.
81+
template <typename T>
82+
static inline void swift_cxx_deleteObject(T *ptr) {
83+
if (ptr) {
84+
ptr->~T();
85+
swift_slowDealloc(ptr, sizeof(T), alignof(T) - 1);
86+
}
87+
}
88+
3089
namespace {
3190
// This is C++17 and newer, so we simply re-define it. Since the codebase is
3291
// C++14, assume that DR1558 is accounted for and that unused parameters in alias

include/swift/Runtime/HeapObject.h

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
#include <cstddef>
2121
#include <cstdint>
22-
#include <new>
23-
#include <utility>
2422
#include "swift/Runtime/Config.h"
2523

2624
#if SWIFT_OBJC_INTEROP
@@ -120,62 +118,6 @@ BoxPair swift_makeBoxUnique(OpaqueValue *buffer, Metadata const *type,
120118
SWIFT_RUNTIME_EXPORT
121119
HeapObject* swift_allocEmptyBox();
122120

123-
// Allocate plain old memory. This is the generalized entry point
124-
// Never returns nil. The returned memory is uninitialized.
125-
//
126-
// An "alignment mask" is just the alignment (a power of 2) minus 1.
127-
128-
SWIFT_RUNTIME_EXPORT
129-
void *swift_slowAlloc(size_t bytes, size_t alignMask);
130-
131-
// If the caller cannot promise to zero the object during destruction,
132-
// then call these corresponding APIs:
133-
SWIFT_RUNTIME_EXPORT
134-
void swift_slowDealloc(void *ptr, size_t bytes, size_t alignMask);
135-
136-
/// Allocate and construct an instance of type \c T.
137-
///
138-
/// \param args The arguments to pass to the constructor for \c T.
139-
///
140-
/// \returns A pointer to a new, fully constructed instance of \c T. This
141-
/// function never returns \c nullptr. The caller is responsible for
142-
/// eventually destroying the resulting object by passing it to
143-
/// \c swift_cxx_deleteObject().
144-
///
145-
/// This function avoids the use of the global \c operator \c new (which may be
146-
/// overridden by other code in a process) in favor of calling
147-
/// \c swift_slowAlloc() and constructing the new object with placement new.
148-
///
149-
/// This function is capable of returning well-aligned memory even on platforms
150-
/// that do not implement the C++17 "over-aligned new" feature.
151-
template <typename T, typename... Args>
152-
static inline T *swift_cxx_newObject(Args &&... args) {
153-
auto result = reinterpret_cast<T *>(swift_slowAlloc(sizeof(T),
154-
alignof(T) - 1));
155-
::new (result) T(std::forward<Args>(args)...);
156-
return result;
157-
}
158-
159-
/// Destruct and deallocate an instance of type \c T.
160-
///
161-
/// \param ptr A pointer to an instance of type \c T previously created with a
162-
/// call to \c swift_cxx_newObject().
163-
///
164-
/// This function avoids the use of the global \c operator \c delete (which may
165-
/// be overridden by other code in a process) in favor of directly calling the
166-
/// destructor for \a *ptr and then freeing its memory by calling
167-
/// \c swift_slowDealloc().
168-
///
169-
/// The effect of passing a pointer to this function that was \em not returned
170-
/// from \c swift_cxx_newObject() is undefined.
171-
template <typename T>
172-
static inline void swift_cxx_deleteObject(T *ptr) {
173-
if (ptr) {
174-
ptr->~T();
175-
swift_slowDealloc(ptr, sizeof(T), alignof(T) - 1);
176-
}
177-
}
178-
179121
/// Atomically increments the retain count of an object.
180122
///
181123
/// \param object - may be null, in which case this is a no-op

include/swift/Sema/Constraint.h

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,9 @@ enum class ConstraintKind : char {
209209
/// inferred from a conversion, so the check is more relax comparing to
210210
/// `ConformsTo`.
211211
TransitivelyConformsTo,
212-
/// Represents an AST node contained in a body of a closure. It has only
213-
/// one type - type variable representing type of a node, other side is
214-
/// the AST node to infer the type for.
215-
ClosureBodyElement,
212+
/// Represents an AST node contained in a body of a function/closure.
213+
/// It only has an AST node to generate constraints and infer the type for.
214+
SyntacticElement,
216215
/// Do not add new uses of this, it only exists to retain compatibility for
217216
/// rdar://85263844.
218217
///
@@ -240,8 +239,8 @@ enum class ConstraintClassification : char {
240239
/// A conjunction constraint.
241240
Conjunction,
242241

243-
/// An element of a closure body.
244-
ClosureElement,
242+
/// An element of a closure/function body.
243+
SyntacticElement,
245244
};
246245

247246
/// Specifies a restriction on the kind of conversion that should be
@@ -448,7 +447,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
448447
ContextualTypeInfo Context;
449448
/// Identifies whether result of this node is unused.
450449
bool IsDiscarded;
451-
} ClosureElement;
450+
} SyntacticElement;
452451
};
453452

454453
/// The locator that describes where in the expression this
@@ -589,12 +588,12 @@ class Constraint final : public llvm::ilist_node<Constraint>,
589588
Optional<TrailingClosureMatching> trailingClosureMatching,
590589
ConstraintLocator *locator);
591590

592-
static Constraint *createClosureBodyElement(ConstraintSystem &cs,
591+
static Constraint *createSyntacticElement(ConstraintSystem &cs,
593592
ASTNode node,
594593
ConstraintLocator *locator,
595594
bool isDiscarded = false);
596595

597-
static Constraint *createClosureBodyElement(ConstraintSystem &cs,
596+
static Constraint *createSyntacticElement(ConstraintSystem &cs,
598597
ASTNode node,
599598
ContextualTypeInfo context,
600599
ConstraintLocator *locator,
@@ -708,8 +707,8 @@ class Constraint final : public llvm::ilist_node<Constraint>,
708707
case ConstraintKind::Conjunction:
709708
return ConstraintClassification::Conjunction;
710709

711-
case ConstraintKind::ClosureBodyElement:
712-
return ConstraintClassification::ClosureElement;
710+
case ConstraintKind::SyntacticElement:
711+
return ConstraintClassification::SyntacticElement;
713712
}
714713

715714
llvm_unreachable("Unhandled ConstraintKind in switch.");
@@ -732,7 +731,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
732731
case ConstraintKind::ValueWitness:
733732
return Member.First;
734733

735-
case ConstraintKind::ClosureBodyElement:
734+
case ConstraintKind::SyntacticElement:
736735
llvm_unreachable("closure body element constraint has no type operands");
737736

738737
default:
@@ -746,7 +745,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
746745
case ConstraintKind::Disjunction:
747746
case ConstraintKind::Conjunction:
748747
case ConstraintKind::BindOverload:
749-
case ConstraintKind::ClosureBodyElement:
748+
case ConstraintKind::SyntacticElement:
750749
llvm_unreachable("constraint has no second type");
751750

752751
case ConstraintKind::ValueMember:
@@ -855,19 +854,19 @@ class Constraint final : public llvm::ilist_node<Constraint>,
855854
return Member.UseDC;
856855
}
857856

858-
ASTNode getClosureElement() const {
859-
assert(Kind == ConstraintKind::ClosureBodyElement);
860-
return ClosureElement.Element;
857+
ASTNode getSyntacticElement() const {
858+
assert(Kind == ConstraintKind::SyntacticElement);
859+
return SyntacticElement.Element;
861860
}
862861

863862
ContextualTypeInfo getElementContext() const {
864-
assert(Kind == ConstraintKind::ClosureBodyElement);
865-
return ClosureElement.Context;
863+
assert(Kind == ConstraintKind::SyntacticElement);
864+
return SyntacticElement.Context;
866865
}
867866

868867
bool isDiscardedElement() const {
869-
assert(Kind == ConstraintKind::ClosureBodyElement);
870-
return ClosureElement.IsDiscarded;
868+
assert(Kind == ConstraintKind::SyntacticElement);
869+
return SyntacticElement.IsDiscarded;
871870
}
872871

873872
/// For an applicable function constraint, retrieve the trailing closure

include/swift/Sema/ConstraintLocator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,11 +1012,11 @@ class LocatorPathElt::ConstructorMemberType final
10121012
}
10131013
};
10141014

1015-
class LocatorPathElt::ClosureBodyElement final
1015+
class LocatorPathElt::SyntacticElement final
10161016
: public StoredPointerElement<void> {
10171017
public:
1018-
ClosureBodyElement(ASTNode element)
1019-
: StoredPointerElement(PathElementKind::ClosureBodyElement,
1018+
SyntacticElement(ASTNode element)
1019+
: StoredPointerElement(PathElementKind::SyntacticElement,
10201020
element.getOpaqueValue()) {
10211021
assert(element);
10221022
}
@@ -1054,7 +1054,7 @@ class LocatorPathElt::ClosureBodyElement final
10541054
}
10551055

10561056
static bool classof(const LocatorPathElt *elt) {
1057-
return elt->getKind() == PathElementKind::ClosureBodyElement;
1057+
return elt->getKind() == PathElementKind::SyntacticElement;
10581058
}
10591059
};
10601060

include/swift/Sema/ConstraintLocatorPathElts.def

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,9 @@ CUSTOM_LOCATOR_PATH_ELT(ImplicitConversion)
229229
/// An implicit call to a 'dynamicMember' subscript for a dynamic member lookup.
230230
SIMPLE_LOCATOR_PATH_ELT(ImplicitDynamicMemberSubscript)
231231

232-
/// The element of the closure body e.g. statement, declaration, or expression.
233-
CUSTOM_LOCATOR_PATH_ELT(ClosureBodyElement)
232+
/// The element of the closure/function body e.g. statement, pattern,
233+
/// declaration, or expression.
234+
CUSTOM_LOCATOR_PATH_ELT(SyntacticElement)
234235

235236
/// The element of the pattern binding declaration.
236237
CUSTOM_LOCATOR_PATH_ELT(PatternBindingElement)

0 commit comments

Comments
 (0)