[PATCH] D28287: [clang-tidy] Ignore default arguments in modernize-default-member-init
Malcolm Parsons via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 4 07:48:27 PST 2017
malcolm.parsons updated this revision to Diff 83056.
malcolm.parsons added a comment.
Only match DeclRefExprs to EnumConstantDecls.
https://reviews.llvm.org/D28287
Files:
clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
test/clang-tidy/modernize-use-default-member-init.cpp
Index: test/clang-tidy/modernize-use-default-member-init.cpp
===================================================================
--- test/clang-tidy/modernize-use-default-member-init.cpp
+++ test/clang-tidy/modernize-use-default-member-init.cpp
@@ -221,6 +221,12 @@
int i;
};
+struct NegativeDefaultArg
+{
+ NegativeDefaultArg(int i = 4) : i(i) {}
+ int i;
+};
+
struct ExistingChar {
ExistingChar(short) : e1(), e2(), e3(), e4() {}
// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
Index: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===================================================================
--- clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -158,7 +158,7 @@
unaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")),
hasUnaryOperand(floatLiteral())),
cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
- declRefExpr());
+ declRefExpr(to(enumConstantDecl())));
Finder->addMatcher(
cxxConstructorDecl(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28287.83056.patch
Type: text/x-patch
Size: 1178 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170104/85a36fbc/attachment.bin>
More information about the cfe-commits
mailing list