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

Vassil Vassilev vvasilev at cern.ch
Sun Jun 2 05:26:36 PDT 2013


On 6/2/13 2:01 PM, Sebastian Redl wrote:
> On 02.06.2013, at 13:39, Vassil Vassilev wrote:
>
>> Hi,
>>   Maybe a silly question, but why I cannot get the FunctionDecl for a given FunctionType?
> Because
>
> void f();
> void g();
> void h();
>
> all have the same FunctionType. Which decl do you want?
>
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;
}

Vassil



More information about the cfe-dev mailing list