Skip to content

Commit 691cf19

Browse files
authored
Merge branch 'main' into ewilde/concurrency/unavailablefromasync-messages
2 parents 34fc8cd + a46a3c5 commit 691cf19

File tree

301 files changed

+8662
-3522
lines changed

Some content is hidden

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

301 files changed

+8662
-3522
lines changed

CMakeLists.txt

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,9 @@ set(SWIFT_DARWIN_PLATFORMS "IOS" "IOS_SIMULATOR" "TVOS" "TVOS_SIMULATOR" "WATCHO
669669
set(SWIFT_APPLE_PLATFORMS ${SWIFT_DARWIN_PLATFORMS})
670670
if(SWIFT_FREESTANDING_FLAVOR STREQUAL "apple")
671671
list(APPEND SWIFT_APPLE_PLATFORMS "FREESTANDING")
672+
if(SWIFT_FREESTANDING_IS_DARWIN)
673+
list(APPEND SWIFT_DARWIN_PLATFORMS "FREESTANDING")
674+
endif()
672675
endif()
673676

674677
# Configuration flags passed to all of our invocations of gyb. Try to
@@ -1026,37 +1029,6 @@ endif()
10261029
# Find required dependencies.
10271030
#
10281031

1029-
function(swift_icu_variables_set sdk arch result)
1030-
string(TOUPPER "${sdk}" sdk)
1031-
1032-
set(icu_var_ICU_UC_INCLUDE ${SWIFT_${sdk}_${arch}_ICU_UC_INCLUDE})
1033-
set(icu_var_ICU_UC ${SWIFT_${sdk}_${arch}_ICU_UC})
1034-
set(icu_var_ICU_I18N_INCLUDE ${SWIFT_${sdk}_${arch}_ICU_I18N_INCLUDE})
1035-
set(icu_var_ICU_I18N ${SWIFT_${sdk}_${arch}_ICU_I18N})
1036-
1037-
if(icu_var_ICU_UC_INCLUDE AND icu_var_ICU_UC AND
1038-
icu_var_ICU_I18N_INCLUDE AND icu_var_ICU_I18N)
1039-
set(${result} TRUE PARENT_SCOPE)
1040-
else()
1041-
set(${result} FALSE PARENT_SCOPE)
1042-
endif()
1043-
endfunction()
1044-
1045-
# ICU is provided through CoreFoundation on Darwin. On other hosts, if the ICU
1046-
# unicode and i18n include and library paths are not defined, perform a standard
1047-
# package lookup. Otherwise, rely on the paths specified by the user. These
1048-
# need to be defined when cross-compiling.
1049-
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
1050-
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
1051-
swift_icu_variables_set("${SWIFT_PRIMARY_VARIANT_SDK}"
1052-
"${SWIFT_PRIMARY_VARIANT_ARCH}"
1053-
ICU_CONFIGURED)
1054-
if("${SWIFT_PATH_TO_LIBICU_BUILD}" STREQUAL "" AND NOT ${ICU_CONFIGURED})
1055-
find_package(ICU REQUIRED COMPONENTS uc i18n)
1056-
endif()
1057-
endif()
1058-
endif()
1059-
10601032
find_package(Python3 COMPONENTS Interpreter REQUIRED)
10611033

10621034
#
@@ -1179,7 +1151,6 @@ endif()
11791151

11801152
if(SWIFT_INCLUDE_TESTS)
11811153
add_subdirectory(test)
1182-
add_subdirectory(validation-test)
11831154
add_subdirectory(unittests)
11841155
endif()
11851156
if(SWIFT_INCLUDE_DOCS)

cmake/modules/AddSwift.cmake

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ endfunction()
428428
# [SHARED]
429429
# [STATIC]
430430
# [OBJECT]
431-
# [PURE_SWIFT]
432431
# [LLVM_LINK_COMPONENTS comp1 ...]
433432
# source1 [source2 source3 ...])
434433
#
@@ -447,18 +446,13 @@ endfunction()
447446
# LLVM_LINK_COMPONENTS
448447
# LLVM components this library depends on.
449448
#
450-
# PURE_SWIFT
451-
# This has two effects if set: we do not use llvm_update_compile_flags to
452-
# generate cflags/etc and we leave the linking mode of the library as swift.
453-
#
454449
# source1 ...
455450
# Sources to add into this library.
456451
function(add_swift_host_library name)
457452
set(options
458453
SHARED
459454
STATIC
460-
OBJECT
461-
PURE_SWIFT)
455+
OBJECT)
462456
set(single_parameter_options)
463457
set(multiple_parameter_options
464458
LLVM_LINK_COMPONENTS)
@@ -521,9 +515,7 @@ function(add_swift_host_library name)
521515
if (LLVM_COMMON_DEPENDS)
522516
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
523517
endif()
524-
if (NOT ASHL_PURE_SWIFT)
525-
llvm_update_compile_flags(${name})
526-
endif()
518+
llvm_update_compile_flags(${name})
527519
swift_common_llvm_config(${name} ${ASHL_LLVM_LINK_COMPONENTS})
528520
set_output_directory(${name}
529521
BINARY_DIR ${SWIFT_RUNTIME_OUTPUT_INTDIR}
@@ -582,11 +574,7 @@ function(add_swift_host_library name)
582574
NO_SONAME YES)
583575
endif()
584576
585-
# Always link as CXX even if we have swift content unless we only contain
586-
# swift content signaled via us being marked "PURE_SWIFT".
587-
if (NOT ASHL_PURE_SWIFT)
588-
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
589-
endif()
577+
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
590578
591579
if(${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS)
592580
target_link_options(${name} PRIVATE
@@ -596,30 +584,6 @@ function(add_swift_host_library name)
596584
"LINKER:-current_version,${SWIFT_COMPILER_VERSION}")
597585
endif()
598586
599-
# If we found a swift compiler and are going to use swift code in swift
600-
# host side tools but link with clang, add the appropriate -L paths so we
601-
# find all of the necessary swift libraries on Darwin.
602-
if (NOT ASHL_PURE_SWIFT)
603-
if (CMAKE_Swift_COMPILER)
604-
# Add in the toolchain directory so we can grab compatibility libraries
605-
get_filename_component(TOOLCHAIN_BIN_DIR ${CMAKE_Swift_COMPILER} DIRECTORY)
606-
get_filename_component(TOOLCHAIN_LIB_DIR "${TOOLCHAIN_BIN_DIR}/../lib/swift/macosx" ABSOLUTE)
607-
target_link_directories(${name} PUBLIC ${TOOLCHAIN_LIB_DIR})
608-
609-
# Add in the SDK directory for the host platform.
610-
#
611-
# NOTE: We do this /after/ target_link_directorying TOOLCHAIN_LIB_DIR to
612-
# ensure that we first find libraries from the toolchain, rather than
613-
# from the SDK. The reason why this is important is that when we perform
614-
# a stage2 build, this path is into the stage1 build. This is not a pure
615-
# SDK and also contains compatibility libraries. We need to make sure
616-
# that the compiler sees the actual toolchain's compatibility libraries
617-
# first before the just built compability libraries or build errors occur.
618-
target_link_directories(${name} PRIVATE
619-
${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}/usr/lib/swift)
620-
endif()
621-
endif()
622-
623587
# For now turn off on Darwin swift targets, debug info if we are compiling a static
624588
# library and set up an rpath so that if someone works around this by using
625589
# shared libraries that in the short term we can find shared libraries.
@@ -945,25 +909,7 @@ function(add_swift_host_tool executable)
945909
set_property(TARGET ${executable} APPEND_STRING PROPERTY
946910
LINK_FLAGS " -lobjc ")
947911
948-
else() # ASHT_HAS_LIBSWIFT AND LIBSWIFT_BUILD_MODE
949-
950-
# TODO: do we really need this? Do any tools which don't link libswift include other swift code?
951-
952-
# Add in the SDK directory for the host platform.
953-
#
954-
# NOTE: We do this /after/ target_link_directorying TOOLCHAIN_LIB_DIR to
955-
# ensure that we first find libraries from the toolchain, rather than from
956-
# the SDK.
957-
target_link_directories(${executable} PRIVATE "${sdk_dir}")
958-
959-
# We also want to be able to find libraries from the base toolchain
960-
# directory. This is so swiftc can rely on its own host side dylibs that may
961-
# contain swift content.
962-
list(APPEND RPATH_LIST "@executable_path/../lib")
963-
964-
# Also include the abi stable system stdlib in our rpath.
965-
list(APPEND RPATH_LIST "/usr/lib/swift")
966-
endif()
912+
endif() # ASHT_HAS_LIBSWIFT AND LIBSWIFT_BUILD_MODE
967913
968914
set_target_properties(${executable} PROPERTIES
969915
BUILD_WITH_INSTALL_RPATH YES

cmake/modules/FindICU.cmake

Lines changed: 0 additions & 40 deletions
This file was deleted.

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ function(_report_sdk prefix)
6565
message(STATUS " ${arch} libc header path: ${SWIFT_SDK_${prefix}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}")
6666
message(STATUS " ${arch} libc architecture specific header path: ${SWIFT_SDK_${prefix}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY}")
6767
endforeach()
68-
if(SWIFT_BUILD_STDLIB)
69-
foreach(arch ${SWIFT_SDK_${prefix}_ARCHITECTURES})
70-
message(STATUS " ${arch} ICU i18n INCLUDE: ${SWIFT_${prefix}_${arch}_ICU_I18N_INCLUDE}")
71-
message(STATUS " ${arch} ICU i18n LIB: ${SWIFT_${prefix}_${arch}_ICU_I18N}")
72-
message(STATUS " ${arch} ICU unicode INCLUDE: ${SWIFT_${prefix}_${arch}_ICU_UC_INCLUDE}")
73-
message(STATUS " ${arch} ICU unicode LIB: ${SWIFT_${prefix}_${arch}_ICU_UC}")
74-
endforeach()
75-
endif()
7668
endif()
7769

7870
message(STATUS "")

include/swift/AST/ASTContext.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,15 @@ class ASTContext final {
273273
/// Diags - The diagnostics engine.
274274
DiagnosticEngine &Diags;
275275

276+
/// If the shared pointer is not a \c nullptr and the pointee is \c true,
277+
/// all operations working on this ASTContext should be aborted at the next
278+
/// possible opportunity.
279+
/// This is used by SourceKit to cancel requests for which the result is no
280+
/// longer of interest.
281+
/// The returned result will be discarded, so the operation that acknowledges
282+
/// the cancellation might return with any result.
283+
std::shared_ptr<std::atomic<bool>> CancellationFlag = nullptr;
284+
276285
TypeCheckCompletionCallback *CompletionCallback = nullptr;
277286

278287
/// The request-evaluator that is used to process various requests.

include/swift/AST/Decl.h

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "swift/AST/GenericParamKey.h"
2929
#include "swift/AST/IfConfigClause.h"
3030
#include "swift/AST/LayoutConstraint.h"
31+
#include "swift/AST/ReferenceCounting.h"
3132
#include "swift/AST/StorageImpl.h"
3233
#include "swift/AST/TypeAlignments.h"
3334
#include "swift/AST/TypeWalker.h"
@@ -37,10 +38,10 @@
3738
#include "swift/Basic/Compiler.h"
3839
#include "swift/Basic/Debug.h"
3940
#include "swift/Basic/InlineBitfield.h"
41+
#include "swift/Basic/Located.h"
4042
#include "swift/Basic/NullablePtr.h"
4143
#include "swift/Basic/OptionalEnum.h"
4244
#include "swift/Basic/Range.h"
43-
#include "swift/Basic/Located.h"
4445
#include "llvm/ADT/DenseSet.h"
4546
#include "llvm/Support/TrailingObjects.h"
4647
#include <type_traits>
@@ -3906,7 +3907,8 @@ class ClassDecl final : public NominalTypeDecl {
39063907
///
39073908
/// \see getForeignClassKind
39083909
bool isForeign() const {
3909-
return getForeignClassKind() != ForeignKind::Normal;
3910+
return getForeignClassKind() != ForeignKind::Normal ||
3911+
const_cast<ClassDecl *>(this)->isForeignReferenceType();
39103912
}
39113913

39123914
/// Whether the class is (known to be) a default actor.
@@ -3941,9 +3943,22 @@ class ClassDecl final : public NominalTypeDecl {
39413943
bool isNativeNSObjectSubclass() const;
39423944

39433945
/// Whether the class uses the ObjC object model (reference counting,
3944-
/// allocation, etc.) instead of the Swift model.
3945-
bool usesObjCObjectModel() const {
3946-
return checkAncestry(AncestryFlags::ObjCObjectModel);
3946+
/// allocation, etc.), the Swift model, or has no reference counting at all.
3947+
ReferenceCounting getObjectModel() {
3948+
if (isForeignReferenceType())
3949+
return ReferenceCounting::None;
3950+
3951+
if (checkAncestry(AncestryFlags::ObjCObjectModel))
3952+
return ReferenceCounting::ObjC;
3953+
3954+
return ReferenceCounting::Native;
3955+
}
3956+
3957+
LayoutConstraintKind getLayoutConstraintKind() {
3958+
if (getObjectModel() == ReferenceCounting::ObjC)
3959+
return LayoutConstraintKind::Class;
3960+
3961+
return LayoutConstraintKind::NativeClass;
39473962
}
39483963

39493964
/// Returns true if the class has designated initializers that are not listed
@@ -4065,6 +4080,11 @@ class ClassDecl final : public NominalTypeDecl {
40654080
bool hasKnownSwiftImplementation() const {
40664081
return !hasClangNode();
40674082
}
4083+
4084+
/// Used to determine if this class decl is a foriegn reference type. I.e., a
4085+
/// non-reference-counted swift reference type that was imported from a C++
4086+
/// record.
4087+
bool isForeignReferenceType();
40684088
};
40694089

40704090
/// A convenience wrapper around the \c SelfReferencePosition::Kind enum.

include/swift/AST/DiagnosticsIRGen.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,10 @@ ERROR(temporary_allocation_alignment_not_positive,none,
5959
ERROR(temporary_allocation_alignment_not_power_of_2,none,
6060
"alignment value must be a power of two", ())
6161

62+
ERROR(foreign_reference_types_unsupported,none,
63+
"attempt to use a foreign reference type in a generic context. "
64+
"Foreign reference types are currently not supported. Using foreign "
65+
"reference types in a generic context is not yet implemented.", ())
66+
6267
#define UNDEFINE_DIAGNOSTIC_MACROS
6368
#include "DefineDiagnosticMacros.h"

include/swift/AST/DiagnosticsParse.def

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ ERROR(forbidden_interpolated_string,none,
9191
ERROR(forbidden_extended_escaping_string,none,
9292
"%0 cannot be an extended escaping string literal", (StringRef))
9393

94+
ERROR(regex_literal_parsing_error,none,
95+
"%0", (StringRef))
96+
9497
//------------------------------------------------------------------------------
9598
// MARK: Lexer diagnostics
9699
//------------------------------------------------------------------------------
@@ -108,9 +111,6 @@ ERROR(lex_unprintable_ascii_character,none,
108111
ERROR(lex_invalid_utf8,none,
109112
"invalid UTF-8 found in source file", ())
110113

111-
NOTE(lex_experimental_regex_strawperson,none,
112-
"'%0'", (StringRef))
113-
114114
ERROR(lex_single_quote_string,none,
115115
"single-quoted string literal found, use '\"'", ())
116116
ERROR(lex_invalid_curly_quote,none,
@@ -140,6 +140,9 @@ ERROR(lex_invalid_escape_delimiter,none,
140140
ERROR(lex_invalid_closing_delimiter,none,
141141
"too many '#' characters in closing delimiter", ())
142142

143+
ERROR(lex_unterminated_regex,none,
144+
"unterminated regex literal", ())
145+
143146
ERROR(lex_invalid_unicode_scalar,none,
144147
"invalid unicode scalar", ())
145148
ERROR(lex_unicode_escape_braces,none,

include/swift/AST/DiagnosticsSIL.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ NOTE(sil_movekillscopyablevalue_use_here, none,
741741
NOTE(sil_movekillscopyablevalue_value_consumed_in_loop, none,
742742
"cyclic move here. move will occur multiple times in the loop", ())
743743
ERROR(sil_movekillscopyablevalue_move_applied_to_unsupported_move, none,
744-
"_move applied to value that the compiler does not supporting checking.",
744+
"_move applied to value that the compiler does not support checking",
745745
())
746746

747747
#define UNDEFINE_DIAGNOSTIC_MACROS

include/swift/AST/DiagnosticsSema.def

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3668,6 +3668,9 @@ ERROR(builtin_string_literal_broken_proto,none,
36683668
ERROR(string_literal_broken_proto,none,
36693669
"protocol 'ExpressibleByStringLiteral' is broken", ())
36703670

3671+
ERROR(regex_decl_broken,none,
3672+
"cannot find 'Regex' type in scope", ())
3673+
36713674
// Array literals
36723675
ERROR(should_use_dictionary_literal,none,
36733676
"dictionary of type %0 cannot be %select{used|initialized}1 "
@@ -4491,6 +4494,10 @@ ERROR(concurrent_access_of_local_capture,none,
44914494
"%select{mutation of|reference to}0 captured %1 %2 in "
44924495
"concurrently-executing code",
44934496
(bool, DescriptiveDeclKind, DeclName))
4497+
ERROR(non_sendable_capture,none,
4498+
"capture of %1 with non-sendable type %0 in a `@Sendable` closure",
4499+
(Type, DeclName))
4500+
44944501
NOTE(actor_isolated_sync_func,none,
44954502
"calls to %0 %1 from outside of its actor context are "
44964503
"implicitly asynchronous",

0 commit comments

Comments
 (0)