aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-11-16 22:46:56 +0000
committerAnders Carlsson <andersca@mac.com>2008-11-16 22:46:56 +0000
commit529569e68d10b0fd3750fd2124faf742249b846b (patch)
tree0ed9b8e0faa353bddd381d8ffe07eabd1629f3c5 /lib/AST/ExprConstant.cpp
parenta25bd55e63b9ab26ca69390533356aaae7f1a40e (diff)
Address some comments Eli had.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59430 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r--lib/AST/ExprConstant.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 07f6c5476d..ef8e2d4c13 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -407,6 +407,7 @@ public:
bool VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E);
bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) {
+ Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
Result = E->getValue();
Result.setIsUnsigned(E->getType()->isUnsignedIntegerType());
return true;
@@ -578,7 +579,9 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
return false;
APFloat::cmpResult CR = LHS.compare(RHS);
-
+
+ Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
+
switch (E->getOpcode()) {
default:
assert(0 && "Invalid binary operator!");
@@ -602,20 +605,12 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
break;
}
- Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
Result.setIsUnsigned(E->getType()->isUnsignedIntegerType());
return true;
}
if (E->getOpcode() == BinaryOperator::Sub) {
- if (LHSTy->isPointerType()) {
- if (RHSTy->isIntegralType()) {
- // pointer - int.
- // FIXME: Implement.
- }
-
- assert(RHSTy->isPointerType() && "RHS not pointer!");
-
+ if (LHSTy->isPointerType() && RHSTy->isPointerType()) {
APValue LHSValue;
if (!EvaluatePointer(E->getLHS(), LHSValue, Info))
return false;
@@ -634,8 +629,8 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
uint64_t D = LHSValue.getLValueOffset() - RHSValue.getLValueOffset();
D /= Info.Ctx.getTypeSize(ElementType) / 8;
- Result = D;
Result.zextOrTrunc(getIntTypeSizeInBits(E->getType()));
+ Result = D;
Result.setIsUnsigned(E->getType()->isUnsignedIntegerType());
return true;