This is an archive of the discontinued LLVM Phabricator instance.

Fixed cppcoreguidelines-pro-type-member-init when checking records with indirect fields
ClosedPublic

Authored by michael_miller on May 5 2016, 1:36 PM.

Details

Summary

Fixed a crash in cppcoreguidelines-pro-type-member-init when checking record types with indirect fields pre-C++11.
Fixed handling of indirect fields so they are properly checked and suggested fixes are proposed.

Diff Detail

Repository
rL LLVM

Event Timeline

michael_miller retitled this revision from to Fixed cppcoreguidelines-pro-type-member-init when checking records with indirect fields.
michael_miller updated this object.
michael_miller added a subscriber: cfe-commits.
alexfh added inline comments.May 5 2016, 4:33 PM
clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
31 ↗(On Diff #56341)

Is getCanonicalType() important here? Did you try using QualType::getAsCXXRecordDecl()?

michael_miller added inline comments.May 5 2016, 4:44 PM
clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
31 ↗(On Diff #56341)

Probably not but I didn't try it. I just moved the previous function up to the top so I didn't have to forward declare it.

One thing I'm simply unsure of is whether it's possible to get a RecordDecl that's not a CXXRecordDecl in C++ code. It seems like the answer is no but that might be another reason to keep it as is if I'm wrong about that...

hokein added inline comments.May 6 2016, 1:55 AM
clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
31 ↗(On Diff #56341)

One thing I'm simply unsure of is whether it's possible to get a RecordDecl that's not a CXXRecordDecl in C++ code.

From the documents, RecordDecl and CXXRecordDecl present struct/union/class, except CXXRecordDecl provides more methods for classes. So I think you can try QualType::getAsCXXRecordDecl() here.

Switched to using getAsCXXRecordDecl.

hokein accepted this revision.May 9 2016, 3:29 AM
hokein edited edge metadata.

LGTM.

This revision is now accepted and ready to land.May 9 2016, 3:29 AM
This revision was automatically updated to reflect the committed changes.