[cfe-commits] [PATCH] PR9812: _Bool != bool

Douglas Gregor dgregor at apple.com
Thu Jun 23 07:15:57 PDT 2011


Sent from my iPhone

On Jun 23, 2011, at 12:05 AM, Enea Zaffanella <zaffanella at cs.unipr.it> wrote:

> Il 23/06/2011 02:31, Richard Smith ha scritto:
> [...]
>>> The goal of BuiltinTypeLoc is to provide quite accurate information
>>> about the syntax actually used in the sources and it is therefore
>>> essential to distinguish between TST__Bool and TST_bool.
>>> 
>>> To this end, the thing to do is to change the implementation of
>>> 
>>> bool needsExtraLocalData() const;
>>> 
>>> so as to return true for BuiltinType::Bool.
>> 
>> I'm not so keen on this approach: it would inflate both the in-memory
>> representation of every bool type and increase the size of the serialized
>> AST. If we have no intention to begin supporting both bool and _Bool in
>> the same language, I'd prefer to pass LangOptions into
>> BuiltinTypeLoc::getWrittenTypeSpec and use that to reconstruct the correct
>> type, or find a spare bit somewhere.
>> 
>> Richard
> 
> That is indeed a better approach that will work perfectly provided _Bool
> and bool will never occur together (I have seen so many language
> extensions supported by compilers, hence I was not excluding this
> possibility a priori).

Both bool and _Bool can appear in the same translation unit, so using LangOptions won't be perfect. 

That said, I'm not willing to spend a bit in BuiltinTypeLoc on it. A spare bit or some Type-level sugar node would be fine. 

  - Doug



More information about the cfe-commits mailing list