Author: wizard
Date: Wed Mar  7 10:59:25 2018
New Revision: 326928

URL: http://llvm.org/viewvc/llvm-project?rev=326928&view=rev
Log:
do not register matcher for objc-only checks when analyzing non-objc 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

Modified:
    
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
    clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
    clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
    clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp?rev=326928&r1=326927&r2=326928&view=diff
==============================================================================
--- 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp 
Wed Mar  7 10:59:25 2018
@@ -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:"),

Modified: clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp?rev=326928&r1=326927&r2=326928&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidNSErrorInitCheck.cpp Wed Mar  
7 10:59:25 2018
@@ -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"),

Modified: clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp?rev=326928&r1=326927&r2=326928&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/objc/ForbiddenSubclassingCheck.cpp Wed 
Mar  7 10:59:25 2018
@@ -77,6 +77,10 @@ ForbiddenSubclassingCheck::ForbiddenSubc
 }
 
 void ForbiddenSubclassingCheck::registerMatchers(MatchFinder *Finder) {
+  // this check should only be applied to ObjC sources.
+  if (!getLangOpts().ObjC1 && !getLangOpts().ObjC2) {
+    return;
+  }
   Finder->addMatcher(
       objcInterfaceDecl(
           isSubclassOf(

Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=326928&r1=326927&r2=326928&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Wed 
Mar  7 10:59:25 2018
@@ -170,6 +170,10 @@ PropertyDeclarationCheck::PropertyDeclar
       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());


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to