Skip to content

Commit 63b8db1

Browse files
committed
Start using '-enable-bare-slash-regex'
Change the flag to imply '-enable-experimental-string-processing', and and update some tests to start using it.
1 parent 080d59b commit 63b8db1

File tree

11 files changed

+28
-14
lines changed

11 files changed

+28
-14
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,9 @@ namespace swift {
564564
/// Enables dumping type witness systems from associated type inference.
565565
bool DumpTypeWitnessSystems = false;
566566

567-
/// Enables `/.../` syntax regular-expression literals
568-
bool EnableForwardSlashRegexLiterals = false;
567+
/// Enables `/.../` syntax regular-expression literals. This requires
568+
/// experimental string processing. Note this does not affect `#/.../#`.
569+
bool EnableBareSlashRegexLiterals = false;
569570

570571
/// Sets the target we are building for and updates platform conditions
571572
/// to match.

lib/Frontend/CompilerInvocation.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,13 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
504504
Opts.EnableExperimentalStringProcessing |=
505505
Args.hasArg(OPT_enable_experimental_string_processing);
506506

507+
// Whether '/.../' regex literals are enabled. This implies experimental
508+
// string processing.
509+
if (Args.hasArg(OPT_enable_bare_slash_regex)) {
510+
Opts.EnableBareSlashRegexLiterals = true;
511+
Opts.EnableExperimentalStringProcessing = true;
512+
}
513+
507514
Opts.EnableExperimentalBoundGenericExtensions |=
508515
Args.hasArg(OPT_enable_experimental_bound_generic_extensions);
509516

@@ -1010,9 +1017,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
10101017
if (Args.hasArg(OPT_disable_requirement_machine_reuse))
10111018
Opts.EnableRequirementMachineReuse = false;
10121019

1013-
if (Args.hasArg(OPT_enable_bare_slash_regex))
1014-
Opts.EnableForwardSlashRegexLiterals = true;
1015-
10161020
if (Args.hasArg(OPT_enable_requirement_machine_opaque_archetypes))
10171021
Opts.EnableRequirementMachineOpaqueArchetypes = true;
10181022

test/IDE/complete_regex.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// REQUIRES: swift_in_compiler
22

33
// RUN: %empty-directory(%t)
4-
// RUN: %target-swift-ide-test -enable-experimental-string-processing -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
4+
// RUN: %target-swift-ide-test -enable-bare-slash-regex -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
55

66
func testLiteral() {
77
#/foo/#.#^RE_LITERAL_MEMBER^#

test/SourceKit/Sema/sema_regex.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ public func retRegex() -> Regex<Substring> {
33
}
44

55
// REQUIRES: swift_in_compiler
6-
// RUN: %sourcekitd-test -req=sema %s -- %s -Xfrontend -enable-experimental-string-processing | %FileCheck %s
6+
// RUN: %sourcekitd-test -req=sema %s -- %s -Xfrontend -enable-bare-slash-regex | %FileCheck %s
77

88
// CHECK: [
99
// CHECK: {

test/StringProcessing/Parse/regex.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -enable-experimental-string-processing
1+
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex
22
// REQUIRES: swift_in_compiler
33

44
_ = #/abc/#

test/StringProcessing/Parse/regex_parse_end_of_buffer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -enable-experimental-string-processing
1+
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex
22
// REQUIRES: swift_in_compiler
33

44
// Note there is purposefully no trailing newline here.

test/StringProcessing/Parse/regex_parse_error.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -enable-experimental-string-processing
1+
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex
22
// REQUIRES: swift_in_compiler
33

44
_ = #/(/# // expected-error {{expected ')'}}

test/StringProcessing/Runtime/regex_basic.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-string-processing)
1+
// RUN: %target-run-simple-swift(-Xfrontend -enable-bare-slash-regex)
22

33
// REQUIRES: swift_in_compiler,string_processing,executable_test
44

test/StringProcessing/SILGen/regex_literal_silgen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-silgen -enable-experimental-string-processing %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -emit-silgen -enable-bare-slash-regex %s | %FileCheck %s
22
// REQUIRES: swift_in_compiler
33

44
var s = #/abc/#

test/StringProcessing/Sema/regex_literal_type_inference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -enable-experimental-string-processing
1+
// RUN: %target-typecheck-verify-swift -enable-bare-slash-regex
22
// REQUIRES: swift_in_compiler
33

44
let r0 = #/./#

0 commit comments

Comments
 (0)