[PATCH] D26751: [clang-tidy] Ignore template instantiations in modernize-use-equals-delete check
Malcolm Parsons via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 16 09:22:47 PST 2016
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, alexfh.
malcolm.parsons added a subscriber: cfe-commits.
Template instantiations were causing misplaced fixits.
https://reviews.llvm.org/D26751
Files:
clang-tidy/modernize/UseEqualsDeleteCheck.cpp
test/clang-tidy/modernize-use-equals-delete.cpp
Index: test/clang-tidy/modernize-use-equals-delete.cpp
===================================================================
--- test/clang-tidy/modernize-use-equals-delete.cpp
+++ test/clang-tidy/modernize-use-equals-delete.cpp
@@ -22,6 +22,32 @@
// CHECK-FIXES: ~PositivePrivate() = delete;
};
+template<typename T>
+struct PositivePrivateTemplate {
+private:
+ PositivePrivateTemplate();
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+ // CHECK-FIXES: PositivePrivateTemplate() = delete;
+ PositivePrivateTemplate(const PositivePrivateTemplate &);
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+ // CHECK-FIXES: PositivePrivateTemplate(const PositivePrivateTemplate &) = delete;
+ PositivePrivateTemplate &operator=(const PositivePrivateTemplate &);
+ // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+ // CHECK-FIXES: PositivePrivateTemplate &operator=(const PositivePrivateTemplate &) = delete;
+ PositivePrivateTemplate(PositivePrivateTemplate &&);
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+ // CHECK-FIXES: PositivePrivateTemplate(PositivePrivateTemplate &&) = delete;
+ PositivePrivateTemplate &operator=(PositivePrivateTemplate &&);
+ // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+ // CHECK-FIXES: PositivePrivateTemplate &operator=(PositivePrivateTemplate &&) = delete;
+ ~PositivePrivateTemplate();
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+ // CHECK-FIXES: ~PositivePrivateTemplate() = delete;
+};
+
+template struct PositivePrivateTemplate<int>;
+template struct PositivePrivateTemplate<char>;
+
struct NegativePublic {
NegativePublic(const NegativePublic &);
};
Index: clang-tidy/modernize/UseEqualsDeleteCheck.cpp
===================================================================
--- clang-tidy/modernize/UseEqualsDeleteCheck.cpp
+++ clang-tidy/modernize/UseEqualsDeleteCheck.cpp
@@ -34,6 +34,7 @@
cxxMethodDecl(
PrivateSpecialFn,
unless(anyOf(hasBody(stmt()), isDefaulted(), isDeleted(),
+ ast_matchers::isTemplateInstantiation(),
// Ensure that all methods except private special member
// functions are defined.
hasParent(cxxRecordDecl(hasMethod(unless(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26751.78202.patch
Type: text/x-patch
Size: 2794 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161116/4eca0249/attachment.bin>
More information about the cfe-commits
mailing list