[clang] [clang-tools-extra] [lld] [llvm] [llvm] Add subcommand support for OptTable (PR #155026)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 5 14:52:57 PDT 2025
================
@@ -534,6 +555,21 @@ InputArgList OptTable::internalParseArgs(
MissingArgIndex = MissingArgCount = 0;
unsigned Index = 0, End = ArgArr.size();
+ const Command *ActiveCommand = nullptr;
+
+ // Look for subcommand which is positional.
+ if (!Commands.empty() && Index < End) {
+ StringRef FirstArg = Args.getArgString(Index);
+ if (isInput(PrefixesUnion, FirstArg)) {
+ for (const auto &C : Commands) {
+ if (FirstArg == C.Name) {
+ ActiveCommand = &C;
+ break;
+ }
+ }
----------------
PiJoules wrote:
Alternatively, it looks like you have `getActiveCommand` below so maybe you could reuse it here.
https://github.com/llvm/llvm-project/pull/155026
More information about the llvm-commits
mailing list