1) Redesign DeclAttributes to be based around an array indexed by attribute, instead

of having a ton of ad-hoc bools in it.  This allows us to consolidate a ton of 
   boilerplate, eliminating 250 lines of code:

 17 files changed, 435 insertions(+), 662 deletions(-)

2) This eliminates the special case for weak and unowned attributes, which previously
   didn't show up in Attr.def.

3) While we're at it, keep track of proper source locations for each attribute, and
   use these to emit diagnostics pointing at the attribute in question instead of at
   a funcdecl or the @ sign.

4) Fix axle attributes, which had vertex and fragment swapped.



Swift SVN r9263
This commit is contained in:
Chris Lattner
2013-10-13 01:25:50 +00:00
parent a718c8f57a
commit 09705dc7cd
13 changed files with 351 additions and 578 deletions

View File

@@ -1066,7 +1066,7 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext,
var->setImplicit();
var->setIsObjC(isObjC);
if (isIBOutlet)
var->getMutableAttrs().IBOutlet = true;
var->getMutableAttrs().setAttr(AK_iboutlet, SourceLoc());
var->setOverriddenDecl(cast_or_null<VarDecl>(getDecl(overriddenID)));
break;
@@ -1149,24 +1149,24 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext,
fn->getMutableAttrs().AsmName = ctx.AllocateCopy(blobData);
if (isAssignmentOrConversion) {
if (fn->isOperator())
fn->getMutableAttrs().Assignment = true;
fn->getMutableAttrs().setAttr(AK_assignment, SourceLoc());
else
fn->getMutableAttrs().Conversion = true;
fn->getMutableAttrs().setAttr(AK_conversion, SourceLoc());
}
fn->setIsObjC(isObjC);
if (isIBAction)
fn->getMutableAttrs().IBAction = true;
fn->getMutableAttrs().setAttr(AK_ibaction, SourceLoc());
if (isTransparent)
fn->getMutableAttrs().Transparent = true;
fn->getMutableAttrs().setAttr(AK_transparent, SourceLoc());
if (Decl *associated = getDecl(associatedDeclID)) {
if (auto op = dyn_cast<OperatorDecl>(associated)) {
fn->setOperatorDecl(op);
if (isa<PrefixOperatorDecl>(op))
fn->getMutableAttrs().ExplicitPrefix = true;
fn->getMutableAttrs().setAttr(AK_prefix, SourceLoc());
else if (isa<PostfixOperatorDecl>(op))
fn->getMutableAttrs().ExplicitPostfix = true;
fn->getMutableAttrs().setAttr(AK_postfix, SourceLoc());
// Note that an explicit [infix] is not required.
}
// Otherwise, unknown associated decl kind.
@@ -1238,7 +1238,7 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext,
if (isImplicit)
proto->setImplicit();
if (isClassProtocol)
proto->getMutableAttrs().ClassProtocol = true;
proto->getMutableAttrs().setAttr(AK_class_protocol, SourceLoc());
proto->setIsObjC(isObjC);
proto->computeType();