Skip to content

Commit dd3c4fb

Browse files
authored
[clang-tidy][doc] Contributing.rst update snippet and docs (#129209)
This reflects the add_new_check.py changes: isLanguageVersionSupported is now overridden by default by the script The changes were instroduced in #100129 Thanks
1 parent fcc571e commit dd3c4fb

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

clang-tools-extra/docs/clang-tidy/Contributing.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ After choosing the module and the name for the check, run the
149149
``clang-tidy/add_new_check.py`` script to create the skeleton of the check and
150150
plug it to :program:`clang-tidy`. It's the recommended way of adding new checks.
151151

152+
By default, the new check will apply only to C++ code. If it should apply under
153+
different language options, use the ``--language`` script's parameter.
154+
152155
If we want to create a `readability-awesome-function-names`, we would run:
153156

154157
.. code-block:: console
@@ -171,9 +174,7 @@ Let's see in more detail at the check class definition:
171174

172175
#include "../ClangTidyCheck.h"
173176

174-
namespace clang {
175-
namespace tidy {
176-
namespace readability {
177+
namespace clang::tidy::readability {
177178

178179
...
179180
class AwesomeFunctionNamesCheck : public ClangTidyCheck {
@@ -182,11 +183,12 @@ Let's see in more detail at the check class definition:
182183
: ClangTidyCheck(Name, Context) {}
183184
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
184185
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
186+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
187+
return LangOpts.CPlusPlus;
188+
}
185189
};
186190
187-
} // namespace readability
188-
} // namespace tidy
189-
} // namespace clang
191+
} // namespace clang::tidy::readability
190192

191193
...
192194

@@ -231,9 +233,6 @@ override the method ``registerPPCallbacks``. The ``add_new_check.py`` script
231233
does not generate an override for this method in the starting point for your
232234
new check.
233235

234-
If your check applies only under a specific set of language options, be sure
235-
to override the method ``isLanguageVersionSupported`` to reflect that.
236-
237236
Check development tips
238237
----------------------
239238

0 commit comments

Comments
 (0)