This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Convert ParsedAttr to use llvm::TrailingObjects
ClosedPublic

Authored by erichkeane on Aug 9 2018, 1:02 PM.

Details

Summary

ParsedAttr is using a hand-rolled trailing-objects
implementation that gets cleaned up quite a bit by
just using llvm::TrailingObjects. This is a large
TrailingObjects list, but most things are length '0'.

Diff Detail

Repository
rL LLVM

Event Timeline

erichkeane created this revision.Aug 9 2018, 1:02 PM
erichkeane added inline comments.Aug 9 2018, 1:07 PM
include/clang/Sema/ParsedAttr.h
80 ↗(On Diff #159980)

Because all of these became part of the TYPE of ParsedAttr now, they need to be defined outside of ParsedAttr. Additionally, they are now required to be in a non-anonymous namespace.

525 ↗(On Diff #159980)

Unfortunately, these need to return a non-const param, since the only user of these takes a const ParsedAttr and requires the IdentifierInfo* to be a non-const ptr.

578 ↗(On Diff #159980)

Sadly, there isn't a better way to do this with TrailingObjects. The parameter argument list is simply so that it can check to make sure you have them right?

I'd much prefer to be able to omit the ones not important to this size, but that doesn't seem possible.

Also, it seems that we used to do some things to make sure that these sizes were a multiple of sizeof(void*) as a premature optimization. However, all of these are constant-sized, so over-allocating seems like a useless task.

lib/Sema/SemaDeclCXX.cpp
15466 ↗(On Diff #159980)

The only usage of PropertyData, which didn't seem important to support anymore.

rsmith accepted this revision.Aug 9 2018, 1:09 PM
rsmith added a subscriber: rsmith.

Looks good, thanks. (I'm not sure why PropertyData needs special handling rather than being treated as two IdentifierLoc arguments, but that's not made any worse here, just perhaps a bit more obvious.)

This revision is now accepted and ready to land.Aug 9 2018, 1:09 PM
This revision was automatically updated to reflect the committed changes.

Some inline comments. Since you already committed it I don't think it
is worth bothering with them.

cfe/trunk/include/clang/Sema/ParsedAttr.h
124

I think you can do something like friend TrailingObjects;
like most (every ?) other users of TrailingObjects do. It relies on the
injected class name if I am not mistaken.

366

And maybe it would be nice to delete explicitly the move
ctor/assignment op too (my turn to make this remark :) ).
They are already not declared I think so it do not really matter.