aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-08-15 00:03:43 +0000
committerChris Lattner <sabre@nondot.org>2009-08-15 00:03:43 +0000
commitec18ddd33d5dc2cba5f64fa903bac7a83dc1e01e (patch)
treec903aa37b13d37f953b3990cd47ba03d2ea6eb53 /lib/CodeGen/CodeGenFunction.cpp
parent881eb9ce336c1fe29cab92c06a1900fccd0951d1 (diff)
minor cleanups for VLA stuff.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index a977add65f..e4a83bce02 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -493,19 +493,16 @@ llvm::Value *CodeGenFunction::EmitVLASize(QualType Ty) {
llvm::Value *&SizeEntry = VLASizeMap[VAT];
if (!SizeEntry) {
- // Get the element size;
- llvm::Value *ElemSize;
-
- QualType ElemTy = VAT->getElementType();
-
const llvm::Type *SizeTy = ConvertType(getContext().getSizeType());
+ // Get the element size;
+ QualType ElemTy = VAT->getElementType();
+ llvm::Value *ElemSize;
if (ElemTy->isVariableArrayType())
ElemSize = EmitVLASize(ElemTy);
- else {
+ else
ElemSize = llvm::ConstantInt::get(SizeTy,
getContext().getTypeSize(ElemTy) / 8);
- }
llvm::Value *NumElements = EmitScalarExpr(VAT->getSizeExpr());
NumElements = Builder.CreateIntCast(NumElements, SizeTy, false, "tmp");
@@ -514,14 +511,16 @@ llvm::Value *CodeGenFunction::EmitVLASize(QualType Ty) {
}
return SizeEntry;
- } else if (const ArrayType *AT = dyn_cast<ArrayType>(Ty)) {
- EmitVLASize(AT->getElementType());
- } else if (const PointerType *PT = Ty->getAs<PointerType>())
- EmitVLASize(PT->getPointeeType());
- else {
- assert(0 && "unknown VM type!");
}
+ if (const ArrayType *AT = dyn_cast<ArrayType>(Ty)) {
+ EmitVLASize(AT->getElementType());
+ return 0;
+ }
+
+ const PointerType *PT = Ty->getAs<PointerType>();
+ assert(PT && "unknown VM type!");
+ EmitVLASize(PT->getPointeeType());
return 0;
}