1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

[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
This commit is contained in:
Don Hinton 2019-05-03 18:56:25 +00:00
parent 9bba12d9eb
commit 2626ede61b
3 changed files with 8 additions and 2 deletions

View File

@ -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.

View File

@ -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() {

View File

@ -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!