aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-08-15 22:33:19 +0000
committerTed Kremenek <kremenek@apple.com>2007-08-15 22:33:19 +0000
commitfc4a1601a84d280d7e5c424b77843fdd743beec8 (patch)
treec2f0134f872676d719f28e7279e6a4e7491896cf
parent87ce144920a4f9c4cc8d6b021b1d759d7785317c (diff)
Added a comment to ArraySubscriptExpr to note that the expressions like
"A[4]" are equivalent to "4[A]", and that a test that the expression returned by "getBase()" has a pointer type is required to resolve which subexpression is the "true" base expression of the array index. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41113 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Expr.h5
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; }