[PATCH] D42413: [clang-tidy] Handle bitfields in modernize-use-default-member-init if using C++2a
Malcolm Parsons via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 23 07:36:10 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323208: [clang-tidy] Handle bitfields in modernize-use-default-member-init if using… (authored by malcolm.parsons, committed by ).
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
https://reviews.llvm.org/D42413
Files:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -167,7 +167,9 @@
isDefaultConstructor(), unless(isInstantiated()),
forEachConstructorInitializer(
cxxCtorInitializer(
- forField(unless(anyOf(isBitField(),
+ forField(unless(anyOf(getLangOpts().CPlusPlus2a
+ ? unless(anything())
+ : isBitField(),
hasInClassInitializer(anything()),
hasParent(recordDecl(isUnion()))))),
isWritten(), withInitializer(ignoringImplicit(Init)))
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- -- -std=c++2a
+
+struct PositiveBitField
+{
+ PositiveBitField() : i(6) {}
+ // CHECK-FIXES: PositiveBitField() {}
+ int i : 5;
+ // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'i' [modernize-use-default-member-init]
+ // CHECK-FIXES: int i : 5{6};
+};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42413.131072.patch
Type: text/x-patch
Size: 1664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180123/e0f46afe/attachment.bin>
More information about the llvm-commits
mailing list