Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[uninit] Revise translation of conditional expression for C struct
Summary: This diff revises the translation of the conditional expression for C struct. ``` struct S = { int f1; int f2; } struct S foo(int b) { ... return b ? x : y; } ``` Before this diff, the return statements were translated to ``` n$0 = *&__return_param; ... *n$0 = x; // at the true branch ... *n$0 = y; // at the false branch ``` However, this is incorrect because there is no first-value for C struct in SIL. By this diff, it is translated to multiple instructions that copy each field separately. ``` n$0 = *&__return_param; ... n$1 = *&x.f1; // at the true branch *n$0.f1 = n$1; n$2 = *&x.f2; *n$0.f2 = n$2; ... n$3 = *&y.f1; // at the false branch *n$0.f1 = n$3; n$4 = *&y.f2; *n$0.f2 = n$4; ``` Reviewed By: jvillard Differential Revision: D49829058 fbshipit-source-id: 3b9dd95d82e0d4e37c709126117ef7c5a130c3d7
- Loading branch information