[LLVMdev] Addressing const reference in ArrayRef

David Blaikie dblaikie at gmail.com
Fri Aug 22 10:53:58 PDT 2014


On Fri, Aug 22, 2014 at 10:50 AM, Reid Kleckner <rnk at google.com> wrote:
> On Fri, Aug 22, 2014 at 10:43 AM, David Blaikie <dblaikie at gmail.com> wrote:
>>
>> Yep - the convenience of one-element->ArrayRef is "cute" at best, I
>> think. Having to wrap it doesn't seem detrimental. Would have to look
>> at some numbers, though (if we could easily gather the number of
>> instances of this - I'm not sure of the easiest way to do that, given
>> the build system likes to stop after it sees an error).
>>
>> I'm not sure if the "Temp" in the name would be a sufficient
>> deterrent, but maybe.
>
>
> Wow, I think I finally understand how the temporary is being created.

Subtle, innit?

>
> Can we get by without the single element constructor? Callers would have to
> write:
> const char *strs[] = { "string" };
> foo(strs);

We can get by - I think that'd be a tad verbose though. But we don't
quite have a feel for just how many of these
single-element-conversions there are.

> Instead of foo("string"), which is subtle anyway.

Yeah - I think it's "cute" at best, and wouldn't mind something more
explicit - I'm just not sure defining a whole local array is the right
tradeoff either.



More information about the llvm-dev mailing list