Commit 7150230
committed
[clang][Sema] Track trivial-relocatability as a type trait
To resolve #69394, this patch separates trivial-relocatability's logic from `canPassInRegisters` to decide if a type is trivial-relocatable. A type passed in registers doesn't necessarily mean trivial-relocatability of that type(e.g. on Windows) i.e. it gives us an unintended false positive. This change would be beneficial for Abseil since they rely upon these semantics.
By these changes now:
User-provided special members prevent natural trivial-relocatabilitiy.
It's important because Abseil and maybe others assume the assignment operator doesn't have an impact on the trivial-relocatability of a type.
In fact, it does have an effect, and with a user-provided assignment operator, the compiler should only accept it as trivial-relocatable if it's implied by the `[[clang::trivial_abi]]` attribute.
Just because a type can pass in registers doesn't necessarily mean it's trivial-relocatable.
The `[[clang::trivial_abi]]` attribute always implies trivial-relocatability, even if it can't pass in registers.
The trait has extensive tests for both old and new behaviors. Test aggregation of
both kinds of types as data members; inheritance; virtual member functions
and virtual bases; const and reference data members; and reference types.
Fixes #693941 parent 1c7607e commit 7150230
File tree
7 files changed
+228
-40
lines changed- clang
- include/clang/AST
- lib/AST
- test/SemaCXX
7 files changed
+228
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
192 | 197 | | |
193 | 198 | | |
194 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1386 | 1386 | | |
1387 | 1387 | | |
1388 | 1388 | | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
1389 | 1392 | | |
1390 | 1393 | | |
1391 | 1394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
279 | 280 | | |
280 | 281 | | |
281 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
282 | 287 | | |
283 | 288 | | |
284 | 289 | | |
| |||
293 | 298 | | |
294 | 299 | | |
295 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
296 | 304 | | |
297 | 305 | | |
298 | 306 | | |
| |||
572 | 580 | | |
573 | 581 | | |
574 | 582 | | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
575 | 587 | | |
576 | 588 | | |
577 | 589 | | |
| |||
760 | 772 | | |
761 | 773 | | |
762 | 774 | | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
763 | 779 | | |
764 | 780 | | |
765 | 781 | | |
| |||
826 | 842 | | |
827 | 843 | | |
828 | 844 | | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
829 | 853 | | |
830 | 854 | | |
831 | 855 | | |
| |||
855 | 879 | | |
856 | 880 | | |
857 | 881 | | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
858 | 885 | | |
859 | 886 | | |
860 | | - | |
| 887 | + | |
861 | 888 | | |
862 | 889 | | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
863 | 894 | | |
864 | 895 | | |
865 | 896 | | |
| |||
1068 | 1099 | | |
1069 | 1100 | | |
1070 | 1101 | | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1071 | 1108 | | |
1072 | 1109 | | |
1073 | 1110 | | |
| |||
1423 | 1460 | | |
1424 | 1461 | | |
1425 | 1462 | | |
1426 | | - | |
| 1463 | + | |
1427 | 1464 | | |
| 1465 | + | |
| 1466 | + | |
1428 | 1467 | | |
1429 | 1468 | | |
1430 | 1469 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2680 | 2680 | | |
2681 | 2681 | | |
2682 | 2682 | | |
2683 | | - | |
2684 | | - | |
| 2683 | + | |
| 2684 | + | |
| 2685 | + | |
| 2686 | + | |
2685 | 2687 | | |
2686 | 2688 | | |
2687 | 2689 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | 8 | | |
16 | | - | |
17 | 9 | | |
18 | 10 | | |
19 | 11 | | |
| |||
39 | 31 | | |
40 | 32 | | |
41 | 33 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | 34 | | |
49 | | - | |
50 | 35 | | |
51 | 36 | | |
52 | 37 | | |
| |||
118 | 103 | | |
119 | 104 | | |
120 | 105 | | |
121 | | - | |
122 | 106 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | 107 | | |
127 | 108 | | |
128 | 109 | | |
129 | 110 | | |
130 | | - | |
131 | 111 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | 112 | | |
136 | 113 | | |
137 | 114 | | |
138 | 115 | | |
139 | 116 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | 117 | | |
144 | | - | |
145 | 118 | | |
146 | 119 | | |
147 | 120 | | |
| |||
153 | 126 | | |
154 | 127 | | |
155 | 128 | | |
156 | | - | |
157 | 129 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | 130 | | |
162 | 131 | | |
163 | 132 | | |
164 | 133 | | |
165 | 134 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | 135 | | |
170 | | - | |
171 | 136 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
0 commit comments