Skip to content

Commit b298fab

Browse files
authored
Merge pull request #1049 from apple/BareBonesRegexSyntax
Rename flag for enabling forward slash literals to be less ambiguous.
2 parents 16016b1 + 457b5c8 commit b298fab

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ 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)
209+
if isFrontendArgSupported(.enableBareSlashRegex) {
210+
try commandLine.appendLast(.enableBareSlashRegex, from: &parsedOptions)
211211
}
212212

213213
// Expand the -experimental-hermetic-seal-at-link flag

Sources/SwiftOptions/Options.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extension Option {
2525
public static let enableAppExtension: Option = Option("-application-extension", .flag, attributes: [.frontend, .noInteractive], helpText: "Restrict code to those available for App Extensions")
2626
public static let AssertConfig: Option = Option("-assert-config", .separate, attributes: [.frontend, .moduleInterface], helpText: "Specify the assert_configuration replacement. Possible values are Debug, Release, Unchecked, DisableReplacement.")
2727
public static let AssumeSingleThreaded: Option = Option("-assume-single-threaded", .flag, attributes: [.helpHidden, .frontend], helpText: "Assume that code will be executed in a single-threaded environment")
28+
public static let asyncMain: Option = Option("-async-main", .flag, attributes: [.frontend], helpText: "Resolve main function as if it were called from an asynchronous context")
2829
public static let autolinkForceLoad: Option = Option("-autolink-force-load", .flag, attributes: [.helpHidden, .frontend, .moduleInterface], helpText: "Force ld to link against this module even if no symbols are used")
2930
public static let autolinkLibrary: Option = Option("-autolink-library", .separate, attributes: [.frontend, .noDriver], helpText: "Add dependent library")
3031
public static let avoidEmitModuleSourceInfo: Option = Option("-avoid-emit-module-source-info", .flag, attributes: [.noInteractive, .doesNotAffectIncrementalBuild], helpText: "don't emit Swift source info file")
@@ -130,6 +131,7 @@ extension Option {
130131
public static let disableGenericMetadataPrespecialization: Option = Option("-disable-generic-metadata-prespecialization", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Do not statically specialize metadata for generic types at types that are known to be used in source.")
131132
public static let disableImplicitConcurrencyModuleImport: Option = Option("-disable-implicit-concurrency-module-import", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable the implicit import of the _Concurrency module.")
132133
public static let disableImplicitDistributedModuleImport: Option = Option("-disable-implicit-distributed-module-import", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable the implicit import of the Distributed module.")
134+
public static let disableImplicitStringProcessingModuleImport: Option = Option("-disable-implicit-string-processing-module-import", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable the implicit import of the _StringProcessing module.")
133135
public static let disableImplicitSwiftModules: Option = Option("-disable-implicit-swift-modules", .flag, attributes: [.frontend, .noDriver], helpText: "Disable building Swift modules implicitly by the compiler")
134136
public static let disableIncrementalImports: Option = Option("-disable-incremental-imports", .flag, attributes: [.frontend], helpText: "Disable cross-module incremental build metadata and driver scheduling for Swift modules")
135137
public static let disableIncrementalLlvmCodegeneration: Option = Option("-disable-incremental-llvm-codegen", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Disable incremental llvm code generation.")
@@ -277,6 +279,7 @@ extension Option {
277279
public static let enableActorDataRaceChecks: Option = Option("-enable-actor-data-race-checks", .flag, attributes: [.frontend, .doesNotAffectIncrementalBuild], helpText: "Emit runtime checks for actor data races")
278280
public static let enableAnonymousContextMangledNames: Option = Option("-enable-anonymous-context-mangled-names", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable emission of mangled names in anonymous context descriptors")
279281
public static let enableAstVerifier: Option = Option("-enable-ast-verifier", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Run the AST verifier during compilation. NOTE: This lets the user override the default behavior on whether or not the ASTVerifier is run. The default behavior is to run the verifier when asserts are enabled and not run it when asserts are disabled. NOTE: Can not be used if disable-ast-verifier is used as well")
282+
public static let enableBareSlashRegex: Option = Option("-enable-bare-slash-regex", .flag, attributes: [.frontend], helpText: "Enable the use of forward slash regular-expression literal syntax")
280283
public static let enableBatchMode: Option = Option("-enable-batch-mode", .flag, attributes: [.helpHidden, .frontend, .noInteractive], helpText: "Enable combining frontend jobs into batches")
281284
public static let enableBridgingPch: Option = Option("-enable-bridging-pch", .flag, attributes: [.helpHidden], helpText: "Enable automatic generation of bridging PCH files")
282285
public static let enableConformanceAvailabilityErrors: Option = Option("-enable-conformance-availability-errors", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Diagnose conformance availability violations as errors")
@@ -327,7 +330,6 @@ extension Option {
327330
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")
328331
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")
329332
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")
331333
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")
332334
public static let enableResilience: Option = Option("-enable-resilience", .flag, attributes: [.helpHidden, .frontend, .noDriver, .moduleInterface], helpText: "Deprecated, use -enable-library-evolution instead")
333335
public static let enableSilOpaqueValues: Option = Option("-enable-sil-opaque-values", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Enable SIL Opaque Values")
@@ -691,6 +693,7 @@ extension Option {
691693
Option.enableAppExtension,
692694
Option.AssertConfig,
693695
Option.AssumeSingleThreaded,
696+
Option.asyncMain,
694697
Option.autolinkForceLoad,
695698
Option.autolinkLibrary,
696699
Option.avoidEmitModuleSourceInfo,
@@ -796,6 +799,7 @@ extension Option {
796799
Option.disableGenericMetadataPrespecialization,
797800
Option.disableImplicitConcurrencyModuleImport,
798801
Option.disableImplicitDistributedModuleImport,
802+
Option.disableImplicitStringProcessingModuleImport,
799803
Option.disableImplicitSwiftModules,
800804
Option.disableIncrementalImports,
801805
Option.disableIncrementalLlvmCodegeneration,
@@ -943,6 +947,7 @@ extension Option {
943947
Option.enableActorDataRaceChecks,
944948
Option.enableAnonymousContextMangledNames,
945949
Option.enableAstVerifier,
950+
Option.enableBareSlashRegex,
946951
Option.enableBatchMode,
947952
Option.enableBridgingPch,
948953
Option.enableConformanceAvailabilityErrors,
@@ -993,7 +998,6 @@ extension Option {
993998
Option.enableOssaModules,
994999
Option.enableParameterizedProtocolTypes,
9951000
Option.enablePrivateImports,
996-
Option.enableRegexLiterals,
9971001
Option.enableRequirementMachineOpaqueArchetypes,
9981002
Option.enableResilience,
9991003
Option.enableSilOpaqueValues,

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3093,16 +3093,16 @@ final class SwiftDriverTests: XCTestCase {
30933093
}
30943094

30953095
func testEnableRegexLiteralFlag() throws {
3096-
var driver = try Driver(args: ["swiftc", "foo.swift", "-enable-regex-literals"])
3097-
guard driver.isFrontendArgSupported(.enableRegexLiterals) else {
3098-
throw XCTSkip("Skipping: compiler does not support '-enable-regex-literals'")
3096+
var driver = try Driver(args: ["swiftc", "foo.swift", "-enable-bare-slash-regex"])
3097+
guard driver.isFrontendArgSupported(.enableBareSlashRegex) else {
3098+
throw XCTSkip("Skipping: compiler does not support '-enable-bare-slash-regex'")
30993099
}
31003100
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
31013101
XCTAssertEqual(plannedJobs.count, 2)
31023102
XCTAssertEqual(plannedJobs[0].kind, .compile)
31033103
XCTAssertEqual(plannedJobs[1].kind, .link)
31043104
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-frontend")))
3105-
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-enable-regex-literals")))
3105+
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-enable-bare-slash-regex")))
31063106
}
31073107

31083108
func testImmediateMode() throws {

0 commit comments

Comments
 (0)