<div style="font-family: arial, helvetica, sans-serif"><font size="2"><div class="gmail_quote">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 class="im"><br>
// Begin function inc returning int<br>
</div>int inc(int &p)<br>
{<br>
p++;<br>
<div class="im"> 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 class="im"> 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>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><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 class="HOEnZb"><div class="h5"><br>
On Sat, Jun 23, 2012 at 12:05 AM, Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:<br>
> On Fri, Jun 22, 2012 at 7:55 PM, John McCall <<a href="mailto:rjmccall@apple.com">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">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><br></font></div>