[PATCH] D38774: [CodeGen] Add support for IncompleteArrayType in Obj-C ivars.
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 26 17:56:52 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316723: [CodeGen] Add support for IncompleteArrayType in Obj-C ivars. (authored by vsapsai).
Changed prior to commit:
https://reviews.llvm.org/D38774?vs=120337&id=120524#toc
Repository:
rL LLVM
https://reviews.llvm.org/D38774
Files:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m
Index: cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m
===================================================================
--- cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m
+++ cfe/trunk/test/CodeGenObjC/ivar-layout-flexible-array.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wno-objc-root-class -fobjc-arc -emit-llvm -o - %s | FileCheck %s
+
+// rdar://problem/21054495
+ at interface FlexibleArrayMember {
+ char flexible_array[][4][2];
+}
+ at end
+ at implementation FlexibleArrayMember
+ at end
+// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}} c"flexible_array\00"
+// CHECK-NEXT: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant {{.*}} c"^[4[2c]]\00"
+
+
+typedef char FlexibleArray[];
+
+struct Packet {
+ int size;
+ FlexibleArray data;
+};
+
+ at interface VariableSizeIvar {
+ struct Packet flexible_struct;
+}
+ at end
+ at implementation VariableSizeIvar
+ at end
+// CHECK: @OBJC_METH_VAR_NAME_{{.*}} = private unnamed_addr constant {{.*}} c"flexible_struct\00"
+// CHECK-NEXT: @OBJC_METH_VAR_TYPE_{{.*}} = private unnamed_addr constant {{.*}} c"{Packet=\22size\22i\22data\22[0c]}\00"
Index: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp
@@ -5084,6 +5084,11 @@
// 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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38774.120524.patch
Type: text/x-patch
Size: 1820 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171027/74601af8/attachment.bin>
More information about the cfe-commits
mailing list