[cfe-dev] finding function callee declarations for type/value dependent function calls

Felix Schmitt felix.schmitt at zih.tu-dresden.de
Fri Feb 10 07:24:52 PST 2012


Hi,

I would like to solve the following problem using clang:
I am traversing the AST using CompilerInstance/CompilerInvocation and try to 
find function callees for function calls. This works well, as long as the 
function call is not a type- or value-dependent CallExpr, for which the callee 
resolves to an UnresolvedLookupExpr.

template<class T>
void foo(T a) {
  a++;
}

template<class T>
void bar() {
  T a;
  foo(a);
}

int main(int argc, char **argv) {
  bar<int>();
}

I am aware that template instantiation is neccessary to locate the correct 
callees and that this is not possible AST-parsing setup, alone.
However, could you please give me any hints on how to solve this, i.e. how to 
perform the template instantiation and resolve the instantiated templates to 
their former counterparts in the original source code?

Thanks a lot,
Felix




More information about the cfe-dev mailing list