Page MenuHomePhabricator

[clang][AST] Get rid of an alignment hack in DeclObjC.h [NFCI]

Authored by miyuki on Jan 7 2021, 4:00 AM.



This code currently uses a union object to increase the
alignment of the type ObjCTypeParamList. The original intent of this
trick was to be able to use the expression this + 1 to access the
beginning of a tail-allocated array of ObjCTypeParamDecl * pointers.

The code has since been refactored and uses llvm::TrailingObjects to
manage the tail-allocated array. This template takes care of
alignment, so the hack is no longer necessary.

This patch removes the union so that the SourceRange class can be
used directly instead of being re-implemented with raw representations
of source locations.

Diff Detail

Event Timeline

miyuki requested review of this revision.Jan 7 2021, 4:00 AM
miyuki created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 7 2021, 4:00 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
miyuki updated this revision to Diff 315113.Jan 7 2021, 5:44 AM

Fixed formatting.

aprantl added inline comments.Jan 8 2021, 4:10 PM

Can you add a comment here explaining why the alignas is needed here? It's not obvious from the context.

miyuki updated this revision to Diff 315601.Jan 9 2021, 7:52 AM
miyuki edited the summary of this revision. (Show Details)

Removed alignas

miyuki marked an inline comment as done.Jan 9 2021, 7:52 AM
miyuki added inline comments.Jan 11 2021, 2:31 AM

Actually, alignas is not needed here. I've removed it and updated the commit message to explain why.

aprantl accepted this revision.Jan 11 2021, 1:36 PM

That's even better!

This revision is now accepted and ready to land.Jan 11 2021, 1:36 PM