This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Handle unions with existing default-member-init
ClosedPublic

Authored by malcolm.parsons on Feb 3 2019, 1:47 PM.

Diff Detail

Event Timeline

malcolm.parsons created this revision.Feb 3 2019, 1:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2019, 1:47 PM

Just to make sure I understand the issue correctly (and so please correct me if I am wrong):

The union member e leads to an IndirectFieldDecl in the record for UnionExisting. Then CXXCtorInitializer::getMember returns null since the initialized member is not a FieldDecl, but an IndirectFieldDecl. Using CXXCtorInitializer::getAnyMember handles both FieldDecls and IndirectFieldDecls, which solves the issue.

Looks OK but probably better to wait for someone else to give the OK ?

JonasToth accepted this revision.Feb 3 2019, 2:59 PM
JonasToth added a subscriber: JonasToth.

LGTM, please close the bug report and notify for the fix with the request to check in the real-project if it actually fixes the issue. Thanks :)

This revision is now accepted and ready to land.Feb 3 2019, 2:59 PM
MyDeveloperDay added a project: Restricted Project.Feb 3 2019, 3:15 PM
This revision was automatically updated to reflect the committed changes.