================
@@ -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:

nit: Just a personal preference so feel free to ignore, but I think this looks 
cleaner

```
auto found = std::find_if(Commands.begin(), Commands.end(), [&](const auto &C){
  return FirstArg == C.Name
});
ActiveCommand = found == Commands.end() ? nullptr : *found;
```

https://github.com/llvm/llvm-project/pull/155026
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to