[clang-tidy] Migrate objc-forbidden-subclassing to use isDerivedFrom 🚛

Summary:
This migrates objc-forbidden-subclassing to `isDerivedFrom` as it now
supports matching Objective-C interface declarations.

Test Notes:
Ran clang tools tests.

Reviewers: aaron.ballman, gribozavr

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66269

llvm-svn: 369076
This commit is contained in:
Stephane Moore 2019-08-16 01:52:17 +00:00
parent ba3d595f93
commit 8c90c1d2d5
1 changed files with 1 additions and 28 deletions

View File

@ -37,33 +37,6 @@ constexpr char DefaultForbiddenSuperClassNames[] =
"UITextInputMode;"
"UIWebView";
/// \brief Matches Objective-C classes that directly or indirectly
/// have a superclass matching \c Base.
///
/// Note that a class is not considered to be a subclass of itself.
///
/// Example matches Y, Z
/// (matcher = objcInterfaceDecl(hasName("X")))
/// \code
/// @interface X
/// @end
/// @interface Y : X // directly derived
/// @end
/// @interface Z : Y // indirectly derived
/// @end
/// \endcode
AST_MATCHER_P(ObjCInterfaceDecl, isSubclassOf,
ast_matchers::internal::Matcher<ObjCInterfaceDecl>, Base) {
for (const auto *SuperClass = Node.getSuperClass();
SuperClass != nullptr;
SuperClass = SuperClass->getSuperClass()) {
if (Base.matches(*SuperClass, Finder, Builder)) {
return true;
}
}
return false;
}
} // namespace
ForbiddenSubclassingCheck::ForbiddenSubclassingCheck(
@ -82,7 +55,7 @@ void ForbiddenSubclassingCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
objcInterfaceDecl(
isSubclassOf(
isDerivedFrom(
objcInterfaceDecl(
hasAnyName(
std::vector<StringRef>(