[cfe-commits] r60323 - /cfe/trunk/lib/CodeGen/CGExprConstant.cpp
Anders Carlsson
andersca at mac.com
Sun Nov 30 18:42:14 PST 2008
Author: andersca
Date: Sun Nov 30 20:42:14 2008
New Revision: 60323
URL: http://llvm.org/viewvc/llvm-project?rev=60323&view=rev
Log:
Change more code over to using the new Expr::Evaluate
Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=60323&r1=60322&r2=60323&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Sun Nov 30 20:42:14 2008
@@ -388,12 +388,12 @@
// Binary operators
llvm::Constant *VisitCallExpr(const CallExpr *E) {
- APValue Result;
+ Expr::EvalResult Result;
if (E->Evaluate(Result, CGM.getContext())) {
- if (Result.isInt())
- return llvm::ConstantInt::get(Result.getInt());
- if (Result.isFloat())
- return llvm::ConstantFP::get(Result.getFloat());
+ if (Result.Val.isInt())
+ return llvm::ConstantInt::get(Result.Val.getInt());
+ if (Result.Val.isFloat())
+ return llvm::ConstantFP::get(Result.Val.getFloat());
}
// Handle __builtin___CFStringMakeConstantString.
@@ -622,16 +622,19 @@
CodeGenFunction *CGF) {
QualType type = Context.getCanonicalType(E->getType());
- APValue V;
- if (E->Evaluate(V, Context)) {
- // FIXME: Assert that the value doesn't have any side effects.
- switch (V.getKind()) {
+ Expr::EvalResult Result;
+
+ if (E->Evaluate(Result, Context)) {
+ assert(!Result.HasSideEffects &&
+ "Constant expr should not have any side effects!");
+ switch (Result.Val.getKind()) {
default: assert(0 && "unhandled value kind!");
case APValue::LValue: {
- llvm::Constant *Offset = llvm::ConstantInt::get(llvm::Type::Int64Ty,
- V.getLValueOffset());
+ llvm::Constant *Offset =
+ llvm::ConstantInt::get(llvm::Type::Int64Ty,
+ Result.Val.getLValueOffset());
- if (const Expr *LVBase = V.getLValueBase()) {
+ if (const Expr *LVBase = Result.Val.getLValueBase()) {
llvm::Constant *C =
ConstExprEmitter(*this, CGF).EmitLValue(const_cast<Expr*>(LVBase));
@@ -651,7 +654,7 @@
getTypes().ConvertType(type));
}
case APValue::Int: {
- llvm::Constant *C = llvm::ConstantInt::get(V.getInt());
+ llvm::Constant *C = llvm::ConstantInt::get(Result.Val.getInt());
if (C->getType() == llvm::Type::Int1Ty) {
const llvm::Type *BoolTy = getTypes().ConvertTypeForMem(E->getType());
@@ -660,12 +663,12 @@
return C;
}
case APValue::Float:
- return llvm::ConstantFP::get(V.getFloat());
+ return llvm::ConstantFP::get(Result.Val.getFloat());
case APValue::ComplexFloat: {
llvm::Constant *Complex[2];
- Complex[0] = llvm::ConstantFP::get(V.getComplexFloatReal());
- Complex[1] = llvm::ConstantFP::get(V.getComplexFloatImag());
+ Complex[0] = llvm::ConstantFP::get(Result.Val.getComplexFloatReal());
+ Complex[1] = llvm::ConstantFP::get(Result.Val.getComplexFloatImag());
return llvm::ConstantStruct::get(Complex, 2);
}
More information about the cfe-commits
mailing list