summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGNonTrivialStruct.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2019-03-29 00:23:20 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2019-03-29 00:23:20 +0000
commit8b8d36231369740746ed7e60233c69edd11b69ad (patch)
tree641f66bc581cfa0ca2f2a48f38fe8bb37eafb29d /clang/lib/CodeGen/CGNonTrivialStruct.cpp
parent801cc3272a5fd460fbd9062f8a582726c73494d7 (diff)
downloadbcm5719-llvm-8b8d36231369740746ed7e60233c69edd11b69ad.tar.gz
bcm5719-llvm-8b8d36231369740746ed7e60233c69edd11b69ad.zip
[CodeGen][ObjC] Adjust the addresses passed to calls to synthesized
copy/move constructor/assignment operator functions for non-trivial C structs. This commit fixes a bug where the offset of struct fields weren't being taken into account when computing the addresses passed to calls to the special functions. For example, the copy constructor for S1 (__copy_constructor_8_8_s0_s8) would pass the start addresses of the destination and source structs to the call to S0's copy constructor (_copy_constructor_8_8_s0) without adding the offset of field f1 to the addresses. typedef struct { id f0; S0 f1; } S1; void test(S1 s1) { S1 t = s1; } rdar://problem/49400610 llvm-svn: 357229
Diffstat (limited to 'clang/lib/CodeGen/CGNonTrivialStruct.cpp')
-rw-r--r--clang/lib/CodeGen/CGNonTrivialStruct.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGNonTrivialStruct.cpp b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
index 09c5d69e079..a73d91d30a4 100644
--- a/clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -688,6 +688,8 @@ struct GenCopyConstructor : GenBinaryFunc<GenCopyConstructor, false> {
void callSpecialFunction(QualType FT, CharUnits Offset,
std::array<Address, 2> Addrs) {
+ Addrs[DstIdx] = getAddrWithOffset(Addrs[DstIdx], Offset);
+ Addrs[SrcIdx] = getAddrWithOffset(Addrs[SrcIdx], Offset);
CGF->callCStructCopyConstructor(CGF->MakeAddrLValue(Addrs[DstIdx], FT),
CGF->MakeAddrLValue(Addrs[SrcIdx], FT));
}
@@ -718,6 +720,8 @@ struct GenMoveConstructor : GenBinaryFunc<GenMoveConstructor, true> {
void callSpecialFunction(QualType FT, CharUnits Offset,
std::array<Address, 2> Addrs) {
+ Addrs[DstIdx] = getAddrWithOffset(Addrs[DstIdx], Offset);
+ Addrs[SrcIdx] = getAddrWithOffset(Addrs[SrcIdx], Offset);
CGF->callCStructMoveConstructor(CGF->MakeAddrLValue(Addrs[DstIdx], FT),
CGF->MakeAddrLValue(Addrs[SrcIdx], FT));
}
@@ -746,6 +750,8 @@ struct GenCopyAssignment : GenBinaryFunc<GenCopyAssignment, false> {
void callSpecialFunction(QualType FT, CharUnits Offset,
std::array<Address, 2> Addrs) {
+ Addrs[DstIdx] = getAddrWithOffset(Addrs[DstIdx], Offset);
+ Addrs[SrcIdx] = getAddrWithOffset(Addrs[SrcIdx], Offset);
CGF->callCStructCopyAssignmentOperator(
CGF->MakeAddrLValue(Addrs[DstIdx], FT),
CGF->MakeAddrLValue(Addrs[SrcIdx], FT));
@@ -780,6 +786,8 @@ struct GenMoveAssignment : GenBinaryFunc<GenMoveAssignment, true> {
void callSpecialFunction(QualType FT, CharUnits Offset,
std::array<Address, 2> Addrs) {
+ Addrs[DstIdx] = getAddrWithOffset(Addrs[DstIdx], Offset);
+ Addrs[SrcIdx] = getAddrWithOffset(Addrs[SrcIdx], Offset);
CGF->callCStructMoveAssignmentOperator(
CGF->MakeAddrLValue(Addrs[DstIdx], FT),
CGF->MakeAddrLValue(Addrs[SrcIdx], FT));
OpenPOWER on IntegriCloud