Get ArraySubcriptExpr


Assume I have the following statment:

u[i][j+1][k][m] = a + b +c;

How can I get all the 4 array subscription expessions at the same time? I have tried the implement a VisitArraySubscriptExpr() funciton, but I can only get each subscription expression each time.
This means I can only get i, j + 1, k, and m one by one.

Is there any easy way to the all the subscription expressions at the same time?


Couldn't you just write a simple function that calls your visitor in a
loop, and pushes the results on a list that it returns? Or am I
misunderstanding the question?

Hi Daniel,

The problem is that I don’t know how many array subscription operations ‘u’ has.

For example, for the following code:

u[i][j][k][m] = u[i][j+1][k][m-1] + u1[i][j]

The visitor function will be called many times and ArraySubscriptExpr->getBase() won’t always give me the correct base.