I tried to use "Tooling" but was unable to specify multiple headers searching directories, redefine preprocessor and so on - as I understood, "Tooling" exposes pretty narrow interface.<br>Prakash, I think this example will be helpful for you: <a href="http://eli.thegreenplace.net/2012/06/08/basic-source-to-source-transformation-with-clang/" target="_blank">http://eli.thegreenplace.net/2012/06/08/basic-source-to-source-transformation-with-clang/</a><br>
<br><div class="gmail_quote">2012/6/25 Slav <span dir="ltr"><<a href="mailto:slavmfm@gmail.com" target="_blank">slavmfm@gmail.com</a>></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:arial,helvetica,sans-serif"><font><div class="gmail_quote">
Cheers,</div><div class="gmail_quote">

/Manuel</div><div><div><div class="gmail_quote"><br></div><div class="gmail_quote">On Mon, Jun 25, 2012 at 3:37 PM, Slav <span dir="ltr"><<a href="mailto:slavmfm@gmail.com" target="_blank">slavmfm@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I tried to use "Tooling" but was unable to specify multiple headers searching directory, redefine preprocessor...</blockquote>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Prakash, I think this example will be helpful for you: <a href="http://eli.thegreenplace.net/2012/06/08/basic-source-to-source-transformation-with-clang/" target="_blank">http://eli.thegreenplace.net/2012/06/08/basic-source-to-source-transformation-with-clang/</a><div>


<div><br>
<br><div class="gmail_quote">2012/6/25 Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div style="font-family:arial,helvetica,sans-serif"><font><div class="gmail_quote"><div><div>On Mon, Jun 25, 2012 at 2:30 PM, Satya Prakash Prasad <span dir="ltr"><<a href="mailto:satyaprakash.prasad@gmail.com" target="_blank">satyaprakash.prasad@gmail.com</a>></span> wrote:<br>




<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks to all for the response.<br>
<br>
I was able to make a progress at least remove the C++ errors but one<br>
issue remains - identifying the include path for C++ header file. I<br>
now get output as :<br>
<br>
fatal error: 'aio.h' file not found<br>
#include <aio.h><br>
<div><br>
// Begin function inc returning int<br>
</div>int inc(int &p)<br>
{<br>
        p++;<br>
<div>        printf("In inc [%d]\n", p);<br>
        return p;<br>
}<br>
// End function inc<br>
</div>……………………………………………………<br>
<br>
The file aio.h is in /usr/include directory of my system:<br>
llvm/build/Release+Asserts/examples> ls -l /usr/include/aio.h<br>
-rw-r--r-- 1 root root 7135 Jul 17  2009 /usr/include/aio.h<br>
<br>
My code modifications are:<br>
<br>
    LangOptions languageOptions;<br>
    languageOptions.CPlusPlus= 1;<br>
<div>    TheCompInst.createFileManager();<br>
    FileManager &FileMgr = TheCompInst.getFileManager();<br>
    TheCompInst.createSourceManager(FileMgr);<br>
</div>    CompilerInvocation* CI = new CompilerInvocation;<br>
    CI->setLangDefaults(languageOptions, IK_CXX);<br>
    TheCompInst.setInvocation(CI);<br>
    DiagnosticsEngine DiagnosticsEngine = TheCompInst.getDiagnostics();<br>
    HeaderSearch headerSearch(FileMgr, DiagnosticsEngine, languageOptions, TI);<br>
    HeaderSearchOptions headerSearchOptions;<br>
    headerSearchOptions.AddPath("/usr/include/c++/4.1.2/backward/",<br>
frontend::Angled, false, false, false, false, false);<br>
    headerSearchOptions.AddPath("/usr/include/c++/4.1.2/",<br>
frontend::Angled, false, false, false, false, false);<br>
    headerSearchOptions.AddPath("/usr/include/c++/", frontend::Angled,<br>
false, false, false, false, false);<br>
    headerSearchOptions.AddPath("/usr/include/", frontend::Angled,<br>
false, false, false, false, false);<br>
    Preprocessor preprocessor(DiagnosticsEngine, languageOptions, TI ,<br>
SourceMgr, headerSearch, TheCompInst);<br>
    TheCompInst.setPreprocessor(&preprocessor);<br>
<br>
I am not sure what I need to do now to remove this error? Though I<br>
have not yet tried libtooling library but since I have explored CLANG<br>
using Frontend APIs I am proceeding with the same.<br></blockquote><div><br></div></div></div><div>Yea, getting the include path search logic right & correctly setup is not trivial. That's exactly what the tooling library takes care of for you :) If you want to duplicate that logic, you're of course free to, but I would guess it'll be more time than switching your code to use the tooling library...</div>




<div><br></div><div>Cheers,</div><div>/Manuel</div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks gain in advance.<br>
<br>
Regards,<br>
Prakash<br>
<div><div><br>
On Sat, Jun 23, 2012 at 12:05 AM, Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:<br>
> On Fri, Jun 22, 2012 at 7:55 PM, John McCall <<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>> wrote:<br>
>><br>
>> On Jun 22, 2012, at 3:06 AM, Satya Prakash Prasad wrote:<br>
>> > Thanks John for the clarification.<br>
>> ><br>
>> > Can you please let me know how to then create clang instance for C++<br>
>> > input file?<br>
>><br>
>> I suggest looking at some of the example code to see how it initializes<br>
>> the<br>
>> CompilerInstance.  clang-interpreter is an example of this.<br>
>><br>
>> Alternatively, you might be happier just running as a clang plugin, in<br>
>> which case you should look at the PrintFunctionNames example.<br>
><br>
><br>
> For source-2-source translation, there are more alternatives with different<br>
> trade-offs to consider:<br>
> <a href="http://clang.llvm.org/docs/Tooling.html" target="_blank">http://clang.llvm.org/docs/Tooling.html</a><br>
><br>
> Cheers,<br>
> /Manuel<br>
><br>
>><br>
>><br>
>> John.<br>
>><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>
><br>
><br>
</div></div></blockquote></div></div><br></font></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>
<br></blockquote></div><br>
</div></div></blockquote></div><br></div></div></font></div>
</blockquote></div><br>
</div></div></blockquote></div><br>