jessevdk / cldoc

clang based documentation generator for C and C++
GNU General Public License v2.0
553 stars 59 forks source link

Typedefs not used for standard types in some contexts #50

Closed rhdunn closed 6 years ago

rhdunn commented 10 years ago

Given:

std::list<std::string> foo();

The XML output expands the typedef in the return type:

<return>
  <type name="std::list&lt;std::basic_string&lt;char&gt;, std::allocator&lt;std::basic_string&lt;char&gt; &gt; &gt;" qualifier=" const &amp;" />
</return>

In other contexts, e.g.:

void foo(const std::string &)

the argument type preserves the typedef:

  <type name="std::string" qualifier=" const &amp;" />

Both contexts should use the typedef alias. That is, the return type should be:

<return>
  <type name="std::list&lt;std::string, std::allocator&lt;std::string&gt; &gt;" qualifier=" const &amp;" />
</return>
rhdunn commented 10 years ago

This also applies for:

struct foo { operator FILE *(); }

where cldoc produces:

<conversionfunction id="foo::operator struct _IO_FILE *" name="operator struct _IO_FILE *">
  <return>
    <type name="FILE" qualifier="*" />
  </return>
</conversionfunction>
jessevdk commented 6 years ago

This should be fixed in latest master. This information appears to only be exposed correctly from libclang 4.0 and upwards, it seems this can't work correctly (information not being exposed) in 3.9. I'm considering only supporting 4.0+.