Page MenuHomePhabricator

[clang-tidy] Fix crashing altera-struct-pack-align on invalid RecordDecls
ClosedPublic

Authored by steakhal on Fri, Nov 19, 9:13 AM.

Diff Detail

Event Timeline

steakhal created this revision.Fri, Nov 19, 9:13 AM
steakhal requested review of this revision.Fri, Nov 19, 9:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptFri, Nov 19, 9:13 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

What happens if this checker runs on a forward declared class?

struct Foo;

I'd expect the pack/alignment info is missing also in that case.

clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
54

I'd mention first that packing and alignment info are meaningless for invalid declarations.

steakhal updated this revision to Diff 389225.Tue, Nov 23, 9:02 AM
steakhal marked an inline comment as done.
  • update comments
  • move no-crash comment inline to the class member declaration

What happens if this checker runs on a forward declared class?

The matcher recordDecl(isStruct(), **isDefinition()**, unless(isExpansionInSystemHeader())) filters that case.

Thanks for the review @martong!

clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
54

Makes sense.

martong accepted this revision.Thu, Nov 25, 5:02 AM

LGTM!

This revision is now accepted and ready to land.Thu, Nov 25, 5:02 AM

I plan to commit this stack on Monday.