title: What are canonical types in Clang?
body: <p>I have a simple header parser based on clang and I get the typedefs from some source.</p>
  
  <pre><code>struct _poire {
  int g;
  tomate rouge;
  };
  typedef struct _poire kudamono;
  </code></pre>
  
  <p>After parsing this I have a <code>clang::TypedefDecl</code> then I get the <code>clang::QualType</code> of the typedef with <code>clang::TypedefDecl::getUnderlyingType()</code></p>
  
  <p>With the <code>QualType</code> if I use the <code>getAsString</code> method I can find the "struct _poire" <code>std::string</code>. All this is Ok. </p>
  
  <p>The problem is if I try to see if this type is a canonical type, with <code>QualType::isCanonical()</code>, it returns false.</p>
  
  <p>So I try to get the canonical type with <code>QualType::getCanonicalType().getAsString()</code> and it returns the same string "struct _poire".</p>
  
  <p>according to the clang reference on type <a href="http://clang.llvm.org/docs/InternalsManual.html#canonical-types">http://clang.llvm.org/docs/InternalsManual.html#canonical-types</a> , I thought that the isCanonical() should return 
  true when no typedef is involved.</p>
  
  <p>So what are really canonical type?</p>