[llvm] [Support] Remove cl::Grouping (PR #224958)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 19:50:21 PDT 2026
================
@@ -748,92 +738,44 @@ bool llvm::cl::ProvidePositionalOption(Option *Handler, StringRef Arg, int i) {
return ProvideOption(Handler, Handler->ArgStr, Arg, 0, nullptr, Dummy);
}
-// getOptionPred - Check to see if there are any options that satisfy the
-// specified predicate with names that are the prefixes in Name. This is
-// checked by progressively stripping characters off of the name, checking to
-// see if there options that satisfy the predicate. If we find one, return it,
-// otherwise return null.
-//
-static Option *getOptionPred(StringRef Name, size_t &Length,
- bool (*Pred)(const Option *),
- const OptionsMapTy &OptionsMap) {
- auto OMI = OptionsMap.find(Name);
- if (OMI != OptionsMap.end() && !Pred(OMI->second))
- OMI = OptionsMap.end();
-
- // Loop while we haven't found an option and Name still has at least two
- // characters in it (so that the next iteration will not be the empty
- // string.
- while (OMI == OptionsMap.end() && Name.size() > 1) {
- Name = Name.drop_back();
- OMI = OptionsMap.find(Name);
- if (OMI != OptionsMap.end() && !Pred(OMI->second))
- OMI = OptionsMap.end();
- }
-
- if (OMI != OptionsMap.end() && Pred(OMI->second)) {
- Length = Name.size();
- return OMI->second; // Found one!
- }
- return nullptr; // No option found!
-}
-
-/// HandlePrefixedOrGroupedOption - The specified argument string (which started
-/// with at least one '-') does not fully match an available option. Check to
-/// see if this is a prefix or grouped option. If so, split arg into output an
-/// Arg/Value pair and return the Option to parse it with.
-static Option *HandlePrefixedOrGroupedOption(StringRef &Arg, StringRef &Value,
- bool &ErrorParsing,
- const OptionsMapTy &OptionsMap) {
+// Find the cl::Prefix or cl::AlwaysPrefix option whose name is the longest
+// prefix of Name.
+static Option *findPrefixOption(StringRef Name, size_t &Length,
+ const OptionsMapTy &OptionsMap) {
+ for (; !Name.empty(); Name = Name.drop_back()) {
+ Option *O = OptionsMap.lookup(Name);
+ if (O && (O->getFormattingFlag() == cl::Prefix ||
+ O->getFormattingFlag() == cl::AlwaysPrefix)) {
+ Length = Name.size();
+ return O;
+ }
+ }
+ return nullptr;
+}
+
+/// HandlePrefixedOption - The specified argument string (which started with at
----------------
MaskRay wrote:
Removed
https://github.com/llvm/llvm-project/pull/224958
More information about the llvm-commits
mailing list