[all-commits] [llvm/llvm-project] cebb7c: [clang-tidy] modernize-use-nullptr matches "NULL" ...
Thomas Köppe via All-commits
all-commits at lists.llvm.org
Wed Sep 25 09:26:07 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: cebb7c010854e39a77065cfd681db91a79e7ce15
https://github.com/llvm/llvm-project/commit/cebb7c010854e39a77065cfd681db91a79e7ce15
Author: Thomas Köppe <tkoeppe at google.com>
Date: 2024-09-25 (Wed, 25 Sep 2024)
Changed paths:
M clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
M clang-tools-extra/docs/ReleaseNotes.rst
M clang-tools-extra/test/clang-tidy/checkers/modernize/use-nullptr.cpp
Log Message:
-----------
[clang-tidy] modernize-use-nullptr matches "NULL" in templates (#109169)
Make modernize-use-nullptr matcher also match "NULL", but not "0", when
it appears on a substituted type of a template specialization.
Previously, any matches on a substituted type were excluded, but this
meant that a situation like the following is not diagnosed:
```c++
template <typename T>
struct X {
T val;
X() { val = NULL; } // should diagnose
};
```
When the user says `NULL`, we expect that the destination type is always
meant to be a pointer type, so this should be converted to `nullptr`. By
contrast, we do not propose changing a literal `0` in that case, which
appears as initializers of both pointer and integer specializations in
reasonable real code. (If `NULL` is used erroneously in such a
situation, it should be changed to `0` or `{}`.)
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list