[clang] clang: Stop using replace_extension when there's no extension (PR #195335)

via cfe-commits cfe-commits at lists.llvm.org
Fri May 1 12:33:18 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

The offload case is building a fresh filepath and there's no file
extension to replace. Just directly append the file extension to avoid
clobbering part of the path name if the triple contains a period.

Avoids confusing test updates in future triple patch.

---
Full diff: https://github.com/llvm/llvm-project/pull/195335.diff


1 Files Affected:

- (modified) clang/lib/Driver/Driver.cpp (+2-1) 


``````````diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index c98ac919f7d2a..e120fdd743826 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6037,10 +6037,11 @@ static void handleTimeTrace(Compilation &C, const ArgList &Args,
       if (Arg *FinalOutput = Args.getLastArg(options::OPT_o))
         Path = llvm::sys::path::parent_path(FinalOutput->getValue());
       llvm::sys::path::append(Path, TraceName);
+      Path += ".json";
     } else {
       Path = Result.getFilename();
+      llvm::sys::path::replace_extension(Path, "json");
     }
-    llvm::sys::path::replace_extension(Path, "json");
   }
   const char *ResultFile = C.getArgs().MakeArgString(Path);
   C.addTimeTraceFile(ResultFile, JA);

``````````

</details>


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


More information about the cfe-commits mailing list