]> granicus.if.org Git - clang/commit
[clang] Update isDerivedFrom to support Objective-C classes 🔍
authorStephane Moore <mog@google.com>
Mon, 12 Aug 2019 23:23:35 +0000 (23:23 +0000)
committerStephane Moore <mog@google.com>
Mon, 12 Aug 2019 23:23:35 +0000 (23:23 +0000)
commitf5d1b9974285a101b15e35c5d8ca73550d2a8c73
treefa492c2982da1d2313ecf0c98e4320a3710a0e00
parent8cfecdf7b60541f2e90fec818a6d5504efc422e2
[clang] Update isDerivedFrom to support Objective-C classes 🔍

Summary:
This change updates `isDerivedFrom` to support Objective-C classes by
converting it to a polymorphic matcher.

Notes:
The matching behavior for Objective-C classes is modeled to match the
behavior of `isDerivedFrom` with C++ classes. To that effect,
`isDerivedFrom` matches aliased types of derived Objective-C classes,
including compatibility aliases. To achieve this, the AST visitor has
been updated to map compatibility aliases to their underlying
Objective-C class.

`isSameOrDerivedFrom` also provides similar behaviors for C++ and
Objective-C classes. The behavior that
`cxxRecordDecl(isSameOrDerivedFrom("X"))` does not match
`class Y {}; typedef Y X;` is mirrored for Objective-C in that
`objcInterfaceDecl(isSameOrDerivedFrom("X"))` does not match either
`@interface Y @end typedef Y X;` or
`@interface Y @end @compatibility_alias X Y;`.

Test Notes:
Ran clang unit tests.

Reviewers: aaron.ballman, jordan_rose, rjmccall, klimek, alexfh, gribozavr

Reviewed By: aaron.ballman, gribozavr

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368632 91177308-0d34-0410-b5e6-96231b3b80d8
docs/LibASTMatchersReference.html
include/clang/ASTMatchers/ASTMatchers.h
include/clang/ASTMatchers/ASTMatchersInternal.h
lib/ASTMatchers/ASTMatchFinder.cpp
unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
unittests/ASTMatchers/Dynamic/RegistryTest.cpp