@@ -340,6 +340,9 @@ public struct Driver {
340340 /// A collection of all the flags the selected toolchain's `swift-frontend` supports
341341 public let supportedFrontendFlags : Set < String >
342342
343+ /// A list of unknown driver flags that are recognizable to `swift-frontend`
344+ public let savedUnknownDriverFlagsForSwiftFrontend : [ String ]
345+
343346 /// A collection of all the features the selected toolchain's `swift-frontend` supports
344347 public let supportedFrontendFeatures : Set < String >
345348
@@ -383,10 +386,10 @@ public struct Driver {
383386 . replacingExtension ( with: . jsonABIBaseline) . intern ( ) , type: . jsonABIBaseline)
384387 } ( )
385388
386- public func isFrontendArgSupported ( _ opt: Option ) -> Bool {
387- var current = opt. spelling
389+ public static func isOptionFound ( _ opt: String , allOpts : Set < String > ) -> Bool {
390+ var current = opt
388391 while ( true ) {
389- if supportedFrontendFlags . contains ( current) {
392+ if allOpts . contains ( current) {
390393 return true
391394 }
392395 if current. starts ( with: " - " ) {
@@ -397,6 +400,10 @@ public struct Driver {
397400 }
398401 }
399402
403+ public func isFrontendArgSupported( _ opt: Option ) -> Bool {
404+ return Driver . isOptionFound ( opt. spelling, allOpts: supportedFrontendFlags)
405+ }
406+
400407 @_spi ( Testing)
401408 public func isFeatureSupported( _ feature: KnownCompilerFeature ) -> Bool {
402409 return supportedFrontendFeatures. contains ( feature. rawValue)
@@ -494,7 +501,7 @@ public struct Driver {
494501
495502 self . driverKind = try Self . determineDriverKind ( args: & args)
496503 self . optionTable = OptionTable ( )
497- self . parsedOptions = try optionTable. parse ( Array ( args) , for: self . driverKind)
504+ self . parsedOptions = try optionTable. parse ( Array ( args) , for: self . driverKind, delayThrows : true )
498505 self . showJobLifecycle = parsedOptions. contains ( . driverShowJobLifecycle)
499506
500507 // Determine the compilation mode.
@@ -662,6 +669,13 @@ public struct Driver {
662669 diagnosticsEngine: diagnosticEngine,
663670 fileSystem: fileSystem, executor: executor,
664671 env: env)
672+ let supportedFrontendFlagsLocal = self . supportedFrontendFlags
673+ self . savedUnknownDriverFlagsForSwiftFrontend = try self . parsedOptions. saveUnknownFlags {
674+ Driver . isOptionFound ( $0, allOpts: supportedFrontendFlagsLocal)
675+ }
676+ self . savedUnknownDriverFlagsForSwiftFrontend. forEach {
677+ diagnosticsEngine. emit ( warning: " save unknown driver flag \( $0) as additional swift-frontend flag " )
678+ }
665679 self . supportedFrontendFeatures = try Self . computeSupportedCompilerFeatures ( of: self . toolchain, env: env)
666680
667681 self . enabledSanitizers = try Self . parseSanitizerArgValues (
0 commit comments