https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/175097
>From 3d88763270f0205ed50d024b249f306166518b4a Mon Sep 17 00:00:00 2001 From: Jan Svoboda <[email protected]> Date: Thu, 8 Jan 2026 15:31:32 -0800 Subject: [PATCH 1/3] [clang] Use the VFS in `CrossTranslationUnitContext` --- clang/lib/CrossTU/CrossTranslationUnit.cpp | 23 ++++++++++++++++++++-- llvm/CMakeLists.txt | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp index a3fc2cf6bfb3c..ad2defb233a7a 100644 --- a/clang/lib/CrossTU/CrossTranslationUnit.cpp +++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp @@ -623,7 +623,26 @@ CrossTranslationUnitContext::ASTLoader::loadFromSource( return CreateASTUnitFromCommandLine( CommandLineArgs.begin(), (CommandLineArgs.end()), CI.getPCHContainerOperations(), DiagOpts, Diags, - CI.getHeaderSearchOpts().ResourceDir); + CI.getHeaderSearchOpts().ResourceDir, + /*StorePreamblesInMemory=*/false, + /*PreambleStoragePath=*/StringRef(), + /*OnlyLocalDecls=*/false, + /*CaptureDiagnostics=*/CaptureDiagsKind::None, + /*RemappedFiles=*/{}, + /*RemappedFilesKeepOriginalName=*/true, + /*PrecompilePreambleAfterNParses=*/0, + /*TUKind=*/TU_Complete, + /*CacheCodeCompletionResults=*/false, + /*IncludeBriefCommentsInCodeCompletion=*/false, + /*AllowPCHWithCompilerErrors=*/false, + /*SkipFunctionBodies=*/SkipFunctionBodiesScope::None, + /*SingleFileParse=*/false, + /*UserFilesAreVolatile=*/false, + /*ForSerialization=*/false, + /*RetainExcludedConditionalBlocks=*/false, + /*ModuleFormat=*/std::nullopt, + /*ErrAST=*/nullptr, + /*VFS=*/CI.getVirtualFileSystemPtr()); } llvm::Expected<InvocationListTy> @@ -710,7 +729,7 @@ llvm::Error CrossTranslationUnitContext::ASTLoader::lazyInitInvocationList() { return llvm::make_error<IndexError>(PreviousParsingResult); llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileContent = - llvm::MemoryBuffer::getFile(InvocationListFilePath); + CI.getVirtualFileSystem().getBufferForFile(InvocationListFilePath); if (!FileContent) { PreviousParsingResult = index_error_code::invocation_list_file_not_found; return llvm::make_error<IndexError>(PreviousParsingResult); diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index f0e4f5d7d6f60..467bc5ebd996c 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -697,7 +697,7 @@ else() option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON) endif() -option(LLVM_ENABLE_IO_SANDBOX "Enable IO sandboxing in supported tools" OFF) +option(LLVM_ENABLE_IO_SANDBOX "Enable IO sandboxing in supported tools" ON) # TODO: Set to OFF before merging. option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF) set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING >From 522c8686cee66830fe823e11ed4568f4efc255b6 Mon Sep 17 00:00:00 2001 From: Jan Svoboda <[email protected]> Date: Fri, 9 Jan 2026 09:41:16 -0800 Subject: [PATCH 2/3] Fix Linux distro detection earlier --- clang/lib/CrossTU/CrossTranslationUnit.cpp | 24 ++++------------------ 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp index ad2defb233a7a..7496deb74cb67 100644 --- a/clang/lib/CrossTU/CrossTranslationUnit.cpp +++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp @@ -24,6 +24,7 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Option/ArgList.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/IOSandbox.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Path.h" #include "llvm/Support/YAMLParser.h" @@ -620,29 +621,12 @@ CrossTranslationUnitContext::ASTLoader::loadFromSource( auto Diags = llvm::makeIntrusiveRefCnt<DiagnosticsEngine>(DiagID, *DiagOpts, DiagClient); + // This runs the driver which isn't expected to be free of sandbox violations. + auto BypassSandbox = llvm::sys::sandbox::scopedDisable(); return CreateASTUnitFromCommandLine( CommandLineArgs.begin(), (CommandLineArgs.end()), CI.getPCHContainerOperations(), DiagOpts, Diags, - CI.getHeaderSearchOpts().ResourceDir, - /*StorePreamblesInMemory=*/false, - /*PreambleStoragePath=*/StringRef(), - /*OnlyLocalDecls=*/false, - /*CaptureDiagnostics=*/CaptureDiagsKind::None, - /*RemappedFiles=*/{}, - /*RemappedFilesKeepOriginalName=*/true, - /*PrecompilePreambleAfterNParses=*/0, - /*TUKind=*/TU_Complete, - /*CacheCodeCompletionResults=*/false, - /*IncludeBriefCommentsInCodeCompletion=*/false, - /*AllowPCHWithCompilerErrors=*/false, - /*SkipFunctionBodies=*/SkipFunctionBodiesScope::None, - /*SingleFileParse=*/false, - /*UserFilesAreVolatile=*/false, - /*ForSerialization=*/false, - /*RetainExcludedConditionalBlocks=*/false, - /*ModuleFormat=*/std::nullopt, - /*ErrAST=*/nullptr, - /*VFS=*/CI.getVirtualFileSystemPtr()); + CI.getHeaderSearchOpts().ResourceDir); } llvm::Expected<InvocationListTy> >From 1f901d288acec7f7c282ef3f9822d5c10006fbc4 Mon Sep 17 00:00:00 2001 From: Jan Svoboda <[email protected]> Date: Fri, 9 Jan 2026 10:16:39 -0800 Subject: [PATCH 3/3] Revert CMake change --- llvm/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 467bc5ebd996c..f0e4f5d7d6f60 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -697,7 +697,7 @@ else() option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON) endif() -option(LLVM_ENABLE_IO_SANDBOX "Enable IO sandboxing in supported tools" ON) # TODO: Set to OFF before merging. +option(LLVM_ENABLE_IO_SANDBOX "Enable IO sandboxing in supported tools" OFF) option(LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF) set(LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
