Commit 69c8c96
[Sema] Use underlying type of scoped enum for -Wformat diagnostics (llvm#67378)
Right now, `-Wformat` for a scoped enum will suggest a cast based on the
format specifier being used. This can lead to incorrect results, e.g.
attempting to format a scoped enum with `%s` would suggest casting to
`char *` instead of fixing the specifier. Change the logic to treat the
scoped enum's underlying type as the intended type to be printed, and
suggest format specifier changes and casts based on that.
(cherry picked from commit 0b07b06)1 parent b2417f5 commit 69c8c96
File tree
4 files changed
+67
-19
lines changed- clang
- docs
- lib/Sema
- test/FixIt
4 files changed
+67
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
| 478 | + | |
| 479 | + | |
482 | 480 | | |
483 | 481 | | |
484 | 482 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11166 | 11166 | | |
11167 | 11167 | | |
11168 | 11168 | | |
| 11169 | + | |
11169 | 11170 | | |
11170 | 11171 | | |
11171 | 11172 | | |
| 11173 | + | |
11172 | 11174 | | |
| 11175 | + | |
11173 | 11176 | | |
11174 | | - | |
| 11177 | + | |
11175 | 11178 | | |
11176 | 11179 | | |
11177 | 11180 | | |
| |||
11183 | 11186 | | |
11184 | 11187 | | |
11185 | 11188 | | |
11186 | | - | |
11187 | 11189 | | |
11188 | 11190 | | |
11189 | 11191 | | |
| |||
11219 | 11221 | | |
11220 | 11222 | | |
11221 | 11223 | | |
11222 | | - | |
11223 | | - | |
| 11224 | + | |
| 11225 | + | |
| 11226 | + | |
| 11227 | + | |
11224 | 11228 | | |
11225 | 11229 | | |
11226 | 11230 | | |
| |||
11275 | 11279 | | |
11276 | 11280 | | |
11277 | 11281 | | |
11278 | | - | |
| 11282 | + | |
11279 | 11283 | | |
11280 | 11284 | | |
11281 | 11285 | | |
11282 | | - | |
11283 | | - | |
11284 | | - | |
11285 | | - | |
11286 | | - | |
11287 | | - | |
| 11286 | + | |
11288 | 11287 | | |
11289 | 11288 | | |
11290 | 11289 | | |
11291 | | - | |
| 11290 | + | |
11292 | 11291 | | |
11293 | 11292 | | |
11294 | 11293 | | |
| |||
11316 | 11315 | | |
11317 | 11316 | | |
11318 | 11317 | | |
11319 | | - | |
| 11318 | + | |
11320 | 11319 | | |
11321 | 11320 | | |
11322 | 11321 | | |
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | 28 | | |
24 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
25 | 32 | | |
26 | 33 | | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
30 | 42 | | |
31 | 43 | | |
32 | 44 | | |
| |||
58 | 70 | | |
59 | 71 | | |
60 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
61 | 77 | | |
0 commit comments