[llvm] [Option] Allow subcommand names as positional arguments (PR #227077)
Prabhu Rajasekaran via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 6 15:02:21 PDT 2026
================
@@ -289,13 +289,19 @@ class ArgList {
/// subcommands.
/// \param HandleOtherPositionals - A callback for the case where positional
/// arguments that are not subcommands are present.
+ /// \param AllowSubCommandNamesAsPositionals - If true, only the first
+ /// positional argument that matches a subcommand name is the subcommand.
+ /// Later ones are passed to \p HandleOtherPositionals instead of being
+ /// reported as multiple subcommands, so that e.g. `foo foo` is subcommand
+ /// `foo` with a positional argument `foo`.
/// \return The name of the subcommand found. If no subcommand is found,
/// this returns an empty StringRef. If multiple subcommands are found, the
/// first one is returned.
----------------
Prabhuk wrote:
The `\return` documentation is not accurate. Can you please fix the documentation for this as well?
It says that if multiple subcommands are found, the first one is returned. What actually happens is that we call `HandleMultipleSubcommands` and then return an empty `StringRef`. So for `foo foo` the doc says you'd get `"foo"` back, but you get `""`. The test case 10 you added in this patch asserts exactly that.
https://github.com/llvm/llvm-project/pull/227077
More information about the llvm-commits
mailing list