Skip to content

Commit

Permalink
do not register matcher for objc-only checks when analyzing non-objc …
Browse files Browse the repository at this point in the history
…sources to save resources

Summary: I did not put lang opt check in AvoidSpinlockCheck since OSSpinLock is not objc specific. We won't want to skip it when analyzing some C++ target used by other ObjC sources.

Reviewers: hokein, benhamilton

Reviewed By: benhamilton

Subscribers: klimek, cfe-commits

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

llvm-svn: 326928
  • Loading branch information
ynzhang0509 committed Mar 7, 2018
1 parent aac28f3 commit c7faee7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
Expand Up @@ -19,6 +19,11 @@ namespace google {
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:"),
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
Expand Up @@ -18,6 +18,10 @@ namespace tidy {
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"),
Expand Down
Expand Up @@ -77,6 +77,10 @@ ForbiddenSubclassingCheck::ForbiddenSubclassingCheck(
}

void ForbiddenSubclassingCheck::registerMatchers(MatchFinder *Finder) {
// this check should only be applied to ObjC sources.
if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
return;
}
Finder->addMatcher(
objcInterfaceDecl(
isSubclassOf(
Expand Down
Expand Up @@ -170,6 +170,10 @@ PropertyDeclarationCheck::PropertyDeclarationCheck(StringRef Name,
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());
Expand Down

0 comments on commit c7faee7

Please sign in to comment.