aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprScalar.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-12-21 03:48:05 +0000
committerAnders Carlsson <andersca@mac.com>2008-12-21 03:48:05 +0000
commit4a1424fd702299fbc354899b8c65bdf8491d8fe9 (patch)
treecaae905a9dc8c95ffb039d819039ed17f234d802 /lib/CodeGen/CGExprScalar.cpp
parent47b32407e45674a41a3d0a8ec4d6b30c1f4f8164 (diff)
Implement alignof for vla types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61305 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r--lib/CodeGen/CGExprScalar.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index d829facb16..a5d5bc22af 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -670,8 +670,13 @@ ScalarExprEmitter::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) {
}
return CGF.GetVLASize(VAT);
}
- // FIXME: This should be an UNSUPPORTED error.
- assert(0 && "alignof VLAs not implemented yet");
+
+ // alignof
+ QualType BaseType = CGF.getContext().getBaseElementType(VAT);
+ uint64_t Align = CGF.getContext().getTypeAlign(BaseType);
+
+ Align /= 8; // Return alignment in bytes, not bits.
+ return llvm::ConstantInt::get(llvm::APInt(ResultWidth, Align));
}
std::pair<uint64_t, unsigned> Info = CGF.getContext().getTypeInfo(TypeToSize);