[cfe-commits] r39934 - in /cfe/trunk/Sema: Sema.h SemaExpr.cpp

Steve Naroff snaroff at apple.com
Mon Jul 16 15:23:01 PDT 2007


Author: snaroff
Date: Mon Jul 16 17:23:01 2007
New Revision: 39934

URL: http://llvm.org/viewvc/llvm-project?rev=39934&view=rev
Log:

Remove the 2 QualType references to method UsualArithmeticConversions. Last week, I added these
to quickly fix a regression. Avoiding them entirely is a much cleaner solution. Clients of 
UsualArithmeticConversions should simply call getType() on the expression to get the
converted type. In practice, only a small number of routines care about this.

Modified:
    cfe/trunk/Sema/Sema.h
    cfe/trunk/Sema/SemaExpr.cpp

Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=39934&r1=39933&r2=39934&view=diff

==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Mon Jul 16 17:23:01 2007
@@ -281,8 +281,8 @@
   // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
   // routine returns the first non-arithmetic type found. The client is 
   // responsible for emitting appropriate error diagnostics.
-  QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
-                                      QualType &lhs, QualType &rhs);                                      
+  QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr);
+                                     
   enum AssignmentCheckResult {
     Compatible,
     Incompatible,

Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=39934&r1=39933&r2=39934&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Mon Jul 16 17:23:01 2007
@@ -496,7 +496,7 @@
   }
   // now check the two expressions.
   if (lexT->isArithmeticType() && rexT->isArithmeticType()) // C99 6.5.15p3,5
-    return UsualArithmeticConversions(lex, rex, lexT, rexT);
+    return UsualArithmeticConversions(lex, rex);
     
   if ((lexT->isStructureType() && rexT->isStructureType()) || // C99 6.5.15p3
       (lexT->isUnionType() && rexT->isUnionType())) {
@@ -609,14 +609,12 @@
 /// binary operators (C99 6.3.1.8). If both operands aren't arithmetic, this
 /// routine returns the first non-arithmetic type found. The client is 
 /// responsible for emitting appropriate error diagnostics.
-QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr,
-                                          QualType &lhs, QualType &rhs) {
+QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr) {
   UsualUnaryConversions(lhsExpr);
   UsualUnaryConversions(rhsExpr);
   
-  // FIXME: get rid of these reference parameters.
-  lhs = lhsExpr->getType();
-  rhs = rhsExpr->getType();
+  QualType lhs = lhsExpr->getType();
+  QualType rhs = rhsExpr->getType();
   
   // If both types are identical, no conversion is needed.
   if (lhs == rhs) 
@@ -801,7 +799,7 @@
   if (lhsType->isVectorType() || rhsType->isVectorType())
     return CheckVectorOperands(loc, lex, rex);
     
-  QualType resType = UsualArithmeticConversions(lex, rex, lhsType, rhsType);
+  QualType resType = UsualArithmeticConversions(lex, rex);
   
   if (resType->isArithmeticType())
     return resType;
@@ -814,7 +812,7 @@
 {
   QualType lhsType = lex->getType(), rhsType = rex->getType();
 
-  QualType resType = UsualArithmeticConversions(lex, rex, lhsType, rhsType);
+  QualType resType = UsualArithmeticConversions(lex, rex);
   
   if (resType->isIntegerType())
     return resType;
@@ -825,19 +823,17 @@
 inline QualType Sema::CheckAdditionOperands( // C99 6.5.6
   Expr *&lex, Expr *&rex, SourceLocation loc) 
 {
-  QualType lhsType = lex->getType(), rhsType = rex->getType();
-
-  if (lhsType->isVectorType() || rhsType->isVectorType())
+  if (lex->getType()->isVectorType() || rex->getType()->isVectorType())
     return CheckVectorOperands(loc, lex, rex);
 
-  QualType resType = UsualArithmeticConversions(lex, rex, lhsType, rhsType);
-
+  QualType resType = UsualArithmeticConversions(lex, rex);
+  
   // handle the common case first (both operands are arithmetic).
   if (resType->isArithmeticType())
     return resType;
 
-  if ((lhsType->isPointerType() && rhsType->isIntegerType()) ||
-      (lhsType->isIntegerType() && rhsType->isPointerType()))
+  if ((lex->getType()->isPointerType() && rex->getType()->isIntegerType()) ||
+      (lex->getType()->isIntegerType() && rex->getType()->isPointerType()))
     return resType;
   InvalidOperands(loc, lex, rex);
   return QualType();
@@ -846,19 +842,18 @@
 inline QualType Sema::CheckSubtractionOperands( // C99 6.5.6
   Expr *&lex, Expr *&rex, SourceLocation loc) 
 {
-  QualType lhsType = lex->getType(), rhsType = rex->getType();
-
-  if (lhsType->isVectorType() || rhsType->isVectorType())
+  if (lex->getType()->isVectorType() || rex->getType()->isVectorType())
     return CheckVectorOperands(loc, lex, rex);
     
-  QualType resType = UsualArithmeticConversions(lex, rex, lhsType, rhsType);
+  QualType resType = UsualArithmeticConversions(lex, rex);
   
   // handle the common case first (both operands are arithmetic).
   if (resType->isArithmeticType())
     return resType;
-  if (lhsType->isPointerType() && rhsType->isIntegerType())
+    
+  if (lex->getType()->isPointerType() && rex->getType()->isIntegerType())
     return resType;
-  if (lhsType->isPointerType() && rhsType->isPointerType())
+  if (lex->getType()->isPointerType() && rex->getType()->isPointerType())
     return Context.getPointerDiffType();
   InvalidOperands(loc, lex, rex);
   return QualType();
@@ -869,8 +864,7 @@
 {
   // FIXME: Shifts don't perform usual arithmetic conversions.  This is wrong
   // for int << longlong -> the result type should be int, not long long.
-  QualType lhsType = lex->getType(), rhsType = rex->getType();
-  QualType resType = UsualArithmeticConversions(lex, rex, lhsType, rhsType);
+  QualType resType = UsualArithmeticConversions(lex, rex);
   
   if (resType->isIntegerType())
     return resType;
@@ -945,12 +939,10 @@
 inline QualType Sema::CheckBitwiseOperands(
   Expr *&lex, Expr *&rex, SourceLocation loc) 
 {
-  QualType lhsType = lex->getType(), rhsType = rex->getType();
-  
-  if (lhsType->isVectorType() || rhsType->isVectorType())
+  if (lex->getType()->isVectorType() || rex->getType()->isVectorType())
     return CheckVectorOperands(loc, lex, rex);
 
-  QualType resType = UsualArithmeticConversions(lex, rex, lhsType, rhsType);
+  QualType resType = UsualArithmeticConversions(lex, rex);
   
   if (resType->isIntegerType())
     return resType;





More information about the cfe-commits mailing list