r255314 - Clean ExprConstant/CGExprConstant up a bit. NFC.
George Burgess IV via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 10 16:23:35 PST 2015
Author: gbiv
Date: Thu Dec 10 18:23:35 2015
New Revision: 255314
URL: http://llvm.org/viewvc/llvm-project?rev=255314&view=rev
Log:
Clean ExprConstant/CGExprConstant up a bit. NFC.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=255314&r1=255313&r2=255314&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Dec 10 18:23:35 2015
@@ -1180,7 +1180,7 @@ static bool EvaluatePointer(const Expr *
static bool EvaluateMemberPointer(const Expr *E, MemberPtr &Result,
EvalInfo &Info);
static bool EvaluateTemporary(const Expr *E, LValue &Result, EvalInfo &Info);
-static bool EvaluateInteger(const Expr *E, APSInt &Result, EvalInfo &Info);
+static bool EvaluateInteger(const Expr *E, APSInt &Result, EvalInfo &Info);
static bool EvaluateIntegerOrLValue(const Expr *E, APValue &Result,
EvalInfo &Info);
static bool EvaluateFloat(const Expr *E, APFloat &Result, EvalInfo &Info);
@@ -1607,7 +1607,7 @@ static bool HandleFloatToFloatCast(EvalI
static APSInt HandleIntToIntCast(EvalInfo &Info, const Expr *E,
QualType DestType, QualType SrcType,
- APSInt &Value) {
+ const APSInt &Value) {
unsigned DestWidth = Info.Ctx.getIntWidth(DestType);
APSInt Result = Value;
// Figure out if this is a truncate, extend or noop cast.
@@ -5655,7 +5655,7 @@ static bool EvaluateVector(const Expr* E
return VectorExprEvaluator(Info, Result).Visit(E);
}
-bool VectorExprEvaluator::VisitCastExpr(const CastExpr* E) {
+bool VectorExprEvaluator::VisitCastExpr(const CastExpr *E) {
const VectorType *VTy = E->getType()->castAs<VectorType>();
unsigned NElts = VTy->getNumElements();
@@ -5668,13 +5668,13 @@ bool VectorExprEvaluator::VisitCastExpr(
if (SETy->isIntegerType()) {
APSInt IntResult;
if (!EvaluateInteger(SE, IntResult, Info))
- return false;
- Val = APValue(IntResult);
+ return false;
+ Val = APValue(std::move(IntResult));
} else if (SETy->isRealFloatingType()) {
- APFloat F(0.0);
- if (!EvaluateFloat(SE, F, Info))
- return false;
- Val = APValue(F);
+ APFloat FloatResult(0.0);
+ if (!EvaluateFloat(SE, FloatResult, Info))
+ return false;
+ Val = APValue(std::move(FloatResult));
} else {
return Error(E);
}
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=255314&r1=255313&r2=255314&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Thu Dec 10 18:23:35 2015
@@ -1350,15 +1350,17 @@ llvm::Constant *CodeGenModule::EmitConst
return llvm::ConstantStruct::get(STy, Complex);
}
case APValue::Vector: {
- SmallVector<llvm::Constant *, 4> Inits;
unsigned NumElts = Value.getVectorLength();
+ SmallVector<llvm::Constant *, 4> Inits(NumElts);
- for (unsigned i = 0; i != NumElts; ++i) {
- const APValue &Elt = Value.getVectorElt(i);
+ for (unsigned I = 0; I != NumElts; ++I) {
+ const APValue &Elt = Value.getVectorElt(I);
if (Elt.isInt())
- Inits.push_back(llvm::ConstantInt::get(VMContext, Elt.getInt()));
+ Inits[I] = llvm::ConstantInt::get(VMContext, Elt.getInt());
+ else if (Elt.isFloat())
+ Inits[I] = llvm::ConstantFP::get(VMContext, Elt.getFloat());
else
- Inits.push_back(llvm::ConstantFP::get(VMContext, Elt.getFloat()));
+ llvm_unreachable("unsupported vector element type");
}
return llvm::ConstantVector::get(Inits);
}
More information about the cfe-commits
mailing list