[cfe-dev] ASTContext: how to get an object or pointer of ASTContext

Jiandong Wang computerhenu at gmail.com
Tue May 18 18:19:55 PDT 2010


On Tue, May 18, 2010 at 10:11 PM, Douglas Gregor <dgregor at apple.com> wrote:

>
> On May 18, 2010, at 6:09 AM, Jiandong Wang wrote:
>
> Hi all:
>     now I am trying to run my own ASTConsumer against AST, but not quite
> sure how to do it, especially how to get an object or pointer of ASTContext.
> BTW, ASTContext is required by ParseAST.
> here is my code snippet:
>
> You can just create an ASTContext on the stack, passing in the various
> other pieces (lang options, source manager, target info, etc.) when you
> construct it.
>

 Thank you. I finally compiled it through.my command:
       g++ `llvm-config --cxxflags --ldflags` -fno-rtti -c Myfile.cpp -o
Myfile.o
but when I generated the executable, unexpected errors occured. my command:
       g++ `llvm-config --cxxflasg --ldflags --libs core` -o Myfile
Myfile.o

errors like this:
undefined reference to 'llvm::errs()'
undefined reference to
'clang::Diagnostic::Diagnostic(clang::DiagnosticClient*)'
undefined reference to 'clang::FileManager::FileManager()'

missing something?

>
> Have you considered using CompilerInvocation/CompilerInstance rather than
> building all of the pieces together?
>
>   Yes, I knew. I will try it later. -:)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100519/e8f30e65/attachment.html>


More information about the cfe-dev mailing list