summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprScalar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r--lib/CodeGen/CGExprScalar.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 7f417b374a..857a40e6c8 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -663,7 +663,14 @@ ScalarExprEmitter::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) {
if (TypeToSize->isVoidType() || TypeToSize->isFunctionType())
return llvm::ConstantInt::get(llvm::APInt(ResultWidth, 1));
- /// FIXME: This doesn't handle VLAs yet!
+ if (const VariableArrayType *VAT =
+ CGF.getContext().getAsVariableArrayType(TypeToSize)) {
+ if (E->isSizeOf())
+ return CGF.GetVLASize(VAT);
+ else
+ assert(0 && "alignof VLAs not implemented yet");
+ }
+
std::pair<uint64_t, unsigned> Info = CGF.getContext().getTypeInfo(TypeToSize);
uint64_t Val = E->isSizeOf() ? Info.first : Info.second;