diff options
author | ed <ed@FreeBSD.org> | 2009-06-07 09:21:25 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-07 09:21:25 +0000 |
commit | 2ae812c77b393190175c91233c3348f526ddab1b (patch) | |
tree | 57fdd33d153490269ca615ac308de731d00669da /lib/CodeGen/CGExpr.cpp | |
parent | 265c92560db8af7e64dc328cb612076086a62bd1 (diff) | |
download | FreeBSD-src-2ae812c77b393190175c91233c3348f526ddab1b.zip FreeBSD-src-2ae812c77b393190175c91233c3348f526ddab1b.tar.gz |
Import Clang r73021.
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index c5f2387..c52e6bd 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -843,14 +843,16 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) { LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) { // The index must always be an integer, which is not an aggregate. Emit it. llvm::Value *Idx = EmitScalarExpr(E->getIdx()); - + QualType IdxTy = E->getIdx()->getType(); + bool IdxSigned = IdxTy->isSignedIntegerType(); + // If the base is a vector type, then we are forming a vector element lvalue // with this subscript. if (E->getBase()->getType()->isVectorType()) { // Emit the vector as an lvalue to get its address. LValue LHS = EmitLValue(E->getBase()); assert(LHS.isSimple() && "Can only subscript lvalue vectors here!"); - // FIXME: This should properly sign/zero/extend or truncate Idx to i32. + Idx = Builder.CreateIntCast(Idx, llvm::Type::Int32Ty, IdxSigned, "vidx"); return LValue::MakeVectorElt(LHS.getAddress(), Idx, E->getBase()->getType().getCVRQualifiers()); } @@ -859,8 +861,6 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) { llvm::Value *Base = EmitScalarExpr(E->getBase()); // Extend or truncate the index type to 32 or 64-bits. - QualType IdxTy = E->getIdx()->getType(); - bool IdxSigned = IdxTy->isSignedIntegerType(); unsigned IdxBitwidth = cast<llvm::IntegerType>(Idx->getType())->getBitWidth(); if (IdxBitwidth != LLVMPointerWidth) Idx = Builder.CreateIntCast(Idx, llvm::IntegerType::get(LLVMPointerWidth), |