DriverTool: adjust argv[0] scanning for CAS

Ensure that we nativize the path and consider only the filename starting
prefix to account for file suffixes (e.g. `.exe` on Windows). This
ensures that we properly support other platforms.
This commit is contained in:
Saleem Abdulrasool
2025-12-08 08:12:32 -06:00
parent 3e2943ff62
commit 070916fef3

View File

@@ -196,7 +196,9 @@ private:
}
// drop swift-frontend executable path and leading `-frontend` from
// command-line.
if (StringRef(FrontendArgs[0]).ends_with("swift-frontend"))
llvm::SmallString<261> path;
llvm::sys::path::native(Twine{FrontendArgs[0]}, path);
if (llvm::sys::path::filename(path).starts_with("swift-frontend"))
FrontendArgs.erase(FrontendArgs.begin());
if (StringRef(FrontendArgs[0]) == "-frontend")
FrontendArgs.erase(FrontendArgs.begin());