Skip to content

Commit 93eae81

Browse files
authored
Merge pull request #37375 from nkcsgexi/diagnose-new-driver-only-options
Driver: diagnose options that are only supported in the new driver
2 parents 3ed1112 + 01b1aea commit 93eae81

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

include/swift/AST/DiagnosticsDriver.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,7 @@ WARNING(warn_drv_darwin_sdk_invalid_settings, none,
173173
"SDK settings were ignored because 'SDKSettings.json' could not be parsed",
174174
())
175175

176+
WARNING(warning_unsupported_driver_option,none,
177+
"option '%0' is ony supported in swift-driver", (StringRef))
176178
#define UNDEFINE_DIAGNOSTIC_MACROS
177179
#include "DefineDiagnosticMacros.h"

include/swift/Option/Options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace options {
4040
SwiftAPIExtractOption = (1 << 15),
4141
SwiftSymbolGraphExtractOption = (1 << 16),
4242
SwiftAPIDigesterOption = (1 << 17),
43+
NewDriverOnlyOption = (1 << 18),
4344
};
4445

4546
enum ID {

include/swift/Option/Options.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ def SwiftSymbolGraphExtractOption : OptionFlag;
6464
// The option should be accepted by swift-api-digester.
6565
def SwiftAPIDigesterOption : OptionFlag;
6666

67+
// The option only functions in the new driver.
68+
def NewDriverOnlyOption : OptionFlag;
69+
6770
/////////
6871
// Options
6972

@@ -1181,7 +1184,7 @@ def working_directory_EQ : Joined<["-"], "working-directory=">,
11811184
Alias<working_directory>;
11821185

11831186
def user_module_version : Separate<["-"], "user-module-version">,
1184-
Flags<[FrontendOption, ModuleInterfaceOption]>,
1187+
Flags<[FrontendOption, ModuleInterfaceOption, NewDriverOnlyOption]>,
11851188
HelpText<"Module version specified from Swift module authors">,
11861189
MetaVarName<"<vers>">;
11871190

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %swiftc_driver -emit-module -user-module-version 999.999 %s -### 2>&1 | %FileCheck %s
2+
3+
// CHECK: warning: option '-user-module-version' is ony supported in swift-driver

tools/driver/driver.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ static int run_driver(StringRef ExecName,
276276
if (Diags.hadAnyError())
277277
return 1;
278278

279+
for (auto arg: ArgList->getArgs()) {
280+
if (arg->getOption().hasFlag(options::NewDriverOnlyOption)) {
281+
Diags.diagnose(SourceLoc(), diag::warning_unsupported_driver_option,
282+
arg->getSpelling());
283+
}
284+
}
285+
279286
std::unique_ptr<Compilation> C =
280287
TheDriver.buildCompilation(*TC, std::move(ArgList));
281288

0 commit comments

Comments
 (0)