[PATCH] D49356: [clang-tidy: modernize] Fix modernize-use-equals-default with {} brackets list initialization: patch

Idriss via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 15 15:56:28 PDT 2018


IdrissRio created this revision.
IdrissRio added reviewers: aaron.ballman, hokein, alexfh.
Herald added a subscriber: cfe-commits.

Hello, i would like to suggest a fix for one of the checks in clang-tidy. The bug was reported in https://bugs.llvm.org/show_bug.cgi?id=38039 where you can find more information


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49356

Files:
  clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  test/clang-tidy/modernize-use-equals-default-copy.cpp


Index: test/clang-tidy/modernize-use-equals-default-copy.cpp
===================================================================
--- test/clang-tidy/modernize-use-equals-default-copy.cpp
+++ test/clang-tidy/modernize-use-equals-default-copy.cpp
@@ -497,3 +497,11 @@
 STRUCT_WITH_COPY_ASSIGN(unsigned char, Hex8CopyAssign)
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy-assignment operator
 // CHECK-MESSAGES: :[[@LINE-9]]:40: note:
+
+// Use of braces
+struct UOB{
+  UOB(const UOB &Other):j{Other.j}{}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default]
+  // CHECK-FIXES: UOB(const UOB &Other)= default;
+  int j;
+};
Index: clang-tidy/modernize/UseEqualsDefaultCheck.cpp
===================================================================
--- clang-tidy/modernize/UseEqualsDefaultCheck.cpp
+++ clang-tidy/modernize/UseEqualsDefaultCheck.cpp
@@ -97,6 +97,7 @@
                 isMemberInitializer(), forField(equalsNode(Field)),
                 withInitializer(anyOf(
                     AccessToFieldInParam,
+					initListExpr(has(AccessToFieldInParam)),
                     cxxConstructExpr(allOf(
                         hasDeclaration(cxxConstructorDecl(isCopyConstructor())),
                         argumentCountIs(1),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49356.155600.patch
Type: text/x-patch
Size: 1351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180715/30228134/attachment.bin>


More information about the cfe-commits mailing list