[PATCH] D26582: [clang-tidy] Handle template instantiations in modenize-use-default check
Malcolm Parsons via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 12 13:46:39 PST 2016
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, alexfh.
malcolm.parsons added a subscriber: cfe-commits.
Duplicate fixes were being created for explicit template instantiations
of out-of-line constructors or destructors.
Fixes PR30921.
https://reviews.llvm.org/D26582
Files:
clang-tidy/modernize/UseDefaultCheck.cpp
test/clang-tidy/modernize-use-default.cpp
Index: test/clang-tidy/modernize-use-default.cpp
===================================================================
--- test/clang-tidy/modernize-use-default.cpp
+++ test/clang-tidy/modernize-use-default.cpp
@@ -124,6 +124,26 @@
// CHECK-FIXES: ~Temp() = default;
};
+// Class template out of line with explicit instantiation.
+template <class T>
+class TempODef {
+public:
+ TempODef();
+ ~TempODef();
+};
+
+template <class T>
+TempODef<T>::TempODef() {}
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default'
+// CHECK-FIXES: TempODef<T>::TempODef() = default;
+template <class T>
+TempODef<T>::~TempODef() {}
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default'
+// CHECK-FIXES: TempODef<T>::~TempODef() = default;
+
+template class TempODef<int>;
+template class TempODef<double>;
+
// Non user-provided constructor/destructor.
struct Imp {
int Int;
Index: clang-tidy/modernize/UseDefaultCheck.cpp
===================================================================
--- clang-tidy/modernize/UseDefaultCheck.cpp
+++ clang-tidy/modernize/UseDefaultCheck.cpp
@@ -241,6 +241,7 @@
if (SpecialFunctionDecl->isDeleted() ||
SpecialFunctionDecl->isExplicitlyDefaulted() ||
SpecialFunctionDecl->isLateTemplateParsed() ||
+ SpecialFunctionDecl->isTemplateInstantiation() ||
!SpecialFunctionDecl->isUserProvided() || !SpecialFunctionDecl->hasBody())
return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26582.77728.patch
Type: text/x-patch
Size: 1415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161112/7224952a/attachment.bin>
More information about the cfe-commits
mailing list