@@ -149,6 +149,9 @@ After choosing the module and the name for the check, run the
149
149
``clang-tidy/add_new_check.py `` script to create the skeleton of the check and
150
150
plug it to :program: `clang-tidy `. It's the recommended way of adding new checks.
151
151
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
+
152
155
If we want to create a `readability-awesome-function-names `, we would run:
153
156
154
157
.. code-block :: console
@@ -171,9 +174,7 @@ Let's see in more detail at the check class definition:
171
174
172
175
#include "../ClangTidyCheck.h"
173
176
174
- namespace clang {
175
- namespace tidy {
176
- namespace readability {
177
+ namespace clang::tidy: :readability {
177
178
178
179
...
179
180
class AwesomeFunctionNamesCheck : public ClangTidyCheck {
@@ -182,11 +183,12 @@ Let's see in more detail at the check class definition:
182
183
: ClangTidyCheck(Name, Context) {}
183
184
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
184
185
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
186
+ bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
187
+ return LangOpts.CPlusPlus;
188
+ }
185
189
};
186
190
187
- } // namespace readability
188
- } // namespace tidy
189
- } // namespace clang
191
+ } // namespace clang::tidy: :readability
190
192
191
193
...
192
194
@@ -231,9 +233,6 @@ override the method ``registerPPCallbacks``. The ``add_new_check.py`` script
231
233
does not generate an override for this method in the starting point for your
232
234
new check.
233
235
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
-
237
236
Check development tips
238
237
----------------------
239
238
0 commit comments