Does anyone happen to have a simple example of VisitCallExpr() implemented? I am trying to use it through a ASTConsumer that inherits RecursiveASTVisitor, but my function never runs.
Thanks
Does anyone happen to have a simple example of VisitCallExpr() implemented? I am trying to use it through a ASTConsumer that inherits RecursiveASTVisitor, but my function never runs.
Thanks
How about you post an example of your code?
Tried that first in another thread actually. It wasn’t going anywhere. though…
Anyway Ive been modification the Print Functions example(llvm/tools/clang/examples) and besides from the inheritence and implementing one function I’m not sure what else is required. Here it is https://gist.github.com/1015907
Thanks
If I make the class the following, i can get it to work:
class PrintFunctionsConsumer : public ASTConsumer, public RecursiveASTVisitor<PrintFunctionsConsumer> {
public:
bool VisitCallExpr (CallExpr *E) {
llvm::errs() << "Function call maybe?!";
return true;
}
virtual void HandleTranslationUnit(ASTContext &ctx) {
TraverseDecl(ctx.getTranslationUnitDecl());
}
};
That does not work for me
Code: https://gist.github.com/1023214
Test program I’m using: https://gist.github.com/1023217
Loading the pluggin and calling the compiler: clang -cc1 -load ~/llvm/Release+Asserts/lib/libPrintFunctionNames.so -plugin print-fns test2.c
Thanks