Skip to content

[clang-tidy] Contributing.rst update snippet and docs #129209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions clang-tools-extra/docs/clang-tidy/Contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ After choosing the module and the name for the check, run the
``clang-tidy/add_new_check.py`` script to create the skeleton of the check and
plug it to :program:`clang-tidy`. It's the recommended way of adding new checks.

By default, the new check will apply only to C++ code. If it should apply under
different language options, use the ``--language`` script's parameter.

If we want to create a `readability-awesome-function-names`, we would run:

.. code-block:: console
Expand All @@ -171,9 +174,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 {
Expand All @@ -182,11 +183,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

...

Expand Down Expand Up @@ -231,9 +233,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
----------------------

Expand Down