Question about Attr.td

Aaron Ballman aaron at aaronballman.com
Thu Jun 20 10:43:35 PDT 2013


I am doing some attribute work, and I wanted to make sure I wasn't
missing anything (and that I was heading in the right direction).

It seems that the Subjects are not being used for anything.  The
tablegen doesn't emit any code based on them, and the subjects in the
td file are not particularly consistent.  I would like to correct this
in the following ways:

1) I want to modify the tablegen to spit out some template functions:

template <typename Subject>
bool appertainsTo() const { return false; }

template <>
bool appertainsTo<TableGenSubject>() const { return true; }

2) If the attribute in the td file has no subjects, I want the default
appertainsTo to return true (so it behaves in a backwards compatible
manner).

Between these two, we can start to do some things in Sema to determine
what the attribtue appertains to.  For instance, my particular problem
is with declarations.  If I have an attribute that I want to appertain
to a statement (not a decl), I cannot do it because the attribute
always attaches to the decl.  I want to be able to report that as an
error for my statement attributes instead of generating an unknown
attribute warning on the decl.

3) Currently, the subjects are a mixture of names based on other td
files (like Var), and fully-formed named (like VarDecl).  I would like
to change the file to consistently used full-formed names (VarDecl) --
otherwise, the tablegen will have to guess at whether the type needs
to be suffixed with Decl, or does not need any suffix at all (such as
Stmt nodes).

4) Do something about SubsetSubjects so that I can emit tablegen code
that works properly with them.

Are there any issues with this?  Or suggestions?

Thanks!

~Aaron



More information about the cfe-commits mailing list