[PATCH] Allow for the use of StringRef command line options instead of cl::opt<std::string>

Puyan Lotfi plotfi at apple.com
Fri Oct 4 11:23:51 PDT 2013

On Oct 4, 2013, at 11:13 AM, Chandler Carruth <chandlerc at google.com> wrote:

> On Fri, Oct 4, 2013 at 2:12 PM, Puyan Lotfi <plotfi at apple.com> wrote:
> It still seems to me that there should be the option of passing argv directly without having copies. Most of the tools don’t need duplicates managed and a lot of clang at the moment is leaking the -mllvm args as well so that’s the same case. I think it would be good to be able to call ParseCommandLineOptioms(argc, argv, “Foo tool\n”, false /* makePersistentCopies=false */);  (where the default behavior is to make dupes) and just not have any dupes generated in the current context as an option.
> You say a few times that there should be this option or that it would be good to have, but you never say *why*, or address the reasons I gave for why not.

The reason why I think this option is good is to avoid allocating memory twice and avoid calling malloc when the strings are already going to persist (despite the small performance impact). I understand your reasons for not wanting a buggy interface that clients would use and have all kinds of unexpected use-after-free bugs, but I’m not proposing this as a default. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131004/959ccc5b/attachment.html>

More information about the llvm-commits mailing list