diff options
-rw-r--r-- | include/clang/AST/Expr.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 36005223c7..a5aba76d75 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -375,6 +375,11 @@ public: Expr(ArraySubscriptExprClass, t), Base(base), Idx(idx), RBracketLoc(rbracketloc) {} + // NOTE: An array access can be written A[4] or 4[A] (both are equivalent). + // In the second case, getBase() actually returns the index and getIdx() + // returns the offset. Only one of the subexpressions will have a pointer + // type (the base), so the second case can be identified using the + // expression getBase()->getType()->isPointerType(). Expr *getBase() { return Base; } const Expr *getBase() const { return Base; } Expr *getIdx() { return Idx; } |