[cfe-dev] Syntactic order of CXXBaseOrMemberInitializers

Douglas Gregor dgregor at apple.com
Tue May 25 07:56:53 PDT 2010


On May 21, 2010, at 2:01 PM, Abramo Bagnara wrote:

> Il 21/05/2010 18:11, Douglas Gregor ha scritto:
>> 
>> On May 21, 2010, at 5:19 AM, Abramo Bagnara wrote:
>> 
>>> Il 20/05/2010 20:47, Douglas Gregor ha scritto:
>>>> 
>>>> On May 20, 2010, at 11:23 AM, Douglas Gregor wrote:
>>>> 
>>>>> 
>>>>> On May 20, 2010, at 10:26 AM, Abramo Bagnara wrote:
>>>>> 
>>>>>> Il 20/05/2010 18:52, Douglas Gregor ha scritto:
>>>>>>> 
>>>>>>> 
>>>>>>> Sent from my iPhone
>>>>>>> 
>>>>>>> On May 19, 2010, at 4:40 AM, Abramo Bagnara <abramo.bagnara at gmail.com> wrote:
>>>>>>> 
>>>>>>>> 
>>>>>>>> As currently the initializers are reordered to match member order in
>>>>>>>> record declaration there is no easy way for an AST consumer to know in
>>>>>>>> which order the initializers were written in the source file.
>>>>>>> 
>>>>>>> Originally, I had imagined that we would compare based on source locations, and perhaps add an "implicit" bit for implicitly-generated initializers. Does that not work?
>>>>>> 
>>>>>> We thought the same, but the fact that a sorting algorithm lead to a
>>>>>> worst case of O(n*log(n)) or O(n*2) calls to non trivial source location
>>>>>> comparison has worried us.
>>>>> 
>>>>> It seems highly unlikely that N will grow large enough for this to ever matter, since N should only include explicitly-written base classes. 
>>>> 
>>>> Hrm. I was thinking "base classes" rather than "base or member initializers."
>>>> 
>>>> Anyway, please go ahead with your original proposal to add an index field into CXXBaseOrMemberInitializer. We can do some shuffling to keep the structure the same size while still adding this field.
>>> 
>>> I've attached the patch for review/approval.
>>> <CXXBaseOrMemberInitializerOrder.patch>
>> 
>> Looks good. You could probably pack NumArrayIndices and SourceOrder into one 32-bit word to save storage.
> 
> What about to have:
> 
> bool isImplicit:1;
> unsigned NumArrayIndicesOrSourceOrder:15;
> 
> ?

Yes, that's good.

>> Also, would you like to update the AST printer to print the base and member initializers in order, now that the information is easier to get to?
> 
> I'm not confident with this area and however it's questionable what to
> do there: we could print also implicit initializer (often the AST
> printer print implicit things), we could print it in source order or in
> execution order, etc.

I like having the AST printer print the AST as we parsed it (without the implicit parts) to reflect our understanding of the source code. The AST dumper, on the other hand, should include the implicit nodes in its output.

	- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100525/713ccecf/attachment.html>


More information about the cfe-dev mailing list