aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/BackendUtil.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2025-09-18 14:53:40 -0700
committerGitHub <noreply@github.com>2025-09-18 14:53:40 -0700
commit152a2162a1a9c93358bb69ab839931d95b9537ad (patch)
tree287401779a7a607784aaa29c420d0c8ffeb682c8 /clang/lib/CodeGen/BackendUtil.cpp
parentcfaf23927c6b083646a431eb8eea2d286694c0a0 (diff)
downloadllvm-152a2162a1a9c93358bb69ab839931d95b9537ad.zip
llvm-152a2162a1a9c93358bb69ab839931d95b9537ad.tar.gz
llvm-152a2162a1a9c93358bb69ab839931d95b9537ad.tar.bz2
[llvm][clang] Pass VFS to `llvm::cl` command line handling (#159174)
This PR passes the VFS down to `llvm::cl` functions so that they don't assume the real file system.
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 8c99af2..77bf0c8 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -562,7 +562,8 @@ getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
return Options;
}
-static void setCommandLineOpts(const CodeGenOptions &CodeGenOpts) {
+static void setCommandLineOpts(const CodeGenOptions &CodeGenOpts,
+ vfs::FileSystem &VFS) {
SmallVector<const char *, 16> BackendArgs;
BackendArgs.push_back("clang"); // Fake program name.
if (!CodeGenOpts.DebugPass.empty()) {
@@ -582,8 +583,9 @@ static void setCommandLineOpts(const CodeGenOptions &CodeGenOpts) {
// FIXME: The command line parser below is not thread-safe and shares a global
// state, so this call might crash or overwrite the options of another Clang
// instance in the same process.
- llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
- BackendArgs.data());
+ llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1, BackendArgs.data(),
+ /*Overview=*/"", /*Errs=*/nullptr,
+ /*VFS=*/&VFS);
}
void EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
@@ -1260,7 +1262,7 @@ void EmitAssemblyHelper::RunCodegenPipeline(
void EmitAssemblyHelper::emitAssembly(BackendAction Action,
std::unique_ptr<raw_pwrite_stream> OS,
BackendConsumer *BC) {
- setCommandLineOpts(CodeGenOpts);
+ setCommandLineOpts(CodeGenOpts, CI.getVirtualFileSystem());
bool RequiresCodeGen = actionRequiresCodeGen(Action);
CreateTargetMachine(RequiresCodeGen);
@@ -1295,7 +1297,7 @@ runThinLTOBackend(CompilerInstance &CI, ModuleSummaryIndex *CombinedIndex,
ModuleToDefinedGVSummaries;
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
- setCommandLineOpts(CGOpts);
+ setCommandLineOpts(CGOpts, CI.getVirtualFileSystem());
// We can simply import the values mentioned in the combined index, since
// we should only invoke this using the individual indexes written out