Commit 94213a4
authored
[LifetimeSafety] Add support for GSL Pointer types (#154009)
This extends the lifetime safety analysis to support C++ types annotated
with `gsl::Pointer`, which represent non-owning "view" types like
`std::string_view`. These types have the same lifetime safety concerns
as raw pointers and references.
- Added support for detecting and analyzing `gsl::Pointer` annotated
types in lifetime safety analysis
- Implemented handling for various expressions involving `gsl::Pointer`
types:
- Constructor expressions
- Member call expressions (especially conversion operators)
- Functional cast expressions
- Initialization list expressions
- Materialized temporary expressions
- Updated the pointer type detection to recognize `gsl::Pointer` types
- Added handling for function calls that create borrows through
reference parameters
Fixes: #1525131 parent 91d4c0d commit 94213a4
File tree
3 files changed
+381
-15
lines changed- clang
- lib/Analysis
- test/Sema
- unittests/Analysis
3 files changed
+381
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
478 | 478 | | |
479 | 479 | | |
480 | 480 | | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
481 | 500 | | |
482 | 501 | | |
483 | 502 | | |
| |||
530 | 549 | | |
531 | 550 | | |
532 | 551 | | |
533 | | - | |
| 552 | + | |
534 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
535 | 573 | | |
536 | 574 | | |
537 | 575 | | |
| |||
557 | 595 | | |
558 | 596 | | |
559 | 597 | | |
560 | | - | |
561 | | - | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
562 | 608 | | |
563 | 609 | | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
564 | 613 | | |
565 | 614 | | |
566 | 615 | | |
| |||
570 | 619 | | |
571 | 620 | | |
572 | 621 | | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
573 | 657 | | |
574 | 658 | | |
575 | 659 | | |
| |||
593 | 677 | | |
594 | 678 | | |
595 | 679 | | |
596 | | - | |
| 680 | + | |
597 | 681 | | |
598 | 682 | | |
599 | 683 | | |
| |||
641 | 725 | | |
642 | 726 | | |
643 | 727 | | |
| 728 | + | |
| 729 | + | |
644 | 730 | | |
645 | 731 | | |
646 | 732 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
9 | 15 | | |
10 | 16 | | |
11 | 17 | | |
| |||
20 | 26 | | |
21 | 27 | | |
22 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
23 | 38 | | |
24 | 39 | | |
25 | 40 | | |
26 | 41 | | |
27 | 42 | | |
28 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
29 | 54 | | |
30 | 55 | | |
31 | 56 | | |
| |||
39 | 64 | | |
40 | 65 | | |
41 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
42 | 77 | | |
43 | 78 | | |
44 | 79 | | |
| |||
78 | 113 | | |
79 | 114 | | |
80 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
81 | 129 | | |
82 | 130 | | |
83 | 131 | | |
| |||
94 | 142 | | |
95 | 143 | | |
96 | 144 | | |
97 | | - | |
98 | | - | |
99 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
100 | 148 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 149 | + | |
| 150 | + | |
107 | 151 | | |
108 | | - | |
| 152 | + | |
109 | 153 | | |
110 | 154 | | |
111 | 155 | | |
| |||
159 | 203 | | |
160 | 204 | | |
161 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
162 | 216 | | |
163 | 217 | | |
164 | 218 | | |
| |||
182 | 236 | | |
183 | 237 | | |
184 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
185 | 252 | | |
186 | 253 | | |
187 | 254 | | |
| |||
258 | 325 | | |
259 | 326 | | |
260 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
261 | 350 | | |
262 | 351 | | |
263 | 352 | | |
| |||
271 | 360 | | |
272 | 361 | | |
273 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
0 commit comments