[clang] [clang] Use VFS to get CWD in `-cc1as` (PR #173289)
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 22 09:48:07 PST 2025
https://github.com/jansvoboda11 created https://github.com/llvm/llvm-project/pull/173289
This PR uses the VFS to get the current working directory in `-cc1as` invocations, preventing sandbox violations.
>From c0ffbf8b957a0ea30e66a7613ae6300413abf3aa Mon Sep 17 00:00:00 2001
From: Jan Svoboda <jan_svoboda at apple.com>
Date: Mon, 22 Dec 2025 09:47:16 -0800
Subject: [PATCH] [clang] Use VFS to get CWD in `-cc1as`
---
clang/tools/driver/cc1as_main.cpp | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
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