aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-profdata/llvm-profdata.cpp
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2025-06-29 10:37:12 +0800
committerGitHub <noreply@github.com>2025-06-29 10:37:12 +0800
commit68d83fae70b2fa136b6c4a8c91af9e615eeedf95 (patch)
treefed2a82daf56019c748106e51b87267526968133 /llvm/tools/llvm-profdata/llvm-profdata.cpp
parent25d52fbf96ec927914b3a5c9db0b61fe2804a3dd (diff)
downloadllvm-68d83fae70b2fa136b6c4a8c91af9e615eeedf95.zip
llvm-68d83fae70b2fa136b6c4a8c91af9e615eeedf95.tar.gz
llvm-68d83fae70b2fa136b6c4a8c91af9e615eeedf95.tar.bz2
[llvm-profdata] Resolve tilde for weighted input filenames (#146206)
When specifying a weighted input file, the shell does not automatically expand the tilde (`~`) character in the filename because the argument is passed as a single string in the format `<weight>,<filename>`. This commit fixes the issue by using `llvm::sys::fs::expand_tilde` to explicitly resolve the tilde in the filename, ensuring that paths like `~/path/to/file` are correctly handled.
Diffstat (limited to 'llvm/tools/llvm-profdata/llvm-profdata.cpp')
-rw-r--r--llvm/tools/llvm-profdata/llvm-profdata.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index a7cbd4b..45eac90 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -1705,7 +1705,10 @@ static WeightedFile parseWeightedFile(const StringRef &WeightedFilename) {
if (WeightStr.getAsInteger(10, Weight) || Weight < 1)
exitWithError("input weight must be a positive integer");
- return {std::string(FileName), Weight};
+ llvm::SmallString<128> ResolvedFileName;
+ llvm::sys::fs::expand_tilde(FileName, ResolvedFileName);
+
+ return {std::string(ResolvedFileName), Weight};
}
static void addWeightedInput(WeightedFileVector &WNI, const WeightedFile &WF) {