[clang-tools-extra] Extend support for specifying languages and version in add_new_check.py (PR #100129)

Marco C. via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 26 08:10:50 PST 2025


Marcondiro wrote:

Hello @njames93,
After this PR, the class derived from `ClangTidyCheck` created by the script `add_new_check.py` overrides `isLanguageVersionSupported` by default, restricting the check's scope to `LangOpts.CPlusPlus` code.

Running `clang-tidy/add_new_check.py readability awesome-function-names` generates:
```c++
// clang-tools-extra/clang-tidy/readability/AwesomeFunctionNamesCheck.h
class AwesomeFunctionNamesCheck : public ClangTidyCheck {
public:
  [...]
  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
    return LangOpts.CPlusPlus;
  }
};
```

Is this behavior expected?
If so, [`clang-tools-extra/docs/clang-tidy/Contributing.rst`](https://clang.llvm.org/extra/clang-tidy/Contributing.html) could be updated accordingly. (It definitely didn't take me a while to figure out why my check wasn't working on C code :smile: )

Thank you!

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


More information about the cfe-commits mailing list