[clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
Reviewers: alexfh Reviewed By: alexfh Subscribers: xazax.hun, malcolm.parsons, JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D30639 llvm-svn: 297009
This commit is contained in:
@@ -39,6 +39,7 @@ AST_MATCHER(Type, sugaredNullptrType) {
|
||||
StatementMatcher makeCastSequenceMatcher() {
|
||||
StatementMatcher ImplicitCastToNull = implicitCastExpr(
|
||||
anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)),
|
||||
unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType()))),
|
||||
unless(hasSourceExpression(hasType(sugaredNullptrType()))));
|
||||
|
||||
return castExpr(anyOf(ImplicitCastToNull,
|
||||
|
||||
@@ -244,3 +244,20 @@ void f() {
|
||||
bool a;
|
||||
a = ZZ(Hash());
|
||||
}
|
||||
|
||||
// Test on ignoring substituted template types.
|
||||
template<typename T>
|
||||
class TemplateClass {
|
||||
public:
|
||||
explicit TemplateClass(int a, T default_value = 0) {}
|
||||
|
||||
void h(T *default_value = 0) {}
|
||||
|
||||
void f(int* p = 0) {}
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
|
||||
// CHECK-FIXES: void f(int* p = nullptr) {}
|
||||
};
|
||||
|
||||
void IgnoreSubstTemplateType() {
|
||||
TemplateClass<int*> a(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user