[clang] [clang-tools-extra] [llvm] [llvm][clang] Pass VFS to `llvm::cl` command line handling (PR #159174)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 16 13:58:14 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- clang-tools-extra/clangd/tool/ClangdMain.cpp clang/lib/CodeGen/BackendUtil.cpp clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp clang/tools/driver/cc1as_main.cpp clang/tools/driver/driver.cpp llvm/include/llvm/Support/CommandLine.h llvm/lib/Support/CommandLine.cpp llvm/tools/obj2yaml/obj2yaml.cpp llvm/tools/yaml2obj/yaml2obj.cpp llvm/unittests/Support/CommandLineTest.cpp llvm/utils/FileCheck/FileCheck.cpp llvm/utils/split-file/split-file.cpp
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 87ffaf154..7390d7d61 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -364,10 +364,10 @@ int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) {
if (!SetBackdoorDriverOutputsFromEnvVars(TheDriver))
return 1;
- auto ExecuteCC1WithContext =
- [&ToolContext, &VFS](SmallVectorImpl<const char *> &ArgV) {
- return ExecuteCC1Tool(ArgV, ToolContext, VFS);
- };
+ auto ExecuteCC1WithContext = [&ToolContext,
+ &VFS](SmallVectorImpl<const char *> &ArgV) {
+ return ExecuteCC1Tool(ArgV, ToolContext, VFS);
+ };
if (!UseNewCC1Process) {
TheDriver.CC1Main = ExecuteCC1WithContext;
// Ensure the CC1Command actually catches cc1 crashes
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 72b98909a..12a8d0c3a 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -1505,12 +1505,9 @@ void CommandLineParser::ResetAllOptionOccurrences() {
}
}
-bool CommandLineParser::ParseCommandLineOptions(int argc,
- const char *const *argv,
- StringRef Overview,
- raw_ostream *Errs,
- vfs::FileSystem *VFS,
- bool LongOptionsUseDoubleDash) {
+bool CommandLineParser::ParseCommandLineOptions(
+ int argc, const char *const *argv, StringRef Overview, raw_ostream *Errs,
+ vfs::FileSystem *VFS, bool LongOptionsUseDoubleDash) {
assert(hasOptions() && "No options specified!");
ProgramOverview = Overview;
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index 10b7d1409..88e644519 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -1915,20 +1915,20 @@ TEST(CommandLineTest, LongOptions) {
// Fails because `-ab` is treated as `-a -b`, so `-a` is seen twice, and
// `val1` is unexpected.
- EXPECT_FALSE(cl::ParseCommandLineOptions(4, args1, StringRef(),
- &OS, nullptr, nullptr, true));
+ EXPECT_FALSE(cl::ParseCommandLineOptions(4, args1, StringRef(), &OS, nullptr,
+ nullptr, true));
EXPECT_FALSE(Errs.empty()); Errs.clear();
cl::ResetAllOptionOccurrences();
// Works because `-a` is treated differently than `--ab`.
- EXPECT_TRUE(cl::ParseCommandLineOptions(4, args2, StringRef(),
- &OS, nullptr, nullptr, true));
+ EXPECT_TRUE(cl::ParseCommandLineOptions(4, args2, StringRef(), &OS, nullptr,
+ nullptr, true));
EXPECT_TRUE(Errs.empty()); Errs.clear();
cl::ResetAllOptionOccurrences();
// Works because `-ab` is treated as `-a -b`, and `--ab` is a long option.
- EXPECT_TRUE(cl::ParseCommandLineOptions(4, args3, StringRef(),
- &OS, nullptr, nullptr, true));
+ EXPECT_TRUE(cl::ParseCommandLineOptions(4, args3, StringRef(), &OS, nullptr,
+ nullptr, true));
EXPECT_TRUE(OptA);
EXPECT_TRUE(OptBLong);
EXPECT_STREQ("val1", OptAB.c_str());
``````````
</details>
https://github.com/llvm/llvm-project/pull/159174
More information about the llvm-commits
mailing list