Skip to content

Merge pull request #59623 from rxwei/cherry-42611 #61793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,27 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
= A->getOption().matches(OPT_enable_deserialization_recovery);
}

// Whether '/.../' regex literals are enabled. This implies experimental
// string processing.
if (Args.hasArg(OPT_enable_bare_slash_regex)) {
Opts.EnableBareSlashRegexLiterals = true;
Opts.EnableExperimentalStringProcessing = true;
}

// Experimental string processing.
if (auto A = Args.getLastArg(OPT_enable_experimental_string_processing,
OPT_disable_experimental_string_processing)) {
Opts.EnableExperimentalStringProcessing =
A->getOption().matches(OPT_enable_experimental_string_processing);

// When experimental string processing is explicitly disabled, also disable
// forward slash regex `/.../`.
if (!Opts.EnableExperimentalStringProcessing)
Opts.EnableBareSlashRegexLiterals = false;
} else {
Opts.EnableExperimentalStringProcessing = true;
}

Opts.DisableAvailabilityChecking |=
Args.hasArg(OPT_disable_availability_checking);
Opts.CheckAPIAvailabilityOnly |=
Expand Down
6 changes: 6 additions & 0 deletions stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1787,6 +1787,12 @@ function(add_swift_target_library name)
"-Xfrontend;-disable-implicit-string-processing-module-import")
endif()

# Turn off implicit import of _StringProcessing when building libraries
if(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING)
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS
"-Xfrontend;-disable-implicit-string-processing-module-import")
endif()

if(SWIFTLIB_IS_STDLIB AND SWIFT_STDLIB_ENABLE_PRESPECIALIZATION)
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS "-Xfrontend;-prespecialize-generic-metadata")
endif()
Expand Down
4 changes: 2 additions & 2 deletions test/Parse/switch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ func f1(x: String, y: Whichever) {
break
case Whichever.buzz: // expected-error {{type 'Whichever' has no member 'buzz'}}
break
// expected-note @+1 {{overloads for '~=' exist with these partially matching parameter lists: (Substring, String)}}
case Whichever.alias: // expected-error {{expression pattern of type 'Whichever' cannot match values of type 'String'}}
// expected-note@-1 {{overloads for '~=' exist}}
// expected-error@-2 {{'case' label in a 'switch' must have at least one executable statement}}
// expected-error@-1 {{'case' label in a 'switch' must have at least one executable statement}}
default:
break
}
Expand Down
2 changes: 1 addition & 1 deletion test/SourceKit/InterfaceGen/gen_swift_module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func f(s : inout [Int]) {
// GROUP-EMPTY: <GROUPS>
// GROUP-EMPTY-NEXT: <\GROUPS>

// RUN: %swift -emit-module -o %t.mod/swift_mod_syn.swiftmodule %S/Inputs/swift_mod_syn.swift -parse-as-library -disable-implicit-concurrency-module-import
// RUN: %swift -emit-module -o %t.mod/swift_mod_syn.swiftmodule %S/Inputs/swift_mod_syn.swift -parse-as-library -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import
// RUN: %sourcekitd-test -req=interface-gen-open -module swift_mod_syn -- -Xfrontend -disable-implicit-concurrency-module-import -Xfrontend -disable-implicit-string-processing-module-import -I %t.mod == -req=cursor -pos=4:7 %s -- -Xfrontend -disable-implicit-concurrency-module-import -Xfrontend -disable-implicit-string-processing-module-import %s -I %t.mod | %FileCheck -check-prefix=SYNTHESIZED-USR1 %s
// SYNTHESIZED-USR1: s:SMsSkRzSL7ElementSTRpzrlE4sortyyF::SYNTHESIZED::s:Sa

Expand Down