Commit ee9487b
committed
[Strict memory safety] Provide argument-specific diagnostics for calls
Similar to what we do for 'throws' checking, perform argument-specific
checking for unsafe call arguments. This provides more detailed failures:
```
example.swift:18:3: warning: expression uses unsafe constructs but is not
marked with 'unsafe' [#StrictMemorySafety]
16 | x.f(a: 0, b: 17, c: nil)
17 |
18 | x.f(a: 0, b: 17, c: &i)
| | `- note: argument 'c' in call to instance
method 'f' has unsafe type 'UnsafePointer<Int>?'
| `- warning: expression uses unsafe constructs but is not marked
with 'unsafe' [#StrictMemorySafety]
19 | unsafeF()
20 | }
```
It also means that we won't complain for `nil` or `Optional.none`
arguments passed to unsafe types, which eliminates some false
positives, and won't complain about unsafe result types when there is
a call---because we'd still get complaints later about the
actually-unsafe bit, which is using those results.
Fixes rdar://149629670.1 parent 0b264e2 commit ee9487b
File tree
11 files changed
+365
-110
lines changed- include/swift/AST
- lib/Sema
- test/Unsafe
11 files changed
+365
-110
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8341 | 8341 | | |
8342 | 8342 | | |
8343 | 8343 | | |
| 8344 | + | |
| 8345 | + | |
| 8346 | + | |
| 8347 | + | |
| 8348 | + | |
| 8349 | + | |
| 8350 | + | |
| 8351 | + | |
| 8352 | + | |
8344 | 8353 | | |
8345 | 8354 | | |
8346 | 8355 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| |||
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
94 | 105 | | |
95 | 106 | | |
96 | 107 | | |
| |||
201 | 212 | | |
202 | 213 | | |
203 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
204 | 228 | | |
205 | 229 | | |
206 | 230 | | |
| |||
242 | 266 | | |
243 | 267 | | |
244 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
245 | 272 | | |
246 | 273 | | |
247 | 274 | | |
| |||
257 | 284 | | |
258 | 285 | | |
259 | 286 | | |
| 287 | + | |
260 | 288 | | |
261 | 289 | | |
262 | 290 | | |
| |||
298 | 326 | | |
299 | 327 | | |
300 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
301 | 332 | | |
302 | 333 | | |
303 | 334 | | |
| |||
330 | 361 | | |
331 | 362 | | |
332 | 363 | | |
| 364 | + | |
333 | 365 | | |
334 | 366 | | |
335 | 367 | | |
| |||
360 | 392 | | |
361 | 393 | | |
362 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
363 | 398 | | |
364 | 399 | | |
365 | 400 | | |
| |||
386 | 421 | | |
387 | 422 | | |
388 | 423 | | |
| 424 | + | |
389 | 425 | | |
390 | 426 | | |
391 | 427 | | |
392 | 428 | | |
393 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
394 | 442 | | |
395 | 443 | | |
396 | 444 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2699 | 2699 | | |
2700 | 2700 | | |
2701 | 2701 | | |
| 2702 | + | |
2702 | 2703 | | |
2703 | 2704 | | |
2704 | 2705 | | |
| |||
0 commit comments