]> granicus.if.org Git - clang/commitdiff
Added a comment to ArraySubscriptExpr to note that the expressions like
authorTed Kremenek <kremenek@apple.com>
Wed, 15 Aug 2007 22:33:19 +0000 (22:33 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 15 Aug 2007 22:33:19 +0000 (22:33 +0000)
"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

include/clang/AST/Expr.h

index 36005223c7e266e5bd751a6801a978eb60b2f74f..a5aba76d7573b90bbbe2d225d9e1b9dd889b1b08 100644 (file)
@@ -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; }