summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Hinton <hintonda@gmail.com>2019-05-03 18:56:25 +0000
committerDon Hinton <hintonda@gmail.com>2019-05-03 18:56:25 +0000
commitf6eac2dd3b3adec4ea9f31316282d11354cf2f4a (patch)
tree76d51b1ce597405e2c2a4215e84bb65962996789
parent83c95b1ec80df675d40b302fbd21e3c9da83f086 (diff)
downloadbcm5719-llvm-f6eac2dd3b3adec4ea9f31316282d11354cf2f4a.tar.gz
bcm5719-llvm-f6eac2dd3b3adec4ea9f31316282d11354cf2f4a.zip
[CommandLine] Enable Grouping for short options by default. Part 4 of 5
Summary: This change enables `cl::Grouping` for short options -- options with names of a single character. This is consistent with GNU getopt behavior. Reviewers: rnk, MaskRay Reviewed By: MaskRay Subscribers: thopre, cfe-commits, MaskRay, rupprecht, hiraditya, llvm-commits Tags: #llvm, #clang Differential Revision: https://reviews.llvm.org/D61270 llvm-svn: 359917
-rw-r--r--llvm/include/llvm/Support/CommandLine.h6
-rw-r--r--llvm/lib/Support/CommandLine.cpp2
-rw-r--r--llvm/test/tools/llvm-readobj/merged.test2
3 files changed, 8 insertions, 2 deletions
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h
index 7951128a48a..74f5de6621e 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -1200,7 +1200,11 @@ template <> struct applicator<FormattingFlags> {
};
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.
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 1ca31b69c78..ff53fefefea 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -421,6 +421,8 @@ void Option::setArgStr(StringRef S) {
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() {
diff --git a/llvm/test/tools/llvm-readobj/merged.test b/llvm/test/tools/llvm-readobj/merged.test
index 0fcc14f1f95..a6f567cda6c 100644
--- a/llvm/test/tools/llvm-readobj/merged.test
+++ b/llvm/test/tools/llvm-readobj/merged.test
@@ -10,4 +10,4 @@ RUN: FileCheck %s --input-file %t.merged
RUN: not llvm-readobj -aeWhSrnudlVgIs %p/Inputs/trivial.obj.elf-i386 2>&1 | FileCheck %s --check-prefix=UNKNOWN
CHECK-NOT: Unknown command line argument
-UNKNOWN: Unknown command line argument
+UNKNOWN: for the --section-headers option: may only occur zero or one times!
OpenPOWER on IntegriCloud