This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Handle bitfields in modernize-use-default-member-init if using C++2a
ClosedPublic

Authored by malcolm.parsons on Jan 23 2018, 3:39 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

aaron.ballman added inline comments.Jan 23 2018, 6:04 AM
clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
165 ↗(On Diff #131032)

I wonder if we could add a nothing() matcher (sibling to the anything() matcher) so that this could be rewritten as:

unless(anyOf(getLangOpts().CPlusPlus2a ? nothing() : isBitField()))

The duplication here adds complexity if we decide to change the matchers in the future.

test/clang-tidy/modernize-use-default-member-init-bitfield.cpp
1 ↗(On Diff #131032)

I'd like to see a test where C++2a is not enabled to ensure that the fix is not suggested in that case.

Use ternary operator.

clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
165 ↗(On Diff #131032)

unless(anything()) is equivalent to nothing().

test/clang-tidy/modernize-use-default-member-init-bitfield.cpp
1 ↗(On Diff #131032)
aaron.ballman accepted this revision.Jan 23 2018, 7:30 AM

LGTM!

clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
165 ↗(On Diff #131032)

Ah, good point! Nice, this is much more clean.

This revision is now accepted and ready to land.Jan 23 2018, 7:30 AM
This revision was automatically updated to reflect the committed changes.