I m working on clang libtooling, I needed the left hand side of the assignment operation ,
So I used VisitBinaryOperator(BinaryOperator *B)
to get the left hand side , I did some research on it and implemented in the following way
bool VisitBinaryOperator(BinaryOperator *B)
{
if(B->isAssignmentOp())
{
Expr *E = B->getLHS();
if(const clang::DeclRefExpr *lhs = dyn_cast<clang::DeclRefExpr>(E))
{
cout<< "Count 1\n";
}
}
return true;
}
This is my sample program
#define abc ab
int ab[5];
int b[10];
int main()
{
b[0] = 0;
b[1] = b[0];
abc[1] = 0;
}
For this program VisitBinaryOperator
function should go inside the if condition , as b[0],b[1],abc[1] are referred in the main function .
But control is not going inside only , and I m failing to debug it also .
Please Let me know the answer for this issue.