[llvm-commits] [llvm] r160170 - /llvm/trunk/include/llvm/Support/CommandLine.h

Chandler Carruth chandlerc at google.com
Mon Jul 16 06:28:19 PDT 2012


On Mon, Jul 16, 2012 at 6:24 AM, Alexander Kornienko <alexfh at google.com>wrote:

> On Mon, Jul 16, 2012 at 3:10 PM, Chandler Carruth <chandlerc at google.com>wrote:
>
>> On Mon, Jul 16, 2012 at 6:02 AM, Alexander Kornienko <alexfh at google.com>wrote:
>>
>>>
>>> On Fri, Jul 13, 2012 at 3:06 PM, Duncan Sands <baldrick at free.fr> wrote:
>>>
>>>> Hi Alexander,
>>>> > Initializers for some fields were missing in Option::Option
>>>>
>>>> did it matter?  If so, please add a testcase.  If not, why this change?
>>>>
>>> This did matter. It caused random crashes in case cl::opt was a member
>>> of non-POD class.
>>>
>>
>> Hold on, a *member*? 'cl::opt' objects are supposed to be globals, not
>> members.
>>
> We need it as a member to make a class which handles a common subset of
> command-line options for several clang tools. In a close future we'll need
> a control on which options should be enabled and which not. So we can't do
> it with global variables. Why can't we use it as a member?
>

Errr... Ok, this is something we should discuss in more depth.

Essentially, it's not that you necessarily can't, it's that the library was
never designed with that use case in mind. It's completely outside the
contract of the library, and so random things are likely to continue
breaking. If this the correct design, we need to at least extend the
library with unittests to check its behavior in that context. These
unittests would then be what you would run under Valgrind in order to
detect the failure.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120716/a2e15126/attachment.html>


More information about the llvm-commits mailing list