diff options
author | Volodymyr Sapsai <vsapsai@apple.com> | 2017-10-27 00:56:23 +0000 |
---|---|---|
committer | Volodymyr Sapsai <vsapsai@apple.com> | 2017-10-27 00:56:23 +0000 |
commit | 636ed47428c1cf9304c4131d631f3c0b72f020ad (patch) | |
tree | 5cbb1d309e7abbc9f184ec04ebc38c5771a5dfb4 /clang/lib/CodeGen/CGObjCMac.cpp | |
parent | 145090f124039a3f02819030d762f1d74d2cba1b (diff) | |
download | bcm5719-llvm-636ed47428c1cf9304c4131d631f3c0b72f020ad.tar.gz bcm5719-llvm-636ed47428c1cf9304c4131d631f3c0b72f020ad.zip |
[CodeGen] Add support for IncompleteArrayType in Obj-C ivars.
Fixes an assertion failure when ivar is a struct containing incomplete
array. Also completes support for direct flexible array members.
rdar://problem/21054495
Reviewers: rjmccall, theraven
Reviewed By: rjmccall
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D38774
llvm-svn: 316723
Diffstat (limited to 'clang/lib/CodeGen/CGObjCMac.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 85901a6d65d..992da814093 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -5084,6 +5084,11 @@ void IvarLayoutBuilder::visitField(const FieldDecl *field, // Drill down into arrays. uint64_t numElts = 1; + if (auto arrayType = CGM.getContext().getAsIncompleteArrayType(fieldType)) { + numElts = 0; + fieldType = arrayType->getElementType(); + } + // Unlike incomplete arrays, constant arrays can be nested. while (auto arrayType = CGM.getContext().getAsConstantArrayType(fieldType)) { numElts *= arrayType->getSize().getZExtValue(); fieldType = arrayType->getElementType(); |