[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
hokein added inline comments. Comment at: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp:254 + + void h(T *default_value = 0) {} + alexfh wrote: > xazax.hun wrote: > > Maybe as a separate patch, but I think it might be worth to warn here. > > WDYT? (Sorry for the double post, the previous one is disappeared after the > > commit.) > Seems reasonable, but probably not an extremely frequent case. Deserves a > FIXME at least. +1, patch are welcome. Repository: rL LLVM https://reviews.llvm.org/D30639 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
alexfh added inline comments. Comment at: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp:254 + + void h(T *default_value = 0) {} + xazax.hun wrote: > Maybe as a separate patch, but I think it might be worth to warn here. WDYT? > (Sorry for the double post, the previous one is disappeared after the commit.) Seems reasonable, but probably not an extremely frequent case. Deserves a FIXME at least. Repository: rL LLVM https://reviews.llvm.org/D30639 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
xazax.hun added inline comments. Comment at: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp:254 + + void h(T *default_value = 0) {} + Maybe as a separate patch, but I think it might be worth to warn here. WDYT? (Sorry for the double post, the previous one is disappeared after the commit.) Repository: rL LLVM https://reviews.llvm.org/D30639 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
This revision was automatically updated to reflect the committed changes. Closed by commit rL297009: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check. (authored by hokein). Changed prior to commit: https://reviews.llvm.org/D30639?vs=90691=90694#toc Repository: rL LLVM https://reviews.llvm.org/D30639 Files: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp === --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp @@ -244,3 +244,20 @@ bool a; a = ZZ(Hash()); } + +// Test on ignoring substituted template types. +template +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() { + TemplateClassa(1); +} Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp @@ -39,6 +39,7 @@ StatementMatcher makeCastSequenceMatcher() { StatementMatcher ImplicitCastToNull = implicitCastExpr( anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)), + unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(, unless(hasSourceExpression(hasType(sugaredNullptrType(); return castExpr(anyOf(ImplicitCastToNull, Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp === --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp @@ -244,3 +244,20 @@ bool a; a = ZZ(Hash()); } + +// Test on ignoring substituted template types. +template +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 a(1); +} Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp @@ -39,6 +39,7 @@ StatementMatcher makeCastSequenceMatcher() { StatementMatcher ImplicitCastToNull = implicitCastExpr( anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)), + unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(, unless(hasSourceExpression(hasType(sugaredNullptrType(); return castExpr(anyOf(ImplicitCastToNull, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
xazax.hun added inline comments. Comment at: test/clang-tidy/modernize-use-nullptr.cpp:254 + + void h(T *default_value = 0) {} + Great! Thanks for adding this test. I have the impression we do want to warn and fix this case however. What do you think? https://reviews.llvm.org/D30639 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
hokein added inline comments. Comment at: test/clang-tidy/modernize-use-nullptr.cpp:252 + public: + explicit TemplateClass(int a, T default_value = 0) {} +}; xazax.hun wrote: > It might be great to have a test case for: > > ``` > > template > class TemplateClass { > public: > explicit TemplateClass(int a, T *default_value = 0) {} > ``` Good catch. Done. https://reviews.llvm.org/D30639 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
hokein updated this revision to Diff 90691. hokein marked an inline comment as done. hokein added a comment. Add more tests. https://reviews.llvm.org/D30639 Files: clang-tidy/modernize/UseNullptrCheck.cpp test/clang-tidy/modernize-use-nullptr.cpp Index: test/clang-tidy/modernize-use-nullptr.cpp === --- test/clang-tidy/modernize-use-nullptr.cpp +++ test/clang-tidy/modernize-use-nullptr.cpp @@ -244,3 +244,20 @@ bool a; a = ZZ(Hash()); } + +// Test on ignoring substituted template types. +template +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() { + TemplateClassa(1); +} Index: clang-tidy/modernize/UseNullptrCheck.cpp === --- clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tidy/modernize/UseNullptrCheck.cpp @@ -39,6 +39,7 @@ StatementMatcher makeCastSequenceMatcher() { StatementMatcher ImplicitCastToNull = implicitCastExpr( anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)), + unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(, unless(hasSourceExpression(hasType(sugaredNullptrType(); return castExpr(anyOf(ImplicitCastToNull, Index: test/clang-tidy/modernize-use-nullptr.cpp === --- test/clang-tidy/modernize-use-nullptr.cpp +++ test/clang-tidy/modernize-use-nullptr.cpp @@ -244,3 +244,20 @@ bool a; a = ZZ(Hash()); } + +// Test on ignoring substituted template types. +template +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 a(1); +} Index: clang-tidy/modernize/UseNullptrCheck.cpp === --- clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tidy/modernize/UseNullptrCheck.cpp @@ -39,6 +39,7 @@ StatementMatcher makeCastSequenceMatcher() { StatementMatcher ImplicitCastToNull = implicitCastExpr( anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)), + unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(, unless(hasSourceExpression(hasType(sugaredNullptrType(); return castExpr(anyOf(ImplicitCastToNull, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. LG https://reviews.llvm.org/D30639 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
xazax.hun added inline comments. Comment at: test/clang-tidy/modernize-use-nullptr.cpp:252 + public: + explicit TemplateClass(int a, T default_value = 0) {} +}; It might be great to have a test case for: ``` template class TemplateClass { public: explicit TemplateClass(int a, T *default_value = 0) {} ``` https://reviews.llvm.org/D30639 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
hokein updated this revision to Diff 90677. hokein marked an inline comment as done. hokein added a comment. typo: vale => value. https://reviews.llvm.org/D30639 Files: clang-tidy/modernize/UseNullptrCheck.cpp test/clang-tidy/modernize-use-nullptr.cpp Index: test/clang-tidy/modernize-use-nullptr.cpp === --- test/clang-tidy/modernize-use-nullptr.cpp +++ test/clang-tidy/modernize-use-nullptr.cpp @@ -244,3 +244,14 @@ bool a; a = ZZ(Hash()); } + +// Test on ignoring substituted template types. +template +class TemplateClass { + public: + explicit TemplateClass(int a, T default_value = 0) {} +}; + +void IgnoreSubstTemplateType() { + TemplateClassa(1); +} Index: clang-tidy/modernize/UseNullptrCheck.cpp === --- clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tidy/modernize/UseNullptrCheck.cpp @@ -39,6 +39,7 @@ StatementMatcher makeCastSequenceMatcher() { StatementMatcher ImplicitCastToNull = implicitCastExpr( anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)), + unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(, unless(hasSourceExpression(hasType(sugaredNullptrType(); return castExpr(anyOf(ImplicitCastToNull, Index: test/clang-tidy/modernize-use-nullptr.cpp === --- test/clang-tidy/modernize-use-nullptr.cpp +++ test/clang-tidy/modernize-use-nullptr.cpp @@ -244,3 +244,14 @@ bool a; a = ZZ(Hash()); } + +// Test on ignoring substituted template types. +template +class TemplateClass { + public: + explicit TemplateClass(int a, T default_value = 0) {} +}; + +void IgnoreSubstTemplateType() { + TemplateClass a(1); +} Index: clang-tidy/modernize/UseNullptrCheck.cpp === --- clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tidy/modernize/UseNullptrCheck.cpp @@ -39,6 +39,7 @@ StatementMatcher makeCastSequenceMatcher() { StatementMatcher ImplicitCastToNull = implicitCastExpr( anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)), + unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(, unless(hasSourceExpression(hasType(sugaredNullptrType(); return castExpr(anyOf(ImplicitCastToNull, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
malcolm.parsons added inline comments. Comment at: test/clang-tidy/modernize-use-nullptr.cpp:252 + public: + explicit TemplateClass(int a, T default_vale = 0) {} +}; vale -> value https://reviews.llvm.org/D30639 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
hokein created this revision. Herald added a subscriber: JDevlieghere. https://reviews.llvm.org/D30639 Files: clang-tidy/modernize/UseNullptrCheck.cpp test/clang-tidy/modernize-use-nullptr.cpp Index: test/clang-tidy/modernize-use-nullptr.cpp === --- test/clang-tidy/modernize-use-nullptr.cpp +++ test/clang-tidy/modernize-use-nullptr.cpp @@ -244,3 +244,14 @@ bool a; a = ZZ(Hash()); } + +// Test on ignoring substituted template types. +template +class TemplateClass { + public: + explicit TemplateClass(int a, T default_vale = 0) {} +}; + +void IgnoreSubstTemplateType() { + TemplateClassa(1); +} Index: clang-tidy/modernize/UseNullptrCheck.cpp === --- clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tidy/modernize/UseNullptrCheck.cpp @@ -39,6 +39,7 @@ StatementMatcher makeCastSequenceMatcher() { StatementMatcher ImplicitCastToNull = implicitCastExpr( anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)), + unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(, unless(hasSourceExpression(hasType(sugaredNullptrType(); return castExpr(anyOf(ImplicitCastToNull, Index: test/clang-tidy/modernize-use-nullptr.cpp === --- test/clang-tidy/modernize-use-nullptr.cpp +++ test/clang-tidy/modernize-use-nullptr.cpp @@ -244,3 +244,14 @@ bool a; a = ZZ(Hash()); } + +// Test on ignoring substituted template types. +template +class TemplateClass { + public: + explicit TemplateClass(int a, T default_vale = 0) {} +}; + +void IgnoreSubstTemplateType() { + TemplateClass a(1); +} Index: clang-tidy/modernize/UseNullptrCheck.cpp === --- clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tidy/modernize/UseNullptrCheck.cpp @@ -39,6 +39,7 @@ StatementMatcher makeCastSequenceMatcher() { StatementMatcher ImplicitCastToNull = implicitCastExpr( anyOf(hasCastKind(CK_NullToPointer), hasCastKind(CK_NullToMemberPointer)), + unless(hasImplicitDestinationType(qualType(substTemplateTypeParmType(, unless(hasSourceExpression(hasType(sugaredNullptrType(); return castExpr(anyOf(ImplicitCastToNull, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits