[cfe-dev] How to get Function Definition from CallExpr
Eli Friedman
eli.friedman at gmail.com
Tue Jul 16 16:29:49 PDT 2013
On Tue, Jul 16, 2013 at 4:06 PM, Kevin Boos <kevinaboos at gmail.com> wrote:
> Thanks so much for your quick reply.
>
> I have been using hasBody(), isThisDeclarationADefinition(), etc... to
> determine if the Decl* i'm looking at is actually a definition -- those are
> useful. I was merely testing things with the redecl chain just to see if I
> could get the definition that way even if getDirectCallee() returned the
> function prototype.
There's also a form of FunctionDecl::hasBody() which lets you retrieve
the definition.
> How would I determine if clang has parsed the definition? Sorry, I'm a bit
> of a beginner here. I thought that Clang first parsed the source file, built
> an AST, and then allowed you to Visit each type of AST node. All I know is,
> at that point, Clang would not yet have visited the definition of foo(), but
> I assume it would have parsed it...?
It depends on how exactly you're getting at the AST. The ASTConsumer
API in particular returns one declaration at a time.
-Eli
More information about the cfe-dev
mailing list