Skip to content

Commit 33d178c

Browse files
stephentyronerxwei
andauthored
Merge pull request #59623 from rxwei/cherry-42611 (#61793)
* Merge pull request #59623 from rxwei/cherry-42611 * Fixup switch.swift test from bad merge. Co-authored-by: Richard Wei <[email protected]>
1 parent 66f6769 commit 33d178c

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,27 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
496496
= A->getOption().matches(OPT_enable_deserialization_recovery);
497497
}
498498

499+
// Whether '/.../' regex literals are enabled. This implies experimental
500+
// string processing.
501+
if (Args.hasArg(OPT_enable_bare_slash_regex)) {
502+
Opts.EnableBareSlashRegexLiterals = true;
503+
Opts.EnableExperimentalStringProcessing = true;
504+
}
505+
506+
// Experimental string processing.
507+
if (auto A = Args.getLastArg(OPT_enable_experimental_string_processing,
508+
OPT_disable_experimental_string_processing)) {
509+
Opts.EnableExperimentalStringProcessing =
510+
A->getOption().matches(OPT_enable_experimental_string_processing);
511+
512+
// When experimental string processing is explicitly disabled, also disable
513+
// forward slash regex `/.../`.
514+
if (!Opts.EnableExperimentalStringProcessing)
515+
Opts.EnableBareSlashRegexLiterals = false;
516+
} else {
517+
Opts.EnableExperimentalStringProcessing = true;
518+
}
519+
499520
Opts.DisableAvailabilityChecking |=
500521
Args.hasArg(OPT_disable_availability_checking);
501522
Opts.CheckAPIAvailabilityOnly |=

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,6 +1787,12 @@ function(add_swift_target_library name)
17871787
"-Xfrontend;-disable-implicit-string-processing-module-import")
17881788
endif()
17891789

1790+
# Turn off implicit import of _StringProcessing when building libraries
1791+
if(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING)
1792+
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS
1793+
"-Xfrontend;-disable-implicit-string-processing-module-import")
1794+
endif()
1795+
17901796
if(SWIFTLIB_IS_STDLIB AND SWIFT_STDLIB_ENABLE_PRESPECIALIZATION)
17911797
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS "-Xfrontend;-prespecialize-generic-metadata")
17921798
endif()

test/Parse/switch.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ func f1(x: String, y: Whichever) {
336336
break
337337
case Whichever.buzz: // expected-error {{type 'Whichever' has no member 'buzz'}}
338338
break
339+
// expected-note @+1 {{overloads for '~=' exist with these partially matching parameter lists: (Substring, String)}}
339340
case Whichever.alias: // expected-error {{expression pattern of type 'Whichever' cannot match values of type 'String'}}
340-
// expected-note@-1 {{overloads for '~=' exist}}
341-
// expected-error@-2 {{'case' label in a 'switch' must have at least one executable statement}}
341+
// expected-error@-1 {{'case' label in a 'switch' must have at least one executable statement}}
342342
default:
343343
break
344344
}

test/SourceKit/InterfaceGen/gen_swift_module.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func f(s : inout [Int]) {
1414
// GROUP-EMPTY: <GROUPS>
1515
// GROUP-EMPTY-NEXT: <\GROUPS>
1616

17-
// 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
17+
// 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
1818
// 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
1919
// SYNTHESIZED-USR1: s:SMsSkRzSL7ElementSTRpzrlE4sortyyF::SYNTHESIZED::s:Sa
2020

0 commit comments

Comments
 (0)