[PATCH] Attribute parameters and arguments

Richard Smith richard at metafoo.co.uk
Tue Aug 27 15:27:22 PDT 2013


On Tue, Aug 27, 2013 at 3:16 PM, Aaron Ballman <aaron at aaronballman.com>wrote:

> Attributes can have a single parameter, as well as multiple (sometimes
> optional) arguments.


What is the distinction you're drawing between parameters and arguments
here?

If you mean the weirdness in the GNU attribute syntax that we sometimes use
different parsing rules for the first argument, I don't think modeling that
as a fundamentally different kind of argument is the right way to proceed.
Instead, we should look at the list of Args when parsing an attribute
argument list, to determine how to parse each element.


>  However, tablegen currently does not do a very
> good job of expressing this, and so the semantic checks have to be
> implemented in many different places.
>
> This patch overhauls the way arguments and parameters are handled in
> tablegen.  Specifically, it:
>
> 1) Adds the notion of an explicit parameter to the attribute
> definition, instead of implicitly relying on it being the first,
> "blessed" type in an argument list.
> 2) Arguments can now specify that they are optional (by default, all
> arguments are mandatory).
> 3) Updates the tablegen for these new features.  This includes adding
> a second attribute constructor which elides the optional arguments
> (they can be set later via an explicit setter).
> 4) Updates the AttributeList to express more information garnered from
> the tablegen.
> 5) Updates the semantic checking for declarations so that it can make
> use of this new information on AttributeList and consolidates a bunch
> of checking into one function.
>
> This may seem like the patch is doing a lot of different things, but
> in the end, the combination is required in order to make this patch
> useful as a unit.  The good news is: subsequent patches consolidating
> more error checking should be considerably smaller.  Future error
> checking includes: optional parameters and attribute subjects (there
> are likely other things we can consolidate as well).
>
> ~Aaron
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130827/492baf44/attachment.html>


More information about the cfe-commits mailing list