SmallString for CommandLine options?

I’ve managed to eliminate nearly all uses of std::string from my frontend. About the only ones remaining are all of the occurrences of cl::optstd::string. Is it likely that at some point we’ll see support for SmallString in the command-line lib?

Hi,

It looks like quite a small diff to add SmallString support to cl – just subclass (or copy-paste) the template specialization for std::string.

Perhaps you could have a go at adding the support yourself and sending a patch?

Cheers,

James

The better fix is to switch cl::opt to allow StringRef: there is no specific reason to copy strings out of argv. The only thing to watch out for is the "parsecommandlineoptions" API, which doesn't necessarily own the underlying string pointers.

-Chris

I’ve managed to eliminate nearly all uses of std::string from my frontend. About the only ones remaining are all of the occurrences of cl::optstd::string. Is it likely that at some point we’ll see support for SmallString in the command-line lib?

The better fix is to switch cl::opt to allow StringRef: there is no specific reason to copy strings out of argv. The only thing to watch out for is the “parsecommandlineoptions” API, which doesn’t necessarily own the underlying string pointers.

It looks like it uses StringRef already internally. Although it also appears to use a mix of std::vector and SmallVector. I haven’t really looked at it that deeply.