[PATCH] D30639: [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 6 03:38:23 PST 2017
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<typename T>
+class TemplateClass {
+ public:
+ explicit TemplateClass(int a, T default_vale = 0) {}
+};
+
+void IgnoreSubstTemplateType() {
+ TemplateClass<int*> 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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30639.90670.patch
Type: text/x-patch
Size: 1105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170306/ef3d2bf0/attachment.bin>
More information about the cfe-commits
mailing list