[cfe-dev] How to get Function Definition from CallExpr

Kevin Boos kevinaboos at gmail.com
Wed Jul 17 03:49:44 PDT 2013


Oh, that was my problem, thank you so much!

Apparently, when following a tutorial, I glossed over the important
distinction between what gets parsed when using HandleTopLevelDecl vs.
HandleTranslationUnit.

Much thanks,
Kevin

On Jul 16, 2013 7:31 PM, "Eli Friedman" <eli.friedman at gmail.com> wrote:

> n Tue, Jul 16, 2013 at 5:05 PM, Kevin Boos <kevinaboos at gmail.com> wrote:
> > Ah, I see now that there are multiple hasBody() functions. I just tried
> > using that hasBody(FunctionDecl *&), and it returns false. Makes sense
> > because it's essentially the same as me manually iterating over each
> redecl.
> >
> > I am indeed using ASTConsumer alongside a RecursiveASTVisitor in the
> > libtooling environment. So you're saying that my code (some analysis
> inside
> > VisitFunctionDecl or VisitStmt, per se) will be unaware of the existence
> of
> > a future foo() definition until VisitFunctionDecl is called on that foo()
> > definition?
> >
> > If so, then there is no way to inspect the body/definition of foo() until
> > VisitFunctionDecl visits it, right? Specifically, while visiting the
> main()
> > FunctionDecl*, I cannot access the Stmts inside the foo() definition?
> That's
> > really what I need.
>
> You can... you just have to call your visitor from the
> HandleTranslationUnit callback.
>
> -Eli
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130717/987bf1f3/attachment.html>


More information about the cfe-dev mailing list