<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt">Instead of using CompilerInstance yourself, you could try writing either a clang plugin or use libtooling (see <a href="http://clang.llvm.org/docs/Tooling.html">http://clang.llvm.org/docs/Tooling.html</a> for when to use what).<div>
<br></div><div>If you cannot do that for some reason, you can take a look at:<br><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?view=markup">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?view=markup</a><br>
</div><div>for a working (rather minimal) example on how to set up a CompilerInstance.</div><div><br></div><div>Cheers,</div><div>/Manuel</div><div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Dec 2, 2012 at 8:05 PM, Hurcan Solter <span dir="ltr"><<a href="mailto:hsolter@gmail.com" target="_blank">hsolter@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 am trying to parse simple C++ class with CompilerInstance but get the following error;<br><br>E:/mycpp_vc/classtest.cpp:3:1: error: unknown type name 'class'<br>
class Test<br>^<br>E:/mycpp_vc/classtest.cpp:3:13: error: expected ';' after top level declarator<br>
class Test<br>               ^<br>               ;<br>My understanding is clang assumes the file is a C file and hence the error.<br>I've thought clang would deduce that the file is a C++ by its extension.<br>I've also tried setting ci.getLangOpts().CPlusPlus=1 before parsing to no avail.<br>

<br>Is there something am I overlooking? <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></blockquote></div><br></div></div>