[PATCH] D58016: fixes copy constructor generation of classes containing 0-length arrays followed by exactly 1 trivial field (fixes #40682)
Joran Bigalet via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 10 12:42:04 PST 2019
jbigalet updated this revision to Diff 186162.
jbigalet added a comment.
regression test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58016/new/
https://reviews.llvm.org/D58016
Files:
clang/lib/CodeGen/CGClass.cpp
clang/test/CodeGenCXX/pod-member-memcpys.cpp
Index: clang/test/CodeGenCXX/pod-member-memcpys.cpp
===================================================================
--- clang/test/CodeGenCXX/pod-member-memcpys.cpp
+++ clang/test/CodeGenCXX/pod-member-memcpys.cpp
@@ -45,6 +45,13 @@
int w, x, y, z;
};
+struct ZeroLengthArrayMember {
+ NonPOD np;
+ int a;
+ int b[0];
+ int c;
+};
+
struct VolatileMember {
int a, b, c, d;
volatile int v;
@@ -109,6 +116,7 @@
CALL_AO(PODMember)
CALL_AO(PODLikeMember)
CALL_AO(ArrayMember)
+CALL_AO(ZeroLengthArrayMember)
CALL_AO(VolatileMember)
CALL_AO(BitfieldMember)
CALL_AO(InnerClassMember)
@@ -142,6 +150,12 @@
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}} align 4 {{.*}} align 4 {{.*}}i64 64, i1 {{.*}})
// CHECK: ret %struct.ArrayMember*
+// ZeroLengthArrayMember copy-assignment:
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.ZeroLengthArrayMember* @_ZN21ZeroLengthArrayMemberaSERKS_(%struct.ZeroLengthArrayMember* %this, %struct.ZeroLengthArrayMember* dereferenceable({{[0-9]+}}))
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.NonPOD* @_ZN6NonPODaSERKS_
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}} align 4 {{.*}} align 4 {{.*}}i64 8, i1 {{.*}})
+// CHECK: ret %struct.ZeroLengthArrayMember*
+
// VolatileMember copy-assignment:
// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.VolatileMember* @_ZN14VolatileMemberaSERKS_(%struct.VolatileMember* %this, %struct.VolatileMember* dereferenceable({{[0-9]+}}))
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}} align 4 {{.*}} align 4 {{.*}}i64 16, i1 {{.*}})
Index: clang/lib/CodeGen/CGClass.cpp
===================================================================
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -1012,7 +1012,7 @@
if (FOffset < FirstFieldOffset) {
FirstField = F;
FirstFieldOffset = FOffset;
- } else if (FOffset > LastFieldOffset) {
+ } else if (FOffset >= LastFieldOffset) {
LastField = F;
LastFieldOffset = FOffset;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58016.186162.patch
Type: text/x-patch
Size: 2078 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190210/3a3bd213/attachment.bin>
More information about the cfe-commits
mailing list