[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.
This commit is contained in:
@@ -1705,7 +1705,10 @@ static WeightedFile parseWeightedFile(const StringRef &WeightedFilename) {
|
|||||||
if (WeightStr.getAsInteger(10, Weight) || Weight < 1)
|
if (WeightStr.getAsInteger(10, Weight) || Weight < 1)
|
||||||
exitWithError("input weight must be a positive integer");
|
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) {
|
static void addWeightedInput(WeightedFileVector &WNI, const WeightedFile &WF) {
|
||||||
|
|||||||
Reference in New Issue
Block a user