@@ -134,19 +134,28 @@ static bool shouldRunAsSubcommand(StringRef ExecName,
134
134
return true ;
135
135
}
136
136
137
- static bool shouldDisallowNewDriver (StringRef ExecName,
137
+ static bool shouldDisallowNewDriver (DiagnosticEngine &diags,
138
+ StringRef ExecName,
138
139
const ArrayRef<const char *> argv) {
139
140
// We are not invoking the driver, so don't forward.
140
141
if (ExecName != " swift" && ExecName != " swiftc" ) {
141
142
return true ;
142
143
}
144
+ StringRef disableArg = " -disallow-use-new-driver" ;
145
+ StringRef disableEnv = " SWIFT_USE_OLD_DRIVER" ;
146
+ auto shouldWarn = !llvm::sys::Process::
147
+ GetEnv (" SWIFT_AVOID_WARNING_USING_OLD_DRIVER" ).hasValue ();
143
148
// If user specified using the old driver, don't forward.
144
- if (llvm::find_if (argv, [](const char * arg) {
145
- return StringRef (arg) == " -disallow-use-new-driver " ;
149
+ if (llvm::find_if (argv, [& ](const char * arg) {
150
+ return StringRef (arg) == disableArg ;
146
151
}) != argv.end ()) {
152
+ if (shouldWarn)
153
+ diags.diagnose (SourceLoc (), diag::old_driver_deprecated, disableArg);
147
154
return true ;
148
155
}
149
- if (llvm::sys::Process::GetEnv (" SWIFT_USE_OLD_DRIVER" ).hasValue ()) {
156
+ if (llvm::sys::Process::GetEnv (disableEnv).hasValue ()) {
157
+ if (shouldWarn)
158
+ diags.diagnose (SourceLoc (), diag::old_driver_deprecated, disableEnv);
150
159
return true ;
151
160
}
152
161
return false ;
@@ -208,7 +217,7 @@ static int run_driver(StringRef ExecName,
208
217
209
218
// Forwarding calls to the swift driver if the C++ driver is invoked as `swift`
210
219
// or `swiftc`, and an environment variable SWIFT_USE_NEW_DRIVER is defined.
211
- if (!shouldDisallowNewDriver (ExecName, argv)) {
220
+ if (!shouldDisallowNewDriver (Diags, ExecName, argv)) {
212
221
SmallString<256 > NewDriverPath (llvm::sys::path::parent_path (Path));
213
222
if (appendSwiftDriverName (NewDriverPath) &&
214
223
llvm::sys::fs::exists (NewDriverPath)) {
0 commit comments