clang/test/Analysis/objc-live-crash.mm
raw| 1 | // RUN: %clang --analyze %s -fblocks |
| 2 | |
| 3 | // https://reviews.llvm.org/D82598#2171312 |
| 4 | |
| 5 | @interface Item |
| 6 | // ... |
| 7 | @end |
| 8 | |
| 9 | @interface Collection |
| 10 | // ... |
| 11 | @end |
| 12 | |
| 13 | typedef void (^Blk)(); |
| 14 | |
| 15 | struct RAII { |
| 16 | Blk blk; |
| 17 | |
| 18 | public: |
| 19 | RAII(Blk blk): blk(blk) {} |
| 20 | ~RAII() { blk(); } |
| 21 | }; |
| 22 | |
| 23 | void foo(Collection *coll) { |
| 24 | RAII raii(^{}); |
| 25 | for (Item *item in coll) {} |
| 26 | int i; |
| 27 | { |
| 28 | int j; |
| 29 | } |
| 30 | } |