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

Manuel Klimek klimek at google.com
Sun Dec 2 22:40:47 PST 2012


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.

Cheers,
/Manuel



> > Another question, Is possible to verify if a QualType is of some class X?
> > like:
> >
> > QualType t;
> >
> > if (t.isofclass<std::string>()) {
> > }
>
> This is not generally possible. The compiler is on a "meta" level from
> the code being compiled, so types inside the source code of the
> compiler are not generally meaningful in this sense. You can ask "is
> this class called `string` in namespace `std`?", but arbitrary C++
> types "inside the compiler" are not related to types in the code being
> compiled. It is basically a Godel, Escher, Bach scenario.
>
> -- Sean Silva
>
> On Sun, Dec 2, 2012 at 2:09 PM, Victor Vicente de Carvalho
> <victor.v.carvalho at gmail.com> 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.
> >
> > Another question, Is possible to verify if a QualType is of some class X?
> > like:
> >
> > QualType t;
> >
> > if (t.isofclass<std::string>()) {
> > }
> >
> >
> > Victor
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> >
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121203/4f0daa95/attachment.html>


More information about the cfe-dev mailing list