/// value l-value, this method emits the address of the l-value, then loads
/// and returns the result.
Value *EmitLoadOfLValue(const Expr *E) {
- // FIXME: Volatile
return EmitLoadOfLValue(EmitLValue(E), E->getType());
}
// integer value.
Value *Base = Visit(E->getBase());
Value *Idx = Visit(E->getIdx());
-
- // FIXME: Convert Idx to i32 type.
+ bool IdxSigned = E->getIdx()->getType()->isSignedIntegerType();
+ Idx = Builder.CreateIntCast(Idx, llvm::IntegerType::get(32),
+ IdxSigned, "vecidxcast");
return Builder.CreateExtractElement(Base, Idx, "vecext");
}
// If this is due to array->pointer conversion, emit the array expression as
// an l-value.
if (Op->getType()->isArrayType()) {
- // FIXME: For now we assume that all source arrays map to LLVM arrays. This
- // will not true when we add support for VLAs.
Value *V = EmitLValue(Op).getAddress(); // Bitfields can't be arrays.
+ // Note that VLA pointers are always decayed, so we don't need to do
+ // anything here.
if (!Op->getType()->isVariableArrayType()) {
assert(isa<llvm::PointerType>(V->getType()) && "Expected pointer");
assert(isa<llvm::ArrayType>(cast<llvm::PointerType>(V->getType())
}
}
return V;
-
- } else if (E->getType()->isReferenceType()) {
- // FIXME: An expression cannot have reference type.
- return EmitLValue(Op).getAddress();
}
-
+
return EmitCastExpr(Op, E->getType());
}
Value *InVal = CGF.EmitLoadOfLValue(LV, ValTy).getScalarVal();
int AmountVal = isInc ? 1 : -1;
-
+
+ if (ValTy->isPointerType() &&
+ ValTy->getAsPointerType()->isVariableArrayType()) {
+ // The amount of the addition/subtraction needs to account for the VLA size
+ CGF.ErrorUnsupported(E, "VLA pointer inc/dec");
+ }
+
Value *NextVal;
if (const llvm::PointerType *PT =
dyn_cast<llvm::PointerType>(InVal->getType())) {
- // FIXME: This isn't right for VLAs.
llvm::Constant *Inc =llvm::ConstantInt::get(llvm::Type::Int32Ty, AmountVal);
if (!isa<llvm::FunctionType>(PT->getElementType())) {
NextVal = Builder.CreateGEP(InVal, Inc, "ptrincdec");
BinOpInfo OpInfo;
if (E->getComputationResultType()->isAnyComplexType()) {
- // FIXME: This needs to go through the complex expression emitter, but
+ // This needs to go through the complex expression emitter, but
// it's a tad complicated to do that... I'm leaving it out for now.
// (Note that we do actually need the imaginary part of the RHS for
// multiplication and division.)
Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
if (!Ops.Ty->isPointerType())
return Builder.CreateAdd(Ops.LHS, Ops.RHS, "add");
-
- // FIXME: What about a pointer to a VLA?
+
+ if (Ops.Ty->getAsPointerType()->isVariableArrayType()) {
+ // The amount of the addition needs to account for the VLA size
+ CGF.ErrorUnsupported(Ops.E, "VLA pointer addition");
+ }
Value *Ptr, *Idx;
Expr *IdxExp;
const PointerType *PT;
if (!isa<llvm::PointerType>(Ops.LHS->getType()))
return Builder.CreateSub(Ops.LHS, Ops.RHS, "sub");
+ if (Ops.E->getLHS()->getType()->getAsPointerType()->isVariableArrayType()) {
+ // The amount of the addition needs to account for the VLA size for
+ // ptr-int
+ // The amount of the division needs to account for the VLA size for
+ // ptr-ptr.
+ CGF.ErrorUnsupported(Ops.E, "VLA pointer subtraction");
+ }
+
const QualType LHSType = Ops.E->getLHS()->getType();
const QualType LHSElementType = LHSType->getAsPointerType()->getPointeeType();
if (!isa<llvm::PointerType>(Ops.RHS->getType())) {
Idx = Builder.CreateZExt(Idx, IdxType, "idx.ext");
}
Idx = Builder.CreateNeg(Idx, "sub.ptr.neg");
-
- // FIXME: The pointer could point to a VLA.
// Explicitly handle GNU void* and function pointer arithmetic
// extensions. The GNU void* casts amount to no-ops since our
// Store the value into the LHS. Bit-fields are handled specially
// because the result is altered by the store, i.e., [C99 6.5.16p1]
// 'An assignment expression has the value of the left operand after
- // the assignment...'.
- // FIXME: Volatility!
+ // the assignment...'.
if (LHS.isBitfield())
CGF.EmitStoreThroughBitfieldLValue(RValue::get(RHS), LHS, E->getType(),
&RHS);
if (!ArgPtr)
return Builder.CreateVAArg(ArgValue, ConvertType(VE->getType()));
- // FIXME: volatile?
return Builder.CreateLoad(ArgPtr);
}