This is an archive of the discontinued LLVM Phabricator instance.

Fix a crash in cppcoreguidelines-pro-type-member-init when checking a class that initializes itself as a base
ClosedPublic

Authored by michael_miller on May 2 2016, 4:59 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

michael_miller retitled this revision from to Fix a crash in cppcoreguidelines-pro-type-member-init when checking a class that initializes itself as a base.
michael_miller updated this object.
michael_miller added a subscriber: cfe-commits.
aaron.ballman added inline comments.May 2 2016, 6:02 AM
test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
342 ↗(On Diff #55805)

Is it required to be a templated class to trigger the crash?

hokein accepted this revision.May 2 2016, 10:56 AM
hokein edited edge metadata.

LGTM. Thanks!

test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
342 ↗(On Diff #55805)

Yes, it's required.

This revision is now accepted and ready to land.May 2 2016, 10:56 AM
aaron.ballman accepted this revision.May 2 2016, 11:39 AM
aaron.ballman edited edge metadata.

LGTM with a commenting request.

test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
342 ↗(On Diff #55805)

Then some comments in this test would be good, I would assume otherwise from just looking at the test.

michael_miller added inline comments.May 2 2016, 3:31 PM
test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
342 ↗(On Diff #55805)

It's a little bit of a pathological example. Without the template, the code won't compile at all due to an error. The check doesn't crash in that case (error: constructor for 'PositiveSelfInitialization' creates a delegation cycle [clang-diagnostic-delegating-ctor-cycles]). With the template in the mix, apparently PositiveSelfInitialization doesn't have a valid RecordDecl. If you instantiate the template, though, the code again fails to compile.

michael_miller edited edge metadata.

Added a comment explaining the new test added.

michael_miller marked 4 inline comments as done.May 2 2016, 3:36 PM
michael_miller added inline comments.
test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
342 ↗(On Diff #55904)

Added a comment explaining why the check is there.

aaron.ballman added inline comments.May 2 2016, 4:01 PM
test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
342 ↗(On Diff #55904)

Thank you, the comment is excellent.

This revision was automatically updated to reflect the committed changes.