[clang-tools-extra] r287221 - [clang-tidy] Ignore template instantiations in modernize-use-equals-delete check

Malcolm Parsons via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 17 03:40:02 PST 2016


Author: malcolm.parsons
Date: Thu Nov 17 05:40:02 2016
New Revision: 287221

URL: http://llvm.org/viewvc/llvm-project?rev=287221&view=rev
Log:
[clang-tidy] Ignore template instantiations in modernize-use-equals-delete check

Summary: Template instantiations were causing misplaced fixits.

Reviewers: aaron.ballman, alexfh, hokein

Subscribers: hokein, cfe-commits

Differential Revision: https://reviews.llvm.org/D26751

Modified:
    clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
    clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp?rev=287221&r1=287220&r2=287221&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp Thu Nov 17 05:40:02 2016
@@ -34,6 +34,7 @@ void UseEqualsDeleteCheck::registerMatch
       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(

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp?rev=287221&r1=287220&r2=287221&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp Thu Nov 17 05:40:02 2016
@@ -22,6 +22,32 @@ private:
   // 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 &);
 };




More information about the cfe-commits mailing list