[cfe-commits] r53469 - /cfe/trunk/lib/AST/ExprConstant.cpp
Chris Lattner
sabre at nondot.org
Fri Jul 11 12:29:33 PDT 2008
Author: lattner
Date: Fri Jul 11 14:29:32 2008
New Revision: 53469
URL: http://llvm.org/viewvc/llvm-project?rev=53469&view=rev
Log:
implement support for __extension__, make sure the result of a
comparison has the right width.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=53469&r1=53468&r2=53469&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Jul 11 14:29:32 2008
@@ -220,6 +220,10 @@
break;
case BinaryOperator::Add: Result += RHS; break;
case BinaryOperator::Sub: Result -= RHS; break;
+ case BinaryOperator::And: Result &= RHS; break;
+ case BinaryOperator::Xor: Result ^= RHS; break;
+ case BinaryOperator::Or: Result |= RHS; break;
+
case BinaryOperator::Shl:
Result <<= (unsigned)RHS.getLimitedValue(Result.getBitWidth()-1);
break;
@@ -227,16 +231,30 @@
Result >>= (unsigned)RHS.getLimitedValue(Result.getBitWidth()-1);
break;
- // FIXME: Need to set the result width?
- case BinaryOperator::LT: Result = Result < RHS; break;
- case BinaryOperator::GT: Result = Result > RHS; break;
- case BinaryOperator::LE: Result = Result <= RHS; break;
- case BinaryOperator::GE: Result = Result >= RHS; break;
- case BinaryOperator::EQ: Result = Result == RHS; break;
- case BinaryOperator::NE: Result = Result != RHS; break;
- case BinaryOperator::And: Result &= RHS; break;
- case BinaryOperator::Xor: Result ^= RHS; break;
- case BinaryOperator::Or: Result |= RHS; break;
+ case BinaryOperator::LT:
+ Result = Result < RHS;
+ Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
+ break;
+ case BinaryOperator::GT:
+ Result = Result > RHS;
+ Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
+ break;
+ case BinaryOperator::LE:
+ Result = Result <= RHS;
+ Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
+ break;
+ case BinaryOperator::GE:
+ Result = Result >= RHS;
+ Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
+ break;
+ case BinaryOperator::EQ:
+ Result = Result == RHS;
+ Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
+ break;
+ case BinaryOperator::NE:
+ Result = Result != RHS;
+ Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
+ break;
case BinaryOperator::Comma:
// C99 6.6p3: "shall not contain assignment, ..., or comma operators,
@@ -293,16 +311,15 @@
// See C99 6.6p3.
default:
return false;
- case UnaryOperator::Extension:
- assert(0 && "Handle UnaryOperator::Extension");
- return false;
case UnaryOperator::LNot: {
bool Val = Result == 0;
Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
Result = Val;
break;
}
+ case UnaryOperator::Extension:
case UnaryOperator::Plus:
+ // The result is always just the subexpr
break;
case UnaryOperator::Minus:
Result = -Result;
More information about the cfe-commits
mailing list