[cfe-commits] r45390 - /cfe/trunk/include/clang/AST/Expr.h

Christopher Lamb christopher.lamb at gmail.com
Fri Dec 28 15:43:08 PST 2007


Author: clamb
Date: Fri Dec 28 17:43:03 2007
New Revision: 45390

URL: http://llvm.org/viewvc/llvm-project?rev=45390&view=rev
Log:
Fix an error in the base/idx accessors for ArraySubscriptExpr's that crops up with vector element access.

Modified:
    cfe/trunk/include/clang/AST/Expr.h

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=45390&r1=45389&r2=45390&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri Dec 28 17:43:03 2007
@@ -499,7 +499,10 @@
   ///    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 @@
   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(); 
   }  
 
   





More information about the cfe-commits mailing list