[cfe-dev] Problem parsing a simple C++ file.

Manuel Klimek klimek at google.com
Sun Dec 2 22:57:42 PST 2012


Instead of using CompilerInstance yourself, you could try writing either a
clang plugin or use libtooling (see
http://clang.llvm.org/docs/Tooling.htmlfor when to use what).

If you cannot do that for some reason, you can take a look at:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?view=markup
for a working (rather minimal) example on how to set up a CompilerInstance.

Cheers,
/Manuel



On Sun, Dec 2, 2012 at 8:05 PM, Hurcan Solter <hsolter at gmail.com> wrote:

> I am trying to parse simple C++ class with CompilerInstance but get the
> following error;
>
> E:/mycpp_vc/classtest.cpp:3:1: error: unknown type name 'class'
> class Test
> ^
> E:/mycpp_vc/classtest.cpp:3:13: error: expected ';' after top level
> declarator
> class Test
>                ^
>                ;
> My understanding is clang assumes the file is a C file and hence the error.
> I've thought clang would deduce that the file is a C++ by its extension.
> I've also tried setting ci.getLangOpts().CPlusPlus=1 before parsing to no
> avail.
>
> Is there something am I overlooking?
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121203/c7179729/attachment.html>


More information about the cfe-dev mailing list