[PATCH] D114995: clang-tidy: improve the 'modernize-use-default-member-init'
Oleg Smolsky via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 2 14:46:18 PST 2021
oleg.smolsky updated this revision to Diff 391470.
oleg.smolsky added a comment.
Fixing the uploaded diff...
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114995/new/
https://reviews.llvm.org/D114995
Files:
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -45,6 +45,38 @@
// CHECK-FIXES: int j{1};
};
+struct PositiveNotDefaultInt
+{
+ PositiveNotDefaultInt(int) : i(7) {}
+ // CHECK-FIXES: PositiveNotDefaultInt(int) {}
+ int i;
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'i'
+ // CHECK-FIXES: int i{7};
+};
+
+struct PositiveNotDefaultOOLInt
+{
+ PositiveNotDefaultOOLInt(int);
+ int i;
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'i'
+ // CHECK-FIXES: int i{7};
+};
+
+PositiveNotDefaultOOLInt::PositiveNotDefaultOOLInt(int) : i(7) {}
+// CHECK-FIXES: PositiveNotDefaultOOLInt::PositiveNotDefaultOOLInt(int) {}
+
+struct PositiveNotDefaultOOLInt2
+{
+ PositiveNotDefaultOOLInt2(int, int);
+ int i;
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'i'
+ // CHECK-FIXES: int i{7};
+ int j;
+};
+
+PositiveNotDefaultOOLInt2::PositiveNotDefaultOOLInt2(int, int arg) : i(7), j(arg) {}
+// CHECK-FIXES: PositiveNotDefaultOOLInt2::PositiveNotDefaultOOLInt2(int, int arg) : j(arg) {}
+
struct PositiveUnaryMinusInt {
PositiveUnaryMinusInt() : j(-1) {}
// CHECK-FIXES: PositiveUnaryMinusInt() {}
@@ -234,12 +266,6 @@
int i : 5;
};
-struct NegativeNotDefaultInt
-{
- NegativeNotDefaultInt(int) : i(7) {}
- int i;
-};
-
struct NegativeDefaultArg
{
NegativeDefaultArg(int i = 4) : i(i) {}
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -213,7 +213,6 @@
Finder->addMatcher(
cxxConstructorDecl(
- isDefaultConstructor(),
forEachConstructorInitializer(
cxxCtorInitializer(
forField(unless(anyOf(getLangOpts().CPlusPlus20
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114995.391470.patch
Type: text/x-patch
Size: 2245 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211202/963547f7/attachment.bin>
More information about the cfe-commits
mailing list