Skip to content

Commit a2bdd28

Browse files
authored
Merge pull request #1048 from apple/revert-1047-revert-1045-EnableRegexLiteralFlag
Revert "Revert "Add support for `-enable-regex-literals` flag""
2 parents 27a1c12 + 334fad6 commit a2bdd28

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ extension Driver {
206206
try commandLine.appendAll(.coveragePrefixMap, from: &parsedOptions)
207207
try commandLine.appendLast(.warnConcurrency, from: &parsedOptions)
208208
try commandLine.appendAll(.moduleAlias, from: &parsedOptions)
209+
if isFrontendArgSupported(.enableRegexLiterals) {
210+
try commandLine.appendLast(.enableRegexLiterals, from: &parsedOptions)
211+
}
209212

210213
// Expand the -experimental-hermetic-seal-at-link flag
211214
if parsedOptions.hasArgument(.experimentalHermeticSealAtLink) {

Sources/SwiftOptions/Options.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ extension Option {
327327
public static let enableOssaModules: Option = Option("-enable-ossa-modules", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Always serialize SIL in ossa form. If this flag is not passed in, when optimizing ownership will be lowered before serializing SIL")
328328
public static let enableParameterizedProtocolTypes: Option = Option("-enable-parameterized-protocol-types", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable experimental support for primary associated types and parameterized protocols")
329329
public static let enablePrivateImports: Option = Option("-enable-private-imports", .flag, attributes: [.helpHidden, .frontend, .noInteractive], helpText: "Allows this module's internal and private API to be accessed")
330+
public static let enableRegexLiterals: Option = Option("-enable-regex-literals", .flag, attributes: [.frontend], helpText: "Enable the use of regular-expression literals")
330331
public static let enableRequirementMachineOpaqueArchetypes: Option = Option("-enable-requirement-machine-opaque-archetypes", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable more correct opaque archetype support, which is off by default because it might fail to produce a convergent rewrite system")
331332
public static let enableResilience: Option = Option("-enable-resilience", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Deprecated, use -enable-library-evolution instead")
332333
public static let enableSilOpaqueValues: Option = Option("-enable-sil-opaque-values", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable SIL Opaque Values")
@@ -992,6 +993,7 @@ extension Option {
992993
Option.enableOssaModules,
993994
Option.enableParameterizedProtocolTypes,
994995
Option.enablePrivateImports,
996+
Option.enableRegexLiterals,
995997
Option.enableRequirementMachineOpaqueArchetypes,
996998
Option.enableResilience,
997999
Option.enableSilOpaqueValues,

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3048,6 +3048,19 @@ final class SwiftDriverTests: XCTestCase {
30483048
XCTAssertTrue(plannedJobs[0].commandLine.contains(.path(try VirtualPath(path: modulePath))))
30493049
}
30503050

3051+
func testEnableRegexLiteralFlag() throws {
3052+
var driver = try Driver(args: ["swiftc", "foo.swift", "-enable-regex-literals"])
3053+
guard driver.isFrontendArgSupported(.enableRegexLiterals) else {
3054+
throw XCTSkip("Skipping: compiler does not support '-enable-regex-literals'")
3055+
}
3056+
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
3057+
XCTAssertEqual(plannedJobs.count, 2)
3058+
XCTAssertEqual(plannedJobs[0].kind, .compile)
3059+
XCTAssertEqual(plannedJobs[1].kind, .link)
3060+
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-frontend")))
3061+
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-enable-regex-literals")))
3062+
}
3063+
30513064
func testImmediateMode() throws {
30523065
do {
30533066
var driver = try Driver(args: ["swift", "foo.swift"])

0 commit comments

Comments
 (0)