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

Sean Silva silvas at purdue.edu
Sun Dec 2 15:29:17 PST 2012


> 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.

> 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
>



More information about the cfe-dev mailing list