[PATCH] D72876: Create a clang-tidy check to warn when -dealloc is implemented inside an ObjC class category.
Stephane Moore via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 24 17:03:31 PST 2020
stephanemoore added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/objc/DeallocInCategoriesCheck.cpp:19
+
+void DeallocInCategoriesCheck::registerMatchers(MatchFinder *Finder) {
+ Finder->addMatcher(
----------------
Early return if the language is not an Objective-C variant:
```
// This check should only be applied to Objective-C sources.
if (!getLangOpts().ObjC)
return;
```
================
Comment at: clang-tools-extra/clang-tidy/objc/DeallocInCategoriesCheck.cpp:21
+ Finder->addMatcher(
+ objcMethodDecl(hasName("dealloc"), hasDeclContext(objcCategoryImplDecl()))
+ .bind("dealloc"),
----------------
stephanemoore wrote:
> Add `isInstanceMethod()` within the `objcMethodDecl`?
Technically, isn't `-dealloc` specific to certain classes, e.g., [`NSObject`](https://developer.apple.com/documentation/objectivec/nsobject/1571947-dealloc?language=objc)) and [NSProxy](https://developer.apple.com/documentation/foundation/nsproxy/1589830-dealloc?language=objc)? If that is true, we should technically check that the category is on a class that is or is derived from a relevant class like `NSObject` or `NSProxy`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72876/new/
https://reviews.llvm.org/D72876
More information about the cfe-commits
mailing list