rip out "AtLoc" in DeclAttributes, now that each individual attribute tracks the location of its associated @ (if present)

Swift SVN r20072
This commit is contained in:
Chris Lattner
2014-07-17 05:02:01 +00:00
parent fdaa28ce16
commit a9ed3303a6
3 changed files with 9 additions and 39 deletions

View File

@@ -836,16 +836,6 @@ class DeclAttributes {
DeclAttribute *DeclAttrs; DeclAttribute *DeclAttrs;
public: public:
/// The location of the first '@' in the attribute specifier.
///
/// This is an invalid location if the declaration does not have any or has
/// only virtual attributes.
///
/// This could be a valid location even if none of the attributes are set.
/// This can happen when the attributes were parsed, but then cleared because
/// they are not allowed in that context.
SourceLoc AtLoc;
DeclAttributes() : DeclAttrs(nullptr) {} DeclAttributes() : DeclAttrs(nullptr) {}
bool isEmpty() const { bool isEmpty() const {

View File

@@ -183,7 +183,7 @@ private:
bool annotateIfConfigConditionIdentifiers(Expr *Cond); bool annotateIfConfigConditionIdentifiers(Expr *Cond);
bool handleAttrs(const DeclAttributes &Attrs); bool handleAttrs(const DeclAttributes &Attrs);
bool handleAttrs(const TypeAttributes &Attrs); bool handleAttrs(const TypeAttributes &Attrs);
bool handleAttrRanges(SourceLoc AtLoc, ArrayRef<SourceRange> Ranges); bool handleAttrRanges(ArrayRef<SourceRange> Ranges);
bool shouldPassBraceStructureNode(BraceStmt *S); bool shouldPassBraceStructureNode(BraceStmt *S);
@@ -656,17 +656,16 @@ bool ModelASTWalker::annotateIfConfigConditionIdentifiers(Expr *Cond) {
bool ModelASTWalker::handleAttrs(const DeclAttributes &Attrs) { bool ModelASTWalker::handleAttrs(const DeclAttributes &Attrs) {
SmallVector<SourceRange, 4> Ranges; SmallVector<SourceRange, 4> Ranges;
Attrs.getAttrRanges(Ranges); Attrs.getAttrRanges(Ranges);
return handleAttrRanges(Attrs.AtLoc, Ranges); return handleAttrRanges(Ranges);
} }
bool ModelASTWalker::handleAttrs(const TypeAttributes &Attrs) { bool ModelASTWalker::handleAttrs(const TypeAttributes &Attrs) {
SmallVector<SourceRange, 4> Ranges; SmallVector<SourceRange, 4> Ranges;
Attrs.getAttrRanges(Ranges); Attrs.getAttrRanges(Ranges);
return handleAttrRanges(Attrs.AtLoc, Ranges); return handleAttrRanges(Ranges);
} }
bool ModelASTWalker::handleAttrRanges(SourceLoc AtLoc, bool ModelASTWalker::handleAttrRanges(ArrayRef<SourceRange> Ranges) {
ArrayRef<SourceRange> Ranges) {
if (Ranges.empty()) if (Ranges.empty())
return true; return true;
@@ -677,9 +676,7 @@ bool ModelASTWalker::handleAttrRanges(SourceLoc AtLoc,
}); });
Ranges = SortedRanges; Ranges = SortedRanges;
SourceLoc BeginLoc = AtLoc; SourceLoc BeginLoc = Ranges.front().Start;
if (!AtLoc.isValid())
BeginLoc = Ranges.front().Start;
std::vector<Token> Toks = swift::tokenize( std::vector<Token> Toks = swift::tokenize(
LangOpts, SM, BufferID, LangOpts, SM, BufferID,
@@ -688,12 +685,8 @@ bool ModelASTWalker::handleAttrRanges(SourceLoc AtLoc,
/*KeepComments=*/true, /*KeepComments=*/true,
/*TokenizeInterpolatedString=*/false); /*TokenizeInterpolatedString=*/false);
auto passAttrNode = [&](SourceLoc AtLoc, SourceRange AttrRange) -> bool { auto passAttrNode = [&](SourceRange AttrRange) -> bool {
SourceRange Range; SourceRange Range = AttrRange;
if (AtLoc.isValid())
Range = SourceRange(AtLoc, AttrRange.End);
else
Range = AttrRange;
if (!passNonTokenNode({SyntaxNodeKind::AttributeBuiltin, if (!passNonTokenNode({SyntaxNodeKind::AttributeBuiltin,
charSourceRangeFromSourceRange(SM, Range)})) charSourceRangeFromSourceRange(SM, Range)}))
return false; return false;
@@ -710,18 +703,13 @@ bool ModelASTWalker::handleAttrRanges(SourceLoc AtLoc,
if (Tok.getLoc() == Ranges.front().Start) { if (Tok.getLoc() == Ranges.front().Start) {
auto R = Ranges.front(); auto R = Ranges.front();
Ranges = Ranges.slice(1); Ranges = Ranges.slice(1);
if (!passAttrNode(AtLoc, R)) if (!passAttrNode(R))
return false; return false;
} }
if (Tok.is(tok::at_sign))
AtLoc = Tok.getLoc();
else
AtLoc = SourceLoc();
} }
if (!Ranges.empty()) { if (!Ranges.empty()) {
if (!passAttrNode(AtLoc, Ranges.front())) if (!passAttrNode(Ranges.front()))
return false; return false;
} }

View File

@@ -813,14 +813,6 @@ bool Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc) {
return true; return true;
} }
// XXX
// FIXME: This is bogus to only honor the first '@', but this
// will be fixed once the attribute refactoring completes for
// all existing declaration attributes.
if (Attributes.AtLoc.isInvalid())
Attributes.AtLoc = AtLoc;
// If the attribute follows the new representation, switch // If the attribute follows the new representation, switch
// over to the alternate parsing path. // over to the alternate parsing path.
DeclAttrKind DK = getDeclAttrFromString(Tok.getText()); DeclAttrKind DK = getDeclAttrFromString(Tok.getText());