On Wed, Oct 17, 2012 at 6:50 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

(readding cfe-dev)<br>
<br>
<br>
<br>
On Wed, Oct 17, 2012 at 9:42 AM, Mohammad Adil <<a href="mailto:madil90@gmail.com" target="_blank">madil90@gmail.com</a>> wrote:<br>
> What I am trying to do is to make a small program which parses the AST and<br>
> does some rewriting to output modified code. How will I use the Driver in<br>
> this case? All I want to do is to parse the AST.<br>
<br>
I don't know off-hand what the best way to integrate the Driver's<br>
lib/header discovery is, just that that's where the logic is.<br>
<br>
The focus of Clang development with regard to "tools" like the one you<br>
described is the Tooling infrastructure (overview of options & a link<br>
to libTooling-specific information can be found here:<br>
<a href="http://clang.llvm.org/docs/Tooling.html" target="_blank">http://clang.llvm.org/docs/Tooling.html</a> ). I'm not sure if that meets<br>
the "standalone execution" scenario that you seem to be going for -<br>
it's ideally meant to integrate with code already building using an<br>
existing build system that has been modified to generate a database of<br>
compilation commands. I /think/ it should also work standalone & still<br>
do all the driver-based discovery, but I could be wrong.<br></blockquote><div><br></div><div>It does not fully do the driver-based discovery, but it'll usually work with the same flags that you provide to a normal clang call - and you can always specify options after "--" if you build the tool like in the tutorials.</div>
<div><br></div><div>Cheers,</div><div>/Manuel</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><br>
> On Wed, Oct 17, 2012 at 9:39 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
>><br>
>> On Wed, Oct 17, 2012 at 9:29 AM, madil90 <<a href="mailto:madil90@gmail.com" target="_blank">madil90@gmail.com</a>> wrote:<br>
>> > Hi,<br>
>> >    I am trying to parse a C++ code but clang doesn't recognize the C++<br>
>> > types. Consider the following code<br>
>> ><br>
>> > #include <iostream><br>
>> > #include <string><br>
>> ><br>
>> > int main()<br>
>> > {<br>
>> >     string str;<br>
>> > }<br>
>> ><br>
>> > clang gives an error at <iostream> and doesn't recognize the string<br>
>> > type. To<br>
>> > enable C++, I did "langOptions.CPlusPlus=1" and the code recognizes<br>
>> > custom<br>
>> > C++ classes. So how do I include default C++ paths?<br>
>><br>
>> I assume you're using clang as a library, rather than actually going<br>
>> through the clang driver? The driver's where all (most) of the header<br>
>> search logic is. You can extract the paths by simply asking clang what<br>
>> command it used to invoke the frontend (I forget offhand, but there is<br>
>> a verbose/print-commands option to clang) & just pass those in. But if<br>
>> you want to make a tool using clang as a library & have the same<br>
>> header/lib discovery that the clang command line program has, you'd<br>
>> need to duplicate or reuse the logic in the driver.<br>
>><br>
>> - David<br>
><br>
><br>
><br>
><br>
</div><span><font color="#888888">> --<br>
> Mohammad Adil<br>
> LUMS SSE<br>
</font></span><div><div>><br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div>