diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -1205,7 +1205,11 @@ }; template <> struct applicator { - 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 --- a/llvm/lib/Support/CommandLine.cpp +++ b/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() {