Commit ebb8966
committed
[BoundsSafety] Rebuild bound attributed types when declaring a function with typeof/typedef
Declaring a function with typedef/typeof, which has bounds attributed
types, creates a bounds attribute expression that refers to the
parameters of the old function.
void foo(int *__counted_by(len), int len);
__typeof__(foo) bar;
In the above example, the count expression in `bar` refers to `len` in
the function `foo`. Instead, it should refer to `len` in `bar`.
Moreover, declaring a function with typedef/typeof loses
`DependerDeclsAttr`. In the above example, `len` in `bar` won't have the
attribute.
This change rebuilds the function type if the function is declared with
typeof/typedef. This will rebuild the bounds attribute expression to
refer to the parameters of the function being declared. Moreover, it
creates `DependerDeclsAttr` for the dependent parameters.
rdar://131339532
(cherry picked from commit 14fa725)1 parent 0712898 commit ebb8966
File tree
8 files changed
+348
-47
lines changed- clang
- lib/Sema
- test/BoundsSafety
- AST
- Sema
8 files changed
+348
-47
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
573 | | - | |
574 | | - | |
| 573 | + | |
575 | 574 | | |
576 | 575 | | |
577 | 576 | | |
| |||
781 | 780 | | |
782 | 781 | | |
783 | 782 | | |
784 | | - | |
| 783 | + | |
785 | 784 | | |
786 | 785 | | |
787 | 786 | | |
| |||
969 | 968 | | |
970 | 969 | | |
971 | 970 | | |
972 | | - | |
| 971 | + | |
973 | 972 | | |
974 | 973 | | |
975 | 974 | | |
| |||
1025 | 1024 | | |
1026 | 1025 | | |
1027 | 1026 | | |
1028 | | - | |
| 1027 | + | |
1029 | 1028 | | |
1030 | 1029 | | |
1031 | 1030 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | 270 | | |
280 | 271 | | |
281 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10466 | 10466 | | |
10467 | 10467 | | |
10468 | 10468 | | |
| 10469 | + | |
| 10470 | + | |
| 10471 | + | |
| 10472 | + | |
| 10473 | + | |
| 10474 | + | |
| 10475 | + | |
| 10476 | + | |
| 10477 | + | |
| 10478 | + | |
| 10479 | + | |
| 10480 | + | |
| 10481 | + | |
| 10482 | + | |
| 10483 | + | |
| 10484 | + | |
| 10485 | + | |
| 10486 | + | |
| 10487 | + | |
| 10488 | + | |
| 10489 | + | |
| 10490 | + | |
| 10491 | + | |
| 10492 | + | |
| 10493 | + | |
| 10494 | + | |
| 10495 | + | |
| 10496 | + | |
| 10497 | + | |
| 10498 | + | |
| 10499 | + | |
| 10500 | + | |
| 10501 | + | |
| 10502 | + | |
| 10503 | + | |
| 10504 | + | |
| 10505 | + | |
| 10506 | + | |
| 10507 | + | |
| 10508 | + | |
| 10509 | + | |
| 10510 | + | |
| 10511 | + | |
| 10512 | + | |
| 10513 | + | |
| 10514 | + | |
| 10515 | + | |
| 10516 | + | |
| 10517 | + | |
| 10518 | + | |
| 10519 | + | |
| 10520 | + | |
| 10521 | + | |
| 10522 | + | |
| 10523 | + | |
| 10524 | + | |
| 10525 | + | |
| 10526 | + | |
| 10527 | + | |
| 10528 | + | |
| 10529 | + | |
| 10530 | + | |
| 10531 | + | |
| 10532 | + | |
| 10533 | + | |
| 10534 | + | |
| 10535 | + | |
| 10536 | + | |
| 10537 | + | |
| 10538 | + | |
| 10539 | + | |
10469 | 10540 | | |
10470 | 10541 | | |
10471 | 10542 | | |
| |||
11025 | 11096 | | |
11026 | 11097 | | |
11027 | 11098 | | |
11028 | | - | |
11029 | | - | |
11030 | | - | |
11031 | | - | |
11032 | | - | |
| 11099 | + | |
| 11100 | + | |
| 11101 | + | |
| 11102 | + | |
| 11103 | + | |
| 11104 | + | |
| 11105 | + | |
| 11106 | + | |
| 11107 | + | |
| 11108 | + | |
| 11109 | + | |
| 11110 | + | |
| 11111 | + | |
| 11112 | + | |
| 11113 | + | |
| 11114 | + | |
| 11115 | + | |
| 11116 | + | |
| 11117 | + | |
| 11118 | + | |
| 11119 | + | |
| 11120 | + | |
| 11121 | + | |
| 11122 | + | |
| 11123 | + | |
| 11124 | + | |
| 11125 | + | |
| 11126 | + | |
| 11127 | + | |
| 11128 | + | |
| 11129 | + | |
| 11130 | + | |
| 11131 | + | |
| 11132 | + | |
| 11133 | + | |
| 11134 | + | |
| 11135 | + | |
| 11136 | + | |
| 11137 | + | |
| 11138 | + | |
| 11139 | + | |
| 11140 | + | |
| 11141 | + | |
| 11142 | + | |
| 11143 | + | |
| 11144 | + | |
| 11145 | + | |
| 11146 | + | |
| 11147 | + | |
| 11148 | + | |
| 11149 | + | |
| 11150 | + | |
| 11151 | + | |
| 11152 | + | |
| 11153 | + | |
| 11154 | + | |
| 11155 | + | |
| 11156 | + | |
11033 | 11157 | | |
11034 | 11158 | | |
11035 | 11159 | | |
| |||
11040 | 11164 | | |
11041 | 11165 | | |
11042 | 11166 | | |
| 11167 | + | |
| 11168 | + | |
| 11169 | + | |
| 11170 | + | |
| 11171 | + | |
| 11172 | + | |
| 11173 | + | |
| 11174 | + | |
| 11175 | + | |
| 11176 | + | |
| 11177 | + | |
| 11178 | + | |
| 11179 | + | |
| 11180 | + | |
11043 | 11181 | | |
11044 | 11182 | | |
11045 | 11183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7851 | 7851 | | |
7852 | 7852 | | |
7853 | 7853 | | |
7854 | | - | |
| 7854 | + | |
7855 | 7855 | | |
7856 | 7856 | | |
7857 | 7857 | | |
| |||
22339 | 22339 | | |
22340 | 22340 | | |
22341 | 22341 | | |
22342 | | - | |
22343 | | - | |
22344 | | - | |
22345 | | - | |
22346 | | - | |
22347 | | - | |
22348 | | - | |
22349 | | - | |
22350 | 22342 | | |
22351 | 22343 | | |
22352 | 22344 | | |
| |||
25162 | 25154 | | |
25163 | 25155 | | |
25164 | 25156 | | |
25165 | | - | |
25166 | | - | |
| 25157 | + | |
25167 | 25158 | | |
25168 | 25159 | | |
25169 | 25160 | | |
| |||
25173 | 25164 | | |
25174 | 25165 | | |
25175 | 25166 | | |
25176 | | - | |
| 25167 | + | |
25177 | 25168 | | |
25178 | 25169 | | |
25179 | 25170 | | |
| |||
25197 | 25188 | | |
25198 | 25189 | | |
25199 | 25190 | | |
25200 | | - | |
25201 | | - | |
| 25191 | + | |
25202 | 25192 | | |
25203 | 25193 | | |
25204 | 25194 | | |
| |||
25213 | 25203 | | |
25214 | 25204 | | |
25215 | 25205 | | |
25216 | | - | |
| 25206 | + | |
25217 | 25207 | | |
25218 | 25208 | | |
25219 | 25209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7469 | 7469 | | |
7470 | 7470 | | |
7471 | 7471 | | |
7472 | | - | |
| 7472 | + | |
7473 | 7473 | | |
7474 | 7474 | | |
7475 | 7475 | | |
| |||
Lines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
120 | | - | |
| 119 | + | |
| 120 | + | |
121 | 121 | | |
122 | | - | |
123 | | - | |
| 122 | + | |
| 123 | + | |
124 | 124 | | |
125 | | - | |
126 | | - | |
| 125 | + | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
0 commit comments