[clang] [clang] Use VFS to get CWD in `-cc1as` (PR #173289)

via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 22 09:48:36 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)

<details>
<summary>Changes</summary>

This PR uses the VFS to get the current working directory in `-cc1as` invocations, preventing sandbox violations.

---
Full diff: https://github.com/llvm/llvm-project/pull/173289.diff


1 Files Affected:

- (modified) clang/tools/driver/cc1as_main.cpp (+2-3) 


``````````diff
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)

``````````

</details>


https://github.com/llvm/llvm-project/pull/173289


More information about the cfe-commits mailing list