Skip to content

Commit 5404469

Browse files
authored
Merge pull request #3901 from swiftwasm/maxd/main-merge
Resolve conflicts with upstream `main`
2 parents 6ddb247 + f8e5d94 commit 5404469

File tree

65 files changed

+802
-312
lines changed

Some content is hidden

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

65 files changed

+802
-312
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,9 +1094,6 @@ if(SWIFT_ENABLE_DISPATCH)
10941094
include(Libdispatch)
10951095
endif()
10961096

1097-
add_bootstrapping_target(0)
1098-
add_bootstrapping_target(1)
1099-
11001097
# Add all of the subdirectories, where we actually do work.
11011098

11021099
###############

cmake/modules/AddSwift.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ function(add_libswift name)
781781
"-parse-as-library" ${sources}
782782
"-wmo" ${libswift_compile_options}
783783
"-I" "${SWIFT_SOURCE_DIR}/include/swift"
784+
"-I" "${SWIFT_SOURCE_DIR}/include"
784785
"-I" "${build_dir}"
785786
COMMENT "Building libswift module ${module}")
786787
@@ -975,13 +976,15 @@ function(add_swift_host_tool executable)
975976
INSTALL_RPATH "${RPATH_LIST}")
976977
977978
elseif(SWIFT_HOST_VARIANT_SDK STREQUAL "LINUX" AND ASHT_HAS_LIBSWIFT AND LIBSWIFT_BUILD_MODE)
979+
set(swiftrt "swiftImageRegistrationObject${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_OBJECT_FORMAT}-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}")
978980
if(LIBSWIFT_BUILD_MODE STREQUAL "HOSTTOOLS")
979981
# At build time and and run time, link against the swift libraries in the
980982
# installed host toolchain.
981983
get_filename_component(swift_bin_dir ${SWIFT_EXEC_FOR_LIBSWIFT} DIRECTORY)
982984
get_filename_component(swift_dir ${swift_bin_dir} DIRECTORY)
983985
set(host_lib_dir "${swift_dir}/lib/swift/linux")
984986
987+
target_link_libraries(${executable} PRIVATE ${swiftrt})
985988
target_link_libraries(${executable} PRIVATE "swiftCore")
986989
987990
target_link_directories(${executable} PRIVATE ${host_lib_dir})
@@ -995,6 +998,7 @@ function(add_swift_host_tool executable)
995998
if (NOT "${ASHT_BOOTSTRAPPING}" STREQUAL "0")
996999
get_bootstrapping_swift_lib_dir(bs_lib_dir "${ASHT_BOOTSTRAPPING}")
9971000
target_link_directories(${executable} PRIVATE ${bs_lib_dir})
1001+
target_link_libraries(${executable} PRIVATE ${swiftrt})
9981002
target_link_libraries(${executable} PRIVATE "swiftCore")
9991003
endif()
10001004

cmake/modules/SwiftUtils.cmake

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -111,35 +111,6 @@ function(get_bootstrapping_swift_lib_dir bs_lib_dir bootstrapping)
111111
set(bs_lib_dir ${bs_lib_dir} PARENT_SCOPE)
112112
endfunction()
113113

114-
function(add_bootstrapping_target bootstrapping)
115-
if(${LIBSWIFT_BUILD_MODE} MATCHES "BOOTSTRAPPING.*")
116-
117-
set(target "bootstrapping${bootstrapping}-all")
118-
add_custom_target(${target})
119-
120-
if(${LIBSWIFT_BUILD_MODE} STREQUAL "BOOTSTRAPPING")
121-
set(lib_target "bootstrapping${bootstrapping}-corelib")
122-
add_custom_target(${lib_target})
123-
add_dependencies(${target} ${lib_target})
124-
endif()
125-
126-
if(SWIFT_PATH_TO_LIBICU_BUILD)
127-
# Need to symlink the libicu libraries to be able to run
128-
# the bootstrapping compiler with a custom library path.
129-
get_bootstrapping_path(output_dir
130-
"${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}" "${bootstrapping}")
131-
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
132-
message("TODO: support for copying ICU libraries on Windows")
133-
endif()
134-
add_custom_command(TARGET "${target}" POST_BUILD
135-
COMMAND
136-
"ln" "-s" "-f" "${SWIFT_PATH_TO_LIBICU_BUILD}/lib/libicu*" "."
137-
WORKING_DIRECTORY "${output_dir}"
138-
COMMENT "symlink ICU libraries for bootstrapping stage ${bootstrapping}")
139-
endif()
140-
endif()
141-
endfunction()
142-
143114
function(is_build_type_optimized build_type result_var_name)
144115
if("${build_type}" STREQUAL "Debug")
145116
set("${result_var_name}" FALSE PARENT_SCOPE)

include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(async, Async,
605605
106)
606606

607607
SIMPLE_DECL_ATTR(Sendable, Sendable,
608-
OnFunc | OnConstructor | OnAccessor |
608+
OnFunc | OnConstructor | OnAccessor | OnAnyClangDecl |
609609
ABIBreakingToAdd | ABIBreakingToRemove |
610610
APIBreakingToAdd | APIBreakingToRemove,
611611
107)

include/swift/AST/Attr.h

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ class DeclAttribute : public AttributeBase {
168168
);
169169

170170
SWIFT_INLINE_BITFIELD(SynthesizedProtocolAttr, DeclAttribute,
171-
NumKnownProtocolKindBits,
172-
kind : NumKnownProtocolKindBits
171+
NumKnownProtocolKindBits+1,
172+
kind : NumKnownProtocolKindBits,
173+
isUnchecked : 1
173174
);
174175
} Bits;
175176

@@ -288,6 +289,9 @@ class DeclAttribute : public AttributeBase {
288289

289290
/// Whether this attribute is only valid when distributed is enabled.
290291
DistributedOnly = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 17),
292+
293+
/// Whether this attribute is valid on additional decls in ClangImporter.
294+
OnAnyClangDecl = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 18),
291295
};
292296

293297
LLVM_READNONE
@@ -1276,11 +1280,13 @@ class SynthesizedProtocolAttr : public DeclAttribute {
12761280

12771281
public:
12781282
SynthesizedProtocolAttr(KnownProtocolKind protocolKind,
1279-
LazyConformanceLoader *Loader)
1283+
LazyConformanceLoader *Loader,
1284+
bool isUnchecked)
12801285
: DeclAttribute(DAK_SynthesizedProtocol, SourceLoc(), SourceRange(),
12811286
/*Implicit=*/true), Loader(Loader)
12821287
{
12831288
Bits.SynthesizedProtocolAttr.kind = unsigned(protocolKind);
1289+
Bits.SynthesizedProtocolAttr.isUnchecked = unsigned(isUnchecked);
12841290
}
12851291

12861292
/// Retrieve the known protocol kind naming the protocol to be
@@ -1289,6 +1295,10 @@ class SynthesizedProtocolAttr : public DeclAttribute {
12891295
return KnownProtocolKind(Bits.SynthesizedProtocolAttr.kind);
12901296
}
12911297

1298+
bool isUnchecked() const {
1299+
return bool(Bits.SynthesizedProtocolAttr.isUnchecked);
1300+
}
1301+
12921302
/// Retrieve the lazy loader that will be used to populate the
12931303
/// synthesized conformance.
12941304
LazyConformanceLoader *getLazyLoader() const { return Loader; }
@@ -2217,6 +2227,15 @@ class DeclAttributes {
22172227
return nullptr;
22182228
}
22192229

2230+
/// Returns the "winning" \c NonSendableAttr or \c SendableAttr in this
2231+
/// attribute list, or \c nullptr if there are none.
2232+
const DeclAttribute *getEffectiveSendableAttr() const;
2233+
2234+
DeclAttribute *getEffectiveSendableAttr() {
2235+
return const_cast<DeclAttribute *>(
2236+
const_cast<const DeclAttributes *>(this)->getEffectiveSendableAttr());
2237+
}
2238+
22202239
private:
22212240
/// Predicate used to filter MatchingAttributeRange.
22222241
template <typename ATTR, bool AllowInvalid> struct ToAttributeKind {

include/swift/AST/Builtins.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,9 @@ BUILTIN_MISC_OPERATION(InitializeDistributedRemoteActor,
770770
BUILTIN_MISC_OPERATION(ResumeNonThrowingContinuationReturning,
771771
"resumeNonThrowingContinuationReturning", "", Special)
772772

773+
/// targetOSVersionAtLeast has type (Builtin.Int32, Builtin.Int32, Builtin.Int32) -> Builtin.Int32
774+
BUILTIN_MISC_OPERATION(TargetOSVersionAtLeast, "targetOSVersionAtLeast", "n", Special)
775+
773776
/// Resume a throwing continuation normally with the given result.
774777
BUILTIN_MISC_OPERATION(ResumeThrowingContinuationReturning,
775778
"resumeThrowingContinuationReturning", "", Special)

include/swift/AST/DiagnosticsClangImporter.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ NOTE(unresolvable_clang_decl_is_a_framework_bug,none,
8585
WARNING(clang_swift_attr_unhandled,none,
8686
"Ignoring unknown Swift attribute or modifier '%0'", (StringRef))
8787

88+
WARNING(clang_error_code_must_be_sendable,none,
89+
"cannot make error code type '%0' non-sendable because Swift errors "
90+
"are always sendable", (StringRef))
91+
8892
WARNING(implicit_bridging_header_imported_from_module,none,
8993
"implicit import of bridging header '%0' via module %1 "
9094
"is deprecated and will be removed in a later version of Swift",

include/swift/AST/FileUnit.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
#include "swift/AST/RawComment.h"
1818
#include "swift/Basic/BasicSourceInfo.h"
1919

20+
#include "llvm/ADT/PointerIntPair.h"
21+
2022
namespace swift {
23+
class SynthesizedFileUnit;
24+
2125
/// A container for module-scope declarations that itself provides a scope; the
2226
/// smallest unit of code organization.
2327
///
@@ -33,19 +37,25 @@ class FileUnit : public DeclContext, public ASTAllocated<FileUnit> {
3337
friend class DirectOperatorLookupRequest;
3438
friend class DirectPrecedenceGroupLookupRequest;
3539

36-
// FIXME: Stick this in a PointerIntPair.
37-
const FileUnitKind Kind;
40+
// The pointer is FileUnit insted of SynthesizedFileUnit to break circularity.
41+
llvm::PointerIntPair<FileUnit *, 3, FileUnitKind> SynthesizedFileAndKind;
3842

3943
protected:
4044
FileUnit(FileUnitKind kind, ModuleDecl &M)
41-
: DeclContext(DeclContextKind::FileUnit, &M), Kind(kind) {
45+
: DeclContext(DeclContextKind::FileUnit, &M),
46+
SynthesizedFileAndKind(nullptr, kind) {
4247
}
4348

4449
public:
4550
FileUnitKind getKind() const {
46-
return Kind;
51+
return SynthesizedFileAndKind.getInt();
4752
}
4853

54+
/// Returns the synthesized file for this source file, if it exists.
55+
SynthesizedFileUnit *getSynthesizedFile() const;
56+
57+
SynthesizedFileUnit &getOrCreateSynthesizedFile();
58+
4959
/// Look up a (possibly overloaded) value set at top-level scope
5060
/// (but with the specified access path, which may come from an import decl)
5161
/// within this file.

include/swift/AST/Module.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,9 @@ class ModuleDecl
758758
/// The order of the results is not guaranteed to be meaningful.
759759
///
760760
/// This can differ from \c getTopLevelDecls, e.g. it returns decls from a
761-
/// shadowed clang module.
761+
/// shadowed clang module. It does not force synthesized top-level decls that
762+
/// should be printed to be added; use \c swift::getTopLevelDeclsForDisplay()
763+
/// for that.
762764
void getDisplayDecls(SmallVectorImpl<Decl*> &results) const;
763765

764766
using LinkLibraryCallback = llvm::function_ref<void(LinkLibrary)>;

include/swift/AST/PrintOptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ struct PrintOptions {
235235
/// Whether to print unavailable parts of the AST.
236236
bool SkipUnavailable = false;
237237

238+
/// Whether to print synthesized extensions created by '@_nonSendable', even
239+
/// if SkipImplicit or SkipUnavailable is set.
240+
bool AlwaysPrintNonSendableExtensions = true;
241+
238242
bool SkipSwiftPrivateClangDecls = false;
239243

240244
/// Whether to skip internal stdlib declarations.
@@ -667,6 +671,7 @@ struct PrintOptions {
667671
PO.ShouldQualifyNestedDeclarations = QualifyNestedDeclarations::TypesOnly;
668672
PO.PrintParameterSpecifiers = true;
669673
PO.SkipImplicit = true;
674+
PO.AlwaysPrintNonSendableExtensions = false;
670675
PO.AlwaysTryPrintParameterLabels = true;
671676
return PO;
672677
}

0 commit comments

Comments
 (0)