[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 04:24:39 PST 2017
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<typename T>
+class TemplateClass {
+ public:
+ explicit TemplateClass(int a, T default_value = 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.90677.patch
Type: text/x-patch
Size: 1106 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170306/a9bc01c0/attachment.bin>
More information about the cfe-commits
mailing list