Change processing of @asmname to use a new internal representation.

This representation is inspired by Clang's internal representation.
The current attribute representation, which is basically a union
of "stuff" in DeclAttributes, is not amendable to richer
attributes, such as @availability, that need to be implemented.
In Clang, attributes are modeled with actual objects that
encode both semantic and syntactic information (e.g., source ranges)
that facilitate richer checking, better diagnostics, and better tools.

This change is foundational for implementing @availability, but
also is a better long-term representation.  As a migratory path,
it creates some duplications, with AttrKind and DeclAttrKind, the
two which should eventually become the same thing.

As part of this patch, there is some additional parser recovery
(for the new attribute representation) for duplicate attributes.
The parser now parses the entire duplicate attribute, which could
be quite complex, and then issues a diagnostic that the attribute
is a duplicate (and discarding it).  This delayed diagnostic
also allows us to present ranges for the duplicate attribute, which
provides a better user experience.

Swift SVN r15365
This commit is contained in:
Ted Kremenek
2014-03-22 14:58:30 +00:00
parent 2235221854
commit f43842e160
12 changed files with 312 additions and 60 deletions

View File

@@ -263,11 +263,11 @@ static void mangleConstant(SILDeclRef c, llvm::raw_ostream &buffer) {
// As a special case, functions can have external asm names.
// Use the asm name only for the original non-thunked, non-curried entry
// point.
if (!c.getDecl()->getAttrs().AsmName.empty()
&& !c.isForeignThunk() && !c.isCurried) {
buffer << c.getDecl()->getAttrs().AsmName;
return;
}
if (auto AsmA = c.getDecl()->getAttrs().getAttribute<AsmnameAttr>())
if (!c.isForeignThunk() && !c.isCurried) {
buffer << AsmA->Name;
return;
}
// Otherwise, fall through into the 'other decl' case.
SWIFT_FALLTHROUGH;