[clang-tools-extra] [clang-tidy] modernize-use-nullptr matches "NULL" in templates (PR #109169)
Thomas Köppe via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 20 08:17:45 PDT 2024
================
@@ -38,7 +38,9 @@ AST_MATCHER(Type, sugaredNullptrType) {
StatementMatcher makeCastSequenceMatcher(llvm::ArrayRef<StringRef> NameList) {
auto ImplicitCastToNull = implicitCastExpr(
anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)),
- unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType()))),
+ anyOf(hasSourceExpression(gnuNullExpr()),
----------------
tkoeppe wrote:
How about:
```
/// TODO/NOTE: The second "anyOf" below discards matches on a substituted type,
/// since we don't know if that would _always_ be a pointer type for all other
/// specializations, unless the expression was "__null", in which case we assume
/// that all specializations are expected to be for pointer types. Ideally this
/// would check for the NULL macro instead, but that'd be harder to express. In
/// practice, NULL is often defined as __null, and this is a useful condition.
```
?
https://github.com/llvm/llvm-project/pull/109169
More information about the cfe-commits
mailing list