Skip to content

Commit 63cec2c

Browse files
authored
Merge pull request #3963 from swiftwasm/maxd/main-merge
Resolve conflicts with upstream `main`
2 parents 36d75ec + 51571ea commit 63cec2c

File tree

103 files changed

+2179
-1751
lines changed

Some content is hidden

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

103 files changed

+2179
-1751
lines changed

CMakeLists.txt

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,37 +1031,6 @@ endif()
10311031
# Find required dependencies.
10321032
#
10331033

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

10671036
#
@@ -1184,7 +1153,6 @@ endif()
11841153

11851154
if(SWIFT_INCLUDE_TESTS)
11861155
add_subdirectory(test)
1187-
add_subdirectory(validation-test)
11881156
add_subdirectory(unittests)
11891157
endif()
11901158
if(SWIFT_INCLUDE_DOCS)

cmake/modules/AddSwift.cmake

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ endfunction()
430430
# [SHARED]
431431
# [STATIC]
432432
# [OBJECT]
433-
# [PURE_SWIFT]
434433
# [LLVM_LINK_COMPONENTS comp1 ...]
435434
# source1 [source2 source3 ...])
436435
#
@@ -449,18 +448,13 @@ endfunction()
449448
# LLVM_LINK_COMPONENTS
450449
# LLVM components this library depends on.
451450
#
452-
# PURE_SWIFT
453-
# This has two effects if set: we do not use llvm_update_compile_flags to
454-
# generate cflags/etc and we leave the linking mode of the library as swift.
455-
#
456451
# source1 ...
457452
# Sources to add into this library.
458453
function(add_swift_host_library name)
459454
set(options
460455
SHARED
461456
STATIC
462-
OBJECT
463-
PURE_SWIFT)
457+
OBJECT)
464458
set(single_parameter_options)
465459
set(multiple_parameter_options
466460
LLVM_LINK_COMPONENTS)
@@ -523,9 +517,7 @@ function(add_swift_host_library name)
523517
if (LLVM_COMMON_DEPENDS)
524518
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
525519
endif()
526-
if (NOT ASHL_PURE_SWIFT)
527-
llvm_update_compile_flags(${name})
528-
endif()
520+
llvm_update_compile_flags(${name})
529521
swift_common_llvm_config(${name} ${ASHL_LLVM_LINK_COMPONENTS})
530522
set_output_directory(${name}
531523
BINARY_DIR ${SWIFT_RUNTIME_OUTPUT_INTDIR}
@@ -584,11 +576,7 @@ function(add_swift_host_library name)
584576
NO_SONAME YES)
585577
endif()
586578
587-
# Always link as CXX even if we have swift content unless we only contain
588-
# swift content signaled via us being marked "PURE_SWIFT".
589-
if (NOT ASHL_PURE_SWIFT)
590-
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
591-
endif()
579+
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
592580
593581
if(${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS)
594582
target_link_options(${name} PRIVATE
@@ -598,30 +586,6 @@ function(add_swift_host_library name)
598586
"LINKER:-current_version,${SWIFT_COMPILER_VERSION}")
599587
endif()
600588
601-
# If we found a swift compiler and are going to use swift code in swift
602-
# host side tools but link with clang, add the appropriate -L paths so we
603-
# find all of the necessary swift libraries on Darwin.
604-
if (NOT ASHL_PURE_SWIFT)
605-
if (CMAKE_Swift_COMPILER)
606-
# Add in the toolchain directory so we can grab compatibility libraries
607-
get_filename_component(TOOLCHAIN_BIN_DIR ${CMAKE_Swift_COMPILER} DIRECTORY)
608-
get_filename_component(TOOLCHAIN_LIB_DIR "${TOOLCHAIN_BIN_DIR}/../lib/swift/macosx" ABSOLUTE)
609-
target_link_directories(${name} PUBLIC ${TOOLCHAIN_LIB_DIR})
610-
611-
# Add in the SDK directory for the host platform.
612-
#
613-
# NOTE: We do this /after/ target_link_directorying TOOLCHAIN_LIB_DIR to
614-
# ensure that we first find libraries from the toolchain, rather than
615-
# from the SDK. The reason why this is important is that when we perform
616-
# a stage2 build, this path is into the stage1 build. This is not a pure
617-
# SDK and also contains compatibility libraries. We need to make sure
618-
# that the compiler sees the actual toolchain's compatibility libraries
619-
# first before the just built compability libraries or build errors occur.
620-
target_link_directories(${name} PRIVATE
621-
${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}/usr/lib/swift)
622-
endif()
623-
endif()
624-
625589
# For now turn off on Darwin swift targets, debug info if we are compiling a static
626590
# library and set up an rpath so that if someone works around this by using
627591
# shared libraries that in the short term we can find shared libraries.
@@ -947,25 +911,7 @@ function(add_swift_host_tool executable)
947911
set_property(TARGET ${executable} APPEND_STRING PROPERTY
948912
LINK_FLAGS " -lobjc ")
949913
950-
else() # ASHT_HAS_LIBSWIFT AND LIBSWIFT_BUILD_MODE
951-
952-
# TODO: do we really need this? Do any tools which don't link libswift include other swift code?
953-
954-
# Add in the SDK directory for the host platform.
955-
#
956-
# NOTE: We do this /after/ target_link_directorying TOOLCHAIN_LIB_DIR to
957-
# ensure that we first find libraries from the toolchain, rather than from
958-
# the SDK.
959-
target_link_directories(${executable} PRIVATE "${sdk_dir}")
960-
961-
# We also want to be able to find libraries from the base toolchain
962-
# directory. This is so swiftc can rely on its own host side dylibs that may
963-
# contain swift content.
964-
list(APPEND RPATH_LIST "@executable_path/../lib")
965-
966-
# Also include the abi stable system stdlib in our rpath.
967-
list(APPEND RPATH_LIST "/usr/lib/swift")
968-
endif()
914+
endif() # ASHT_HAS_LIBSWIFT AND LIBSWIFT_BUILD_MODE
969915
970916
set_target_properties(${executable} PROPERTIES
971917
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/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/DiagnosticsSema.def

Lines changed: 3 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 "

include/swift/AST/Expr.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,38 @@ class InterpolatedStringLiteralExpr : public LiteralExpr {
961961
return E->getKind() == ExprKind::InterpolatedStringLiteral;
962962
}
963963
};
964-
964+
965+
/// A regular expression literal e.g '(a|c)*'.
966+
class RegexLiteralExpr : public LiteralExpr {
967+
SourceLoc Loc;
968+
StringRef RegexText;
969+
Expr *SemanticExpr;
970+
971+
RegexLiteralExpr(SourceLoc loc, StringRef regexText, Expr *semanticExpr,
972+
bool isImplicit)
973+
: LiteralExpr(ExprKind::RegexLiteral, isImplicit), Loc(loc),
974+
RegexText(regexText), SemanticExpr(semanticExpr) {}
975+
976+
public:
977+
static RegexLiteralExpr *createParsed(ASTContext &ctx, SourceLoc loc,
978+
StringRef regexText,
979+
Expr *semanticExpr);
980+
981+
/// Retrieve the raw regex text.
982+
StringRef getRegexText() const { return RegexText; }
983+
984+
/// Retrieve the semantic expression that the regex will be type-checked and
985+
/// emitted as.
986+
Expr *getSemanticExpr() const { return SemanticExpr; }
987+
void setSemanticExpr(Expr *expr) { SemanticExpr = expr; }
988+
989+
SourceRange getSourceRange() const { return Loc; }
990+
991+
static bool classof(const Expr *E) {
992+
return E->getKind() == ExprKind::RegexLiteral;
993+
}
994+
};
995+
965996
/// MagicIdentifierLiteralExpr - A magic identifier like #file which expands
966997
/// out to a literal at SILGen time.
967998
class MagicIdentifierLiteralExpr : public BuiltinLiteralExpr {

include/swift/AST/ExprNodes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ ABSTRACT_EXPR(Literal, Expr)
7878
LITERAL_EXPR(MagicIdentifierLiteral, BuiltinLiteralExpr)
7979
EXPR_RANGE(BuiltinLiteral, BooleanLiteral, MagicIdentifierLiteral)
8080
LITERAL_EXPR(InterpolatedStringLiteral, LiteralExpr)
81+
LITERAL_EXPR(RegexLiteral, LiteralExpr)
8182
LITERAL_EXPR(ObjectLiteral, LiteralExpr)
8283
EXPR_RANGE(Literal, NilLiteral, ObjectLiteral)
8384
EXPR(DiscardAssignment, Expr)

include/swift/AST/KnownIdentifiers.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ IDENTIFIER(pullback)
250250
IDENTIFIER(TangentVector)
251251
IDENTIFIER(zero)
252252

253+
// Regex literals
254+
IDENTIFIER(Regex)
255+
IDENTIFIER(_regexString)
256+
253257
// Distributed actors
254258
IDENTIFIER(transport)
255259
IDENTIFIER(using)

0 commit comments

Comments
 (0)