[clang] 3625d2d - [clang] Use VFS to get CWD in `-cc1as` (#173289)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 5 10:54:11 PST 2026
Author: Jan Svoboda
Date: 2026-01-05T10:54:07-08:00
New Revision: 3625d2d51575f984803e44b04e2ddf6f5d1fd21d
URL: https://github.com/llvm/llvm-project/commit/3625d2d51575f984803e44b04e2ddf6f5d1fd21d
DIFF: https://github.com/llvm/llvm-project/commit/3625d2d51575f984803e44b04e2ddf6f5d1fd21d.diff
LOG: [clang] Use VFS to get CWD in `-cc1as` (#173289)
This PR uses the VFS to get the current working directory in `-cc1as`
invocations, preventing sandbox violations.
Added:
Modified:
clang/tools/driver/cc1as_main.cpp
Removed:
################################################################################
diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp
index dfff194f83106..cb41ffc60d132 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -520,9 +520,8 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
Ctx.setCompilationDir(Opts.DebugCompilationDir);
else {
// If no compilation dir is set, try to use the current directory.
- SmallString<128> CWD;
- if (!sys::fs::current_path(CWD))
- Ctx.setCompilationDir(CWD);
+ if (auto CWD = VFS->getCurrentWorkingDirectory())
+ Ctx.setCompilationDir(*CWD);
}
if (!Opts.DebugPrefixMap.empty())
for (const auto &KV : Opts.DebugPrefixMap)
More information about the cfe-commits
mailing list