I would like to detect the index expression of single or multi-dimensional arrays.<br>I wrote the code below to accomplish this and wanted to check if there is a better way to find the index expression(s).<br>if there is an expression like this : a[i][j][z]. The code below will find the indices in the following order z, j, then i<br>
 <br>          Expr *Curr = LHS;<br>          ArraySubscriptExpr *ASE;<br>          while(ASE=dyn_cast<ArraySubscriptExpr>(Curr)) {<br>            Expr *Idx  = ASE->getIdx();<br>            *Out<<"Index Expr is:";<br>
            Idx->dump();<br>            Curr = ASE->getBase();<br>            if(ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Curr)) {<br>              Curr = ICE->getSubExpr();<br>            }<br>            *Out<<"Base Expr is:";<br>
            Curr->dump();               <br>          }<br><br>Thanks,<br>Moataz<br>