LLVM CommandLine Library Grouping Flag

LLVM CommandLine library always group single character options, for example

llvm::cl::opt optA(“A”);
llvm::cl::opt optB(“B”);

-AB will be treated as equivalent to -A -B, and optA and optB will both be enabled.

But sometimes we don’t want the behaviour like this. I am enhancing my program and trying to handle the options with LLVM CommandLine library instead of the original flow.

I gradually add cl::opt<> or cl::list<> to handle some options, and I have llvm::cl::liststd::string unknownOptions(llvm::cl::Sink) to collect unknown options and pass them to the original flow.

However, if the arguments starts with character “A”(e.g. -Axxxxx), it will unexpectedly enable optA. As it shoule be an unknown option, we may handle it in a later version. If the arguments starts with “AB”(e.g. -ABxxxxxx), both optA and optB will be enabled.

I don’t know if a new MiscFlags option such as llvm::cl::NoGrouping can be provided so that the grouping can be disabled for single char options.

It seems like a reasonable feature request to me. But as is often the case with open-source projects, I suspect you would need to implement the feature yourself if you really want it.