[cfe-dev] Link between clang::FunctionType and clang::FunctionDecl

Sebastian Redl sebastian.redl at getdesigned.at
Sun Jun 2 06:39:51 PDT 2013


On 02.06.2013, at 14:26, Vassil Vassilev wrote:

> Arh... I see. Here is what I want to do:
> 
> template<typename F, typename... Args, typename... A>
> F callF(F (*f)(Args...), A&&... a) {
>   return f(a...);
> }
> 
> int f(int x) {
>  printf("This is f(x).\n");
>  return x*x;
> }
> 
> int main () {
>  int x = 4;
>  callF(f, x); // Here at that point, I want to get the decl of f. That should be possible, right?
>  return 0;
> }

Yes. The AST should look something like this:

ExprStmt(CallExpr(..., ImplicitCastExpr(DeclRefExpr('f')), ...))

and the DeclRefExpr should have a handle to f.



More information about the cfe-dev mailing list