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

Manuel Klimek klimek at google.com
Sat Feb 11 02:58:21 PST 2012


On Fri, Feb 10, 2012 at 4:24 PM, Felix Schmitt
<felix.schmitt at zih.tu-dresden.de> wrote:
> 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.

If you traverse the AST with RecursiveASTVisitor, it allows you to
traverse template instantiations.

Cheers,
/Manuel

>
> 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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list