The fix is to remove duplicate copy-initialization of the only memcpy-able struct member and to correct the address of aggregately initialized members in destructors' calls during stack unwinding (in order to obtain address of struct member by using GEP instead of 'bitcast').
Details
Diff Detail
Event Timeline
lib/CodeGen/CGClass.cpp | ||
---|---|---|
1105 | Wow, the old code here was really impressively broken. Saved by the rule of 3/5, I guess. Okay, two code organization requests. Please add a method on CXXCtorInitializer to get the type of the initialized member. Then, please extract a function in this file to drill down to the initialized member of a CXXCtorInitializer. With that combination, the code here should end up looking really straightforward. Please also update EmitMemberInitializer to use your new functions. |
A function to emit lvalue for any field initialization was added (it also drills down to the field of anonymous unions). The code was adapted to work with this new function.
In previous review there was a request to add a method to CXXCtorInitializer to get the type of the initialized member. I realized that this can be done simply by getAnyMember()->getType() and decided not to add this method, because the new code looks pretty straightforward, I think.
Wow, the old code here was really impressively broken. Saved by the rule of 3/5, I guess.
Okay, two code organization requests. Please add a method on CXXCtorInitializer to get the type of the initialized member. Then, please extract a function in this file to drill down to the initialized member of a CXXCtorInitializer.
With that combination, the code here should end up looking really straightforward.
Please also update EmitMemberInitializer to use your new functions.