Handle C++ functions with clang API to insert code
I need to preprocess some **C++** files to automatically insert code for testing and profiling, and I need to do it with the **clang API**. 

For now, I want to be able to do the following:
If there is a function:

    int SomeFn(int a, int b, int c) {
        doStuff();
    }

I want to preprocess it, that it looks like this:

    int SomeFn(int a, int b, int c) {
        cout << "SomeFn is invoked with the following arguments: a=" << a << ", b=" << b << ", c=" << c << endl;
        doStuff();
    }

I've tried to extend ASTConsumer and use the methods HandleTopLevelDecl and HandleTopLevelSingleDecl and check the if the passed Decls are FunctionDecls. But I can't reach class-methods that way, only global functions.
Moreover, I would need to get more information about the methods, like the types of their params.

I know there is also the concept of Visitors, but I don't know if it's the right way.

So my question is, what would be the right way to do this task? Maybe someone knows, where I can find examples because the clang API is poorly documented.
Handle C++ functions with clang API to insert code
===

I need to preprocess some **C++** files to automatically insert code for testing and profiling, and I need to do it with the **clang API**. 

For now, I want to be able to do the following:
If there is a function:

    int SomeFn(int a, int b, int c) {
        doStuff();
    }

I want to preprocess it, that it looks like this:

    int SomeFn(int a, int b, int c) {
        cout << "SomeFn is invoked with the following arguments: a=" << a << ", b=" << b << ", c=" << c << endl;
        doStuff();
    }

I've tried to extend ASTConsumer and use the methods HandleTopLevelDecl and HandleTopLevelSingleDecl and check the if the passed Decls are FunctionDecls. But I can't reach class-methods that way, only global functions.
Moreover, I would need to get more information about the methods, like the types of their params.

I know there is also the concept of Visitors, but I don't know if it's the right way.

So my question is, what would be the right way to do this task? Maybe someone knows, where I can find examples because the clang API is poorly documented.