================
@@ -6097,10 +6097,29 @@ const char *Driver::GetNamedOutputPath(Compilation &C, 
const JobAction &JA,
   }
 
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
+
   // Output to a user requested destination?
   if (AtTopLevel && !isa<DsymutilJobAction>(JA) && !isa<VerifyJobAction>(JA)) {
-    if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+    bool IsCLNonPCH =
+        IsCLMode() && !C.getArgs().hasArg(options::OPT__SLASH_Yc) &&
+        (isa<PreprocessJobAction>(JA) || isa<PrecompileJobAction>(JA));
+    bool HasAnyOutputArg = C.getArgs().hasArg(
+        options::OPT_o, options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON);
+
+    Arg *FinalOutput = nullptr;
+    if (IsCLNonPCH && HasAnyOutputArg) {
+      FinalOutput = C.getArgs().getLastArg(
+          options::OPT_o, options::OPT__SLASH_Fo, 
options::OPT__SLASH_Fo_COLON);
+    } else if (IsCLNonPCH) {
+      FinalOutput = C.getArgs().getLastArg(options::OPT__SLASH_Fo,
+                                           options::OPT__SLASH_Fo_COLON);
+    } else {
+      FinalOutput = C.getArgs().getLastArg(options::OPT_o);
+    }
----------------
sharadhr wrote:

I've updated the OP message with the reasoning for this. This logic in 
particular is to resolve `lit` test cases that failed when `/Yp` was passed to 
`clang-cl.exe`, i.e. PCHs were generated. I believe this is because `/Yp` uses 
`/Fo` for the PCH output, and therefore this invocation needs to use `/o` (or 
`-o`). 

`HasAnyOutputArg` was written _specifically_ to resolve 
`llvm-project\clang\test\ClangScanDeps\target-filename.cpp` failing. It feels 
like a weird hack and I'm open to suggestions.

https://github.com/llvm/llvm-project/pull/121046
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to