mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Frontend: compare normalised absolute paths for temp
The LLVM API for the temporary paths behaves differently on Windows and Unix. Windows always returns the absolute path, and on Unix, you get whatever is in the environment. Furthermore, windows allows both `\` and `/` as separators. Normalise the path and make it absolute before doing the comparision to get a comparable string.
This commit is contained in:
@@ -126,11 +126,21 @@ generateOptimizationRemarkRegex(DiagnosticEngine &Diags, ArgList &Args,
|
||||
static void PrintArg(raw_ostream &OS, const char *Arg, StringRef TempDir) {
|
||||
const bool Escape = std::strpbrk(Arg, "\"\\$ ");
|
||||
|
||||
if (!TempDir.empty() && StringRef(Arg).startswith(TempDir)) {
|
||||
// Don't write temporary file names in the debug info. This would prevent
|
||||
// incremental llvm compilation because we would generate different IR on
|
||||
// every compiler invocation.
|
||||
Arg = "<temporary-file>";
|
||||
if (!TempDir.empty()) {
|
||||
llvm::SmallString<256> ArgPath{Arg};
|
||||
llvm::sys::fs::make_absolute(ArgPath);
|
||||
llvm::sys::path::native(ArgPath);
|
||||
|
||||
llvm::SmallString<256> TempPath{TempDir};
|
||||
llvm::sys::fs::make_absolute(TempPath);
|
||||
llvm::sys::path::native(TempPath);
|
||||
|
||||
if (StringRef(ArgPath).startswith(TempPath)) {
|
||||
// Don't write temporary file names in the debug info. This would prevent
|
||||
// incremental llvm compilation because we would generate different IR on
|
||||
// every compiler invocation.
|
||||
Arg = "<temporary-file>";
|
||||
}
|
||||
}
|
||||
|
||||
if (!Escape) {
|
||||
|
||||
Reference in New Issue
Block a user