[clang] clang: Stop using replace_extension when there's no extension (PR #195335)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Fri May 1 12:32:23 PDT 2026
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/195335
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.
>From ad6e4c400b9f719b85f06eaf4177e08c11a1df75 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 1 May 2026 19:46:39 +0100
Subject: [PATCH] clang: Stop using replace_extension when there's no extension
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.
---
clang/lib/Driver/Driver.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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);
More information about the cfe-commits
mailing list