[cfe-dev] Generation of CallExpr to builtin function
Douglas Gregor
dgregor at apple.com
Mon Oct 5 14:00:52 PDT 2009
On Oct 5, 2009, at 7:54 AM, Abramo Bagnara wrote:
>
> In our application we need to generate a new CallExpr to a builtin
> function, but we are unable to find a way to do that.
>
> In SemaDecl.cpp we have found
>
> /// LazilyCreateBuiltin - The specified Builtin-ID was first used at
> /// file scope. lazily create a decl for it. ForRedeclaration is true
> /// if we're creating this built-in in anticipation of redeclaring the
> /// built-in.
> NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
> Scope *S, bool ForRedeclaration,
> SourceLocation Loc);
>
> but it's inaccessible (and does also other things).
>
> What's the right way to do that?
You can find the built-in function using Sema::ActOnIdentifierExpr,
which will have the effect of implicitly declaring the builtin (or
finding it if it already existed) and then building a DeclRefExpr that
you can use as the callee of your call expression.
- Doug
More information about the cfe-dev
mailing list