<div dir="ltr">+benjamin who has added a new function that should also help on windows (because it gets argv[0])<br><br><div class="gmail_quote"><div dir="ltr">On Wed, Feb 24, 2016 at 9:09 AM Jacob Carlborg via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2016-02-23 19:23, barbara via cfe-dev wrote:<br>
> We have not found a tutorial or any documentation addressing our<br>
> requirement to use libClang for parsing C++ source and full comments. We<br>
> are currently using libClang 3.6 for testing however moving to 3.7 is<br>
> possible although we would rather wait for 3.8.<br>
><br>
> At the present time we have code to walk the AST and obtain cursors and<br>
> tokens for a sample C++ header. The following are the initial problems<br>
> we have encountered.<br>
><br>
> 1) Locate C++ standard headers<br>
><br>
> On Debian we did not have to pass any parameters to libClang for it to<br>
> locate the C++ standard header files.<br>
><br>
> On Windows, I had to pass six include lines which referenced GCC std<br>
> header files. This works but it will be cumbersome for our users. We<br>
> talked with a few people at the last llvm meeting it was mentioned<br>
> there might be some enhancements for detecting the system headers.<br>
><br>
> Do anyone have ideas or suggestion about this?<br>
<br>
If your tool can detect the headers you can always pass in additional<br>
flags to the clang_parseTranslationUnit2 function. You could also ship<br>
the headers with your tool to avoid the users having to install the<br>
developer tools for the platform. It's even possible to embed headers<br>
the executable itself. I'm doing that with some of the internal Clang<br>
headers, see [2][3].<br>
<br>
> 2) We need to retrieve all the comments and using "cursors" this has<br>
> not worked. We can easily generate a list of the tokens and walking<br>
> these appear to show the comments, however this feels very awkward and<br>
> slow. We understand the basic idea of cursors and tokens. We are not<br>
> sure about the pros and cons of each approach.<br>
<br>
There's a complete module for comment introspection [1]. I have not<br>
tried it myself yet but it looks quite extensive.<br>
<br>
> 3) Is the -Wdocumentation flag passed to clang when building. Or is<br>
> this flag supposed to be passed to libClang? Will this provide us with<br>
> more of the user comments? It appeared to to have no effect.<br>
<br>
If the comment introspection API does not provide the data you need you<br>
could try the CXTranslationUnit_DetailedPreprocessingRecord option for<br>
the clang_parseTranslationUnit2 function.<br>
<br>
[1] <a href="http://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html" rel="noreferrer" target="_blank">http://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html</a><br>
[2]<br>
<a href="http://clang-developers.42468.n3.nabble.com/Builtin-headers-td4049705.html#message4049716" rel="noreferrer" target="_blank">http://clang-developers.42468.n3.nabble.com/Builtin-headers-td4049705.html#message4049716</a><br>
[3]<br>
<a href="http://clang-developers.42468.n3.nabble.com/Builtin-headers-td4049705.html#message4049772" rel="noreferrer" target="_blank">http://clang-developers.42468.n3.nabble.com/Builtin-headers-td4049705.html#message4049772</a><br>
<br>
--<br>
/Jacob Carlborg<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>