[PATCH] D59806: [clang-tidy] Add a check for [super self] in initializers π
Stephane Moore via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 25 18:20:39 PDT 2019
stephanemoore created this revision.
Herald added subscribers: cfe-commits, jdoerfert, xazax.hun, mgorny.
Herald added a project: clang.
stephanemoore edited the summary of this revision.
This check aims to address a relatively common benign error where
Objective-C subclass initializers call -self on their superclass instead
of invoking a superclass initializer, typically -init. The error is
typically benign because libobjc recognizes that improper initializer
chaining is commonΒΉ.
One theory for the frequency of this error might be that -init and -self
have the same return type which could potentially cause inappropriate
autocompletion to -self instead of -init. The equal selector lengths and
triviality of common initializer code probably contribute to errors like
this slipping through code review undetected.
This check aims to flag errors of this form in the interests of
correctness and reduce incidence of initialization failing to chain to
-[NSObject init].
[1] "In practice, it will be hard to rely on this function. Many classes do not properly chain -init calls."
>From _objc_rootInit in https://opensource.apple.com/source/objc4/objc4-750.1/runtime/NSObject.mm.auto.html.
Test Notes:
Verified via `make check-clang-tools`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D59806
Files:
clang-tools-extra/clang-tidy/objc/CMakeLists.txt
clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
clang-tools-extra/clang-tidy/objc/SuperSelfCheck.cpp
clang-tools-extra/clang-tidy/objc/SuperSelfCheck.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang-tools-extra/docs/clang-tidy/checks/objc-super-self.rst
clang-tools-extra/test/clang-tidy/objc-super-self.m
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59806.192235.patch
Type: text/x-patch
Size: 9876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190326/3a7aae18/attachment.bin>
More information about the cfe-commits
mailing list