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

Vassil Vassilev vvasilev at cern.ch
Sun Jun 2 14:17:47 PDT 2013


On 6/2/13 3:39 PM, Sebastian Redl wrote:
> 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.
Sorry for the noise I was mislead. Thanks for steering me in the right 
direction :)
Vassil



More information about the cfe-dev mailing list