[cfe-dev] Recovering an unique ID for an unqualified type

Manuel Klimek klimek at google.com
Mon Dec 3 09:46:37 PST 2012


On Mon, Dec 3, 2012 at 6:44 PM, Jordan Rose <jordan_rose at apple.com> wrote:

>
> On Dec 2, 2012, at 22:40 , Manuel Klimek <klimek at google.com> wrote:
>
> On Mon, Dec 3, 2012 at 12:29 AM, Sean Silva <silvas at purdue.edu> wrote:
>
>> > Does clang stores some sort of unique ID for type definitions? I could
>> > generate manually this id for each time I stumble upon a new QualType
>> but
>> > I'm looking if this is already made by the library.
>>
>> libclang's USR's are probably the closest thing to this, but I don't
>> think that is what you are looking for.
>>
>
> Inside one TU type pointers have identity - that is, there's only one
> Type* for the same type. That doesn't hold for QualTypes.
>
>
> It doesn't? QualTypes are PointerIntPairs (value objects); two QualTypes
> should be equal if they have the same qualifiers and the same underlying
> Type.
>

That means that QualTypes don't have pointer identity (was all I was trying
to say :) - sorry if that was not clear.


>
> Also, you have to decide if you want to take typedefs into consideration;
> if not, you should make sure to call getCanonicalType before comparing your
> QualTypes.
>
> Jordan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121203/2f95e8eb/attachment.html>


More information about the cfe-dev mailing list