[clang-tools-extra] Limit modernize-use-nullptr to C++11/C23 and later (PR #132816)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 24 12:18:21 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tidy
Author: None (higher-performance)
<details>
<summary>Changes</summary>
`nullptr` is not supported on earlier versions of either standard, so the tidy should not diagnose earlier uses.
---
Full diff: https://github.com/llvm/llvm-project/pull/132816.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp (+4-1)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
index 108717e151b57..771ea3875a71a 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -505,7 +505,10 @@ void UseNullptrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
}
void UseNullptrCheck::registerMatchers(MatchFinder *Finder) {
- Finder->addMatcher(makeCastSequenceMatcher(IgnoredTypes), this);
+ // nullptr is supported starting from C++11 and C23.
+ if (getLangOpts().CPlusPlus11 || getLangOpts().C23) {
+ Finder->addMatcher(makeCastSequenceMatcher(IgnoredTypes), this);
+ }
}
void UseNullptrCheck::check(const MatchFinder::MatchResult &Result) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/132816
More information about the cfe-commits
mailing list