[cfe-dev] What are canonical Types in Clang

Richard Smith richard at metafoo.co.uk
Mon Aug 11 11:37:54 PDT 2014

On Mon, Aug 11, 2014 at 10:29 AM, cedlemo <cedlemo at gmx.com> wrote:

>  When I parse this code with an AST parser:
> struct _poire {
>     int g;
>     char rouge; // tomate is probably one of your classes so I just changed the type of the field.};typedef struct _poire kudamono;
> I have a clang::TypedefDecl then I get the clang::QualType of the typedef with clang::TypedefDecl::getUnderlyingType()
> With the QualType if I use the getAsString method I can find the "struct
> _poire" std::string. All this is Ok.
> The problem is if I try to see if this type is a canonical type, with
> QualType::isCanonical(), it returns false.
> So I try to get the canonical type with
> QualType::getCanonicalType().getAsString() and it returns the same string
> "struct _poire".
OK, but presumably it's a different QualType value, and this one's
isCanonical() will return true?

> according to the clang reference on type
> http://clang.llvm.org/docs/InternalsManual.html#canonical-types , I
> thought that the isCanonical() should return true when no typedef is
> involved.
No, there are lots of other things that can make a type non-canonical.

> So what are really canonical type?
> (more informations on my problem can be seen here *http://stackoverflow.com/questions/25231080/clang-what-are-canonical-types
> <http://stackoverflow.com/questions/25231080/clang-what-are-canonical-types>*
> )
> Cedlemo
> _______________________________________________
> 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/20140811/4610299a/attachment.html>

More information about the cfe-dev mailing list