summaryrefslogtreecommitdiffstats
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
commit248d5b277ce8dd1abe600636e829f667f57e8225 (patch)
treec92d2c71fe46cb1650ba2fb91c34d1ef51af0236
parenta392cd2fde4d0a84bc5871f63b545867e3257d56 (diff)
downloadbcm5719-llvm-248d5b277ce8dd1abe600636e829f667f57e8225.tar.gz
bcm5719-llvm-248d5b277ce8dd1abe600636e829f667f57e8225.zip
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. llvm-svn: 41113
-rw-r--r--clang/include/clang/AST/Expr.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 36005223c7e..a5aba76d757 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/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; }
OpenPOWER on IntegriCloud