[clang-tools-extra] [clang-tidy] Contributing.rst update snippet and docs (PR #129209)

via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 28 00:46:27 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: Marco C. (Marcondiro)

<details>
<summary>Changes</summary>

This reflects the add_new_check.py changes: isLanguageVersionSupported is now overridden by default by the script

The changes were instroduced in https://github.com/llvm/llvm-project/pull/100129

Thanks

---
Full diff: https://github.com/llvm/llvm-project/pull/129209.diff


1 Files Affected:

- (modified) clang-tools-extra/docs/clang-tidy/Contributing.rst (+9-9) 


``````````diff
diff --git a/clang-tools-extra/docs/clang-tidy/Contributing.rst b/clang-tools-extra/docs/clang-tidy/Contributing.rst
index 4f1df8d114444..ed28df0e9887a 100644
--- a/clang-tools-extra/docs/clang-tidy/Contributing.rst
+++ b/clang-tools-extra/docs/clang-tidy/Contributing.rst
@@ -171,9 +171,7 @@ Let's see in more detail at the check class definition:
 
   #include "../ClangTidyCheck.h"
 
-  namespace clang {
-  namespace tidy {
-  namespace readability {
+  namespace clang::tidy::readability {
 
   ...
   class AwesomeFunctionNamesCheck : public ClangTidyCheck {
@@ -182,11 +180,12 @@ Let's see in more detail at the check class definition:
         : ClangTidyCheck(Name, Context) {}
     void registerMatchers(ast_matchers::MatchFinder *Finder) override;
     void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+    bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+      return LangOpts.CPlusPlus;
+    }
   };
 
-  } // namespace readability
-  } // namespace tidy
-  } // namespace clang
+  } // namespace clang::tidy::readability
 
   ...
 
@@ -203,6 +202,10 @@ for more information) that will find the pattern in the AST that we want to
 inspect. The results of the matching are passed to the ``check`` method, which
 can further inspect them and report diagnostics.
 
+By default, the new check applies only to C++ code. If it should apply under 
+different language options, be sure to update the ``isLanguageVersionSupported``
+method accordingly.
+
 .. code-block:: c++
 
   using namespace ast_matchers;
@@ -231,9 +234,6 @@ override the method ``registerPPCallbacks``.  The ``add_new_check.py`` script
 does not generate an override for this method in the starting point for your
 new check.
 
-If your check applies only under a specific set of language options, be sure
-to override the method ``isLanguageVersionSupported`` to reflect that.
-
 Check development tips
 ----------------------
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/129209


More information about the cfe-commits mailing list