[Clang] Fix use of `hasArg` when `hasFlag` should be used instead
authorJoseph Huber <jhuber6@vols.utk.edu>
Tue, 11 Oct 2022 16:42:40 +0000 (11:42 -0500)
committerJoseph Huber <jhuber6@vols.utk.edu>
Tue, 11 Oct 2022 18:40:41 +0000 (13:40 -0500)
Summary:
This option forwards a clang flag with a `-no` variant to the Clang
compiler. It should use the `hasFlag` so it works properly when the
option is overridden.

clang/lib/Driver/ToolChains/Clang.cpp

index 1a3ee09..93e0a18 100644 (file)
@@ -6233,7 +6233,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   }
 
   // Forward the new driver to change offloading code generation.
-  if (Args.hasArg(options::OPT_offload_new_driver))
+  if (Args.hasFlag(options::OPT_offload_new_driver,
+                   options::OPT_no_offload_new_driver, false))
     CmdArgs.push_back("--offload-new-driver");
 
   SanitizeArgs.addArgs(TC, Args, CmdArgs, InputType);