[PATCH] D61270: [CommandLine] Enable Grouping for short options by default.
Don Hinton via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 29 10:32:29 PDT 2019
hintonda created this revision.
hintonda added a reviewer: rnk.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
This change enables `cl::Grouping` for short options --
options with names of a single character. This is consistent with GNU
getopt behavior.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D61270
Files:
llvm/include/llvm/Support/CommandLine.h
llvm/lib/Support/CommandLine.cpp
Index: llvm/lib/Support/CommandLine.cpp
===================================================================
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -392,6 +392,8 @@
GlobalParser->updateArgStr(this, S);
assert((S.empty() || S[0] != '-') && "Option can't start with '-");
ArgStr = S;
+ if (ArgStr.size() == 1)
+ setMiscFlag(Grouping);
}
void Option::reset() {
Index: llvm/include/llvm/Support/CommandLine.h
===================================================================
--- llvm/include/llvm/Support/CommandLine.h
+++ llvm/include/llvm/Support/CommandLine.h
@@ -1205,7 +1205,11 @@
};
template <> struct applicator<MiscFlags> {
- static void opt(MiscFlags MF, Option &O) { O.setMiscFlag(MF); }
+ static void opt(MiscFlags MF, Option &O) {
+ assert((MF != Grouping || O.ArgStr.size() == 1) &&
+ "cl::Grouping can only apply to single charater Options.");
+ O.setMiscFlag(MF);
+ }
};
// apply method - Apply modifiers to an option in a type safe way.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61270.197141.patch
Type: text/x-patch
Size: 1034 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190429/ce7b79c2/attachment.bin>
More information about the llvm-commits
mailing list