]> granicus.if.org Git - clang/commitdiff
Fix an error in the base/idx accessors for ArraySubscriptExpr's that crops up with...
authorChristopher Lamb <christopher.lamb@gmail.com>
Fri, 28 Dec 2007 23:43:03 +0000 (23:43 +0000)
committerChristopher Lamb <christopher.lamb@gmail.com>
Fri, 28 Dec 2007 23:43:03 +0000 (23:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45390 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h

index aba11ea9adb970bce0fcd693b477f74b09b58ef6..873b6f7a8ba01b5a8ef120c69eba5705dba89fed 100644 (file)
@@ -499,7 +499,10 @@ public:
   ///    In this case getBase() returns "A" and getIdx() returns "4".
   /// - getLHS() and getRHS() present the syntactic view. e.g. for
   ///    4[A] getLHS() returns "4".
-
+  /// Note: Because vector element access is also written A[4] we must
+  /// predicate the format conversion in getBase and getIdx only on the
+  /// the type of the RHS, as it is possible for the LHS to be a vector of
+  /// integer type
   Expr *getLHS() { return SubExprs[LHS]; }
   const Expr *getLHS() const { return SubExprs[LHS]; }
   
@@ -507,19 +510,19 @@ public:
   const Expr *getRHS() const { return SubExprs[RHS]; }
   
   Expr *getBase() { 
-    return (getLHS()->getType()->isIntegerType()) ? getRHS() : getLHS();
+    return (getRHS()->getType()->isIntegerType()) ? getLHS() : getRHS();
   }
     
   const Expr *getBase() const { 
-    return (getLHS()->getType()->isIntegerType()) ? getRHS() : getLHS();
+    return (getRHS()->getType()->isIntegerType()) ? getLHS() : getRHS();
   }
   
   Expr *getIdx() { 
-    return (getLHS()->getType()->isIntegerType()) ? getLHS() : getRHS();
+    return (getRHS()->getType()->isIntegerType()) ? getRHS() : getLHS();
   }
   
   const Expr *getIdx() const {
-    return (getLHS()->getType()->isIntegerType()) ? getLHS() : getRHS(); 
+    return (getRHS()->getType()->isIntegerType()) ? getRHS() : getLHS(); 
   }