aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-07-16 22:23:01 +0000
committerSteve Naroff <snaroff@apple.com>2007-07-16 22:23:01 +0000
commit3e5e5560b3300b6bed669c6743c52d995e5d8a8d (patch)
tree20a41035678f5384a6e982c172313520eb870a34
parenta2c7767ce7d8feb10253f4b650826a20f3324c6f (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39934 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Sema/Sema.h4
-rw-r--r--Sema/SemaExpr.cpp46
2 files changed, 21 insertions, 29 deletions
diff --git a/Sema/Sema.h b/Sema/Sema.h
index cef5c01dc1..492562d7a5 100644
--- a/Sema/Sema.h
+++ b/Sema/Sema.h
@@ -281,8 +281,8 @@ private:
// 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,
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index d49764365e..dc2fdebf5e 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -496,7 +496,7 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15
}
// 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 @@ void Sema::UsualUnaryConversions(Expr *&expr) {
/// 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 @@ inline QualType Sema::CheckMultiplyDivideOperands(
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 @@ inline QualType Sema::CheckRemainderOperands(
{
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::CheckRemainderOperands(
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::CheckAdditionOperands( // C99 6.5.6
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 @@ inline QualType Sema::CheckShiftOperands( // C99 6.5.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::CheckEqualityOperands( // C99 6.5.9
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;