@@ -134,19 +134,28 @@ static bool shouldRunAsSubcommand(StringRef ExecName,
134134 return true ;
135135}
136136
137- static bool shouldDisallowNewDriver (StringRef ExecName,
137+ static bool shouldDisallowNewDriver (DiagnosticEngine &diags,
138+ StringRef ExecName,
138139 const ArrayRef<const char *> argv) {
139140 // We are not invoking the driver, so don't forward.
140141 if (ExecName != " swift" && ExecName != " swiftc" ) {
141142 return true ;
142143 }
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 ();
143148 // 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 ;
146151 }) != argv.end ()) {
152+ if (shouldWarn)
153+ diags.diagnose (SourceLoc (), diag::old_driver_deprecated, disableArg);
147154 return true ;
148155 }
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);
150159 return true ;
151160 }
152161 return false ;
@@ -208,7 +217,7 @@ static int run_driver(StringRef ExecName,
208217
209218 // Forwarding calls to the swift driver if the C++ driver is invoked as `swift`
210219 // or `swiftc`, and an environment variable SWIFT_USE_NEW_DRIVER is defined.
211- if (!shouldDisallowNewDriver (ExecName, argv)) {
220+ if (!shouldDisallowNewDriver (Diags, ExecName, argv)) {
212221 SmallString<256 > NewDriverPath (llvm::sys::path::parent_path (Path));
213222 if (appendSwiftDriverName (NewDriverPath) &&
214223 llvm::sys::fs::exists (NewDriverPath)) {
0 commit comments