[cfe-dev] What are canonical Types in Clang

cedlemo cedlemo at gmx.com
Mon Aug 11 10:29:04 PDT 2014


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

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.

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

Cedlemo


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140811/0850635d/attachment.html>


More information about the cfe-dev mailing list