[clang] [clang][Driver] Ensure intermediate bitcode files are written according to `/Fo` (PR #189977)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 7 10:06:07 PDT 2026


================
@@ -6574,15 +6574,25 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
   // Determine what the derived output name should be.
   const char *NamedOutput;
 
-  if ((JA.getType() == types::TY_Object || JA.getType() == types::TY_LTO_BC) &&
+  if ((JA.getType() == types::TY_Object || JA.getType() == types::TY_LTO_BC ||
+       JA.getType() == types::TY_LLVM_BC ||
+       JA.getType() == types::TY_LLVM_IR) &&
       C.getArgs().hasArg(options::OPT__SLASH_Fo, options::OPT__SLASH_o)) {
     // The /Fo or /o flag decides the object filename.
     StringRef Val =
         C.getArgs()
             .getLastArg(options::OPT__SLASH_Fo, options::OPT__SLASH_o)
             ->getValue();
+    types::ID OutputFileTy = types::TY_Object;
+    if (JA.getType() == types::TY_LLVM_BC ||
+        JA.getType() == types::TY_LLVM_IR) {
+      // As discussed in PR #189977, this prevents intermediate files from
----------------
efriedma-quic wrote:

Please avoid referring to PRs in code comments, generally; the code should stand on its own.  (I'd maybe make exceptions for certain design discussions, but I don't think this fits.)

I'm not sure the comment really adds anything.

-----

Can we just unconditionally pass JA.getType() to MakeCLOutputFilename?  We're already doing that for every type except TY_LTO_BC, and we should compute the same file extension for that.

https://github.com/llvm/llvm-project/pull/189977


More information about the cfe-commits mailing list