Hi guys,
I’m using libtooling to develop a tool to instrument source code. I need to record the left values of assignment statements.
I tried the VisitBinaryOperator
function in RecursiveASTVisitor
. The code looked like this:
bool VisitBinaryOperator(BinaryOperator *b){
if(b->isAssignmentOp()){
Stmt *lhs = binaryOperator->getLHS();
Are you SURE that the VisitBinaryOperator function is not being called? I find that highly unlikely (considering that these visitors are quite commonly used for all sorts of different purposes, and checking for assignments isn’t unusual by any means).
I would expect that the conditions INSIDE your function is what is causing problems. Try adding some printout (or set a breakpoint in a debugger) at the beginning of the function. I suspect the function is being called, but the operands are not the kind you think they are in this case, so your printout or “do stuff” isn’t happening.