Inheritable vs Noninheritable Attributes

Aaron Ballman aaron at aaronballman.com
Thu Jul 11 19:34:08 PDT 2013


While working on the tablegen to make Subjects worthwhile, I noticed
something that has me confused.  SemaDeclAttr.cpp has two big switch
statements: one for inheritable attributes, and one for
non-inheritable ones.  ProcessDeclAttribute is given two Boolean
parameters to determine whether the call should process inheritable,
non-inheritable or both types of attributes.

The confusing part is that the inheritable attributes in the switch
statements don't seem to resemble the attributes in Attr.td.  For
instance CUDADeviceAttr is in the non-inheritable switch, but is
defined as subclass InheritableAttr.  Conversely, AllocSizeAttr is in
the inheritable switch, but is defined as a subclass of Attr (not
InheritableAttr).  This happens in a number of cases.

When I went to "correct" the td file so that attributes had the proper
inheritance (pardon the pun), it broke a lot of test cases.  The same
happened when I moved attributes to the proper switch statement based
on their inheritance.  This leads me to believe there's something
deeper at play here.

The reason this is important to me is because I am trying to
automatically handle attribute subject diagnostics.  But in order to
do so, I need to know whether we *care* about that attribute when
calling ProcessDeclAttribute, otherwise I may emit a diagnostic for an
attribute we're not actually processing (which causes test cases to
fail as well).

Ideas?

~Aaron



More information about the cfe-commits mailing list