The purpose of this patch and follow-on patches is to ensure that
AttributeCommonInfos always have a syntax that is appropriate for
their kind (i.e. that it matches one of the entries in Attr.td).
The attribute-specific Create and CreateImplicit methods had four
overloads, based on their tail arguments:
(1) no extra arguments
(2) an AttributeCommonInfo
(3) a SourceRange
(4) a SourceRange, a syntax, and (where necessary) a spelling
When (4) had a spelling argument, it defaulted to
SpellingNotCalculated.
One disadvantage of this was that (1) and (3) zero-initialized
the syntax field of the AttributeCommonInfo, which corresponds
to AS_GNU. But AS_GNU isn't always listed as a possibility
in Attr.td.
This patch therefore removes (1) and (3) and instead provides
the same functionality using default arguments on (4) (a bit
like the existing default argument for the spelling).
The default syntax is taken from the attribute's first valid
spelling.
Doing that raises the question: what should happen for attributes
like AlignNatural and CUDAInvalidTarget that are only ever created
implicitly, and so have no source-code manifestation at all?
The patch adds a new AS_Implicit "syntax" for that case.
The patch also removes the syntax argument for these attributes,
since the syntax must always be AS_Implicit.
For similar reasons, the patch removes the syntax argument if
there is exactly one valid spelling.
Doing this means that AttributeCommonInfo no longer needs the
single-argument constructors. It is always given a syntax instead.
If I recall, there was some pretty awful funny business in some attributes, which would explicitly use '0' instead of AS_GNU as implicit. Did you run into any of these?
Would it make sense to make AS_Implicit 'first' here to catch those? Or perhaps make '0' ill-formed (and assert?) and make this '1'?