[cfe-dev] Using libtooling to parse C++ code

Manuel Klimek klimek at google.com
Fri Nov 14 22:47:51 PST 2014


Clang by default uses the file extension to determine the language. If you
pass it a .h file you can say -x c++ or -x c++-header

On Fri, Nov 14, 2014, 23:00 Patrick Lam <prof.lam at gmail.com> wrote:

> Yes, I have the same initialization code. When I feed it a C++ file,
> it just compiles it.
>
> pat
>
> On Fri, Nov 14, 2014 at 4:44 PM, Cong Yan <congyan91 at gmail.com> wrote:
> > How did you do that? Did you change the language option somewhere?
> >
> > This is what I included in the main function:
> >
> > CommonOptionsParser op(argc, argv);
> > // create a new Clang Tool instance (a LibTooling environment)
> > ClangTool Tool(op.getCompilations(), op.getSourcePathList());
> > // run the Clang Tool, creating a new FrontendAction (explained below)
> > int result = Tool.run(newFrontendActionFactory<myFrontendAction>());
> >
> >  It seems that C is the default language in CompilerInstance and
> > CompilerInvocation. Should I do something to change that? Or I should
> pass
> > some argument when I run the tool I write?
> >
> >
> > Thanks!
> > Cong
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> >
> _______________________________________________
> 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/20141115/b70885e9/attachment.html>


More information about the cfe-dev mailing list