[PATCH] D44174: do not register matcher for objc-only checks when analyzing non-objc sources to save resources
Yan Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 6 13:55:15 PST 2018
Wizard created this revision.
Herald added subscribers: cfe-commits, klimek.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D44174
Files:
clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
clang-tidy/objc/AvoidNSErrorInitCheck.cpp
clang-tidy/objc/ForbiddenSubclassingCheck.cpp
clang-tidy/objc/PropertyDeclarationCheck.cpp
Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===================================================================
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -170,6 +170,10 @@
EscapedAcronyms() {}
void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) {
+ // this check should only be applied to ObjC sources.
+ if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+ return;
+ }
if (IncludeDefaultAcronyms) {
EscapedAcronyms.reserve(llvm::array_lengthof(DefaultSpecialAcronyms) +
SpecialAcronyms.size());
Index: clang-tidy/objc/ForbiddenSubclassingCheck.cpp
===================================================================
--- clang-tidy/objc/ForbiddenSubclassingCheck.cpp
+++ clang-tidy/objc/ForbiddenSubclassingCheck.cpp
@@ -77,6 +77,10 @@
}
void ForbiddenSubclassingCheck::registerMatchers(MatchFinder *Finder) {
+ // this check should only be applied to ObjC sources.
+ if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+ return;
+ }
Finder->addMatcher(
objcInterfaceDecl(
isSubclassOf(
Index: clang-tidy/objc/AvoidNSErrorInitCheck.cpp
===================================================================
--- clang-tidy/objc/AvoidNSErrorInitCheck.cpp
+++ clang-tidy/objc/AvoidNSErrorInitCheck.cpp
@@ -18,6 +18,10 @@
namespace objc {
void AvoidNSErrorInitCheck::registerMatchers(MatchFinder *Finder) {
+ // this check should only be applied to ObjC sources.
+ if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+ return;
+ }
Finder->addMatcher(objcMessageExpr(hasSelector("init"),
hasReceiverType(asString("NSError *")))
.bind("nserrorInit"),
Index: clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
===================================================================
--- clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
+++ clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
@@ -19,6 +19,11 @@
namespace objc {
void AvoidThrowingObjCExceptionCheck::registerMatchers(MatchFinder *Finder) {
+ // this check should only be applied to ObjC sources.
+ if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+ return;
+ }
+
Finder->addMatcher(objcThrowStmt().bind("throwStmt"), this);
Finder->addMatcher(
objcMessageExpr(anyOf(hasSelector("raise:format:"),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44174.137267.patch
Type: text/x-patch
Size: 2429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180306/5ebf580b/attachment-0001.bin>
More information about the cfe-commits
mailing list