| 1 | // RUN: %check_clang_tidy %s objc-dealloc-in-category %t |
| 2 | |
| 3 | @interface NSObject |
| 4 | // Used to quash warning about missing base class. |
| 5 | - (void)dealloc; |
| 6 | @end |
| 7 | |
| 8 | @interface Foo : NSObject |
| 9 | @end |
| 10 | |
| 11 | @implementation Foo |
| 12 | - (void)dealloc { |
| 13 | // No warning should be generated here. |
| 14 | } |
| 15 | @end |
| 16 | |
| 17 | @interface Bar : NSObject |
| 18 | @end |
| 19 | |
| 20 | @interface Bar (BarCategory) |
| 21 | @end |
| 22 | |
| 23 | @implementation Bar (BarCategory) |
| 24 | + (void)dealloc { |
| 25 | // Should not trigger on class methods. |
| 26 | } |
| 27 | |
| 28 | - (void)dealloc { |
| 29 | // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: category 'BarCategory' should not implement -dealloc [objc-dealloc-in-category] |
| 30 | } |
| 31 | @end |
| 32 | |
| 33 | @interface Baz : NSObject |
| 34 | @end |
| 35 | |
| 36 | @implementation Baz |
| 37 | - (void)dealloc { |
| 38 | // Should not trigger on implementation in the class itself, even with |
| 39 | // it declared in the category (below). |
| 40 | } |
| 41 | @end |
| 42 | |
| 43 | @interface Baz (BazCategory) |
| 44 | // A declaration in a category @interface does not by itself provide an |
| 45 | // overriding implementation, and should not generate a warning. |
| 46 | - (void)dealloc; |
| 47 | @end |
| 48 | |