Skip to content

Commit

Permalink
[IDE] Make sure to handle the case of virtual-only attributes
Browse files Browse the repository at this point in the history
for syntax coloring.
Add a test for the above.
This addresses <rdar://problem/16584438>.

Swift SVN r16194
  • Loading branch information
sonnyfalk committed Apr 11, 2014
1 parent fdd36e9 commit 407e538
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/IDE/SyntaxModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ bool ModelASTWalker::handleAttrs(const TypeAttributes &Attrs) {
}
bool ModelASTWalker::handleAttrLocs(SourceLoc BeginLoc,
ArrayRef<SourceLoc> Locs) {
if (BeginLoc.isInvalid() || Locs.empty())
if (Locs.empty())
return true;

SmallVector<SourceLoc, 6> SortedLocs(Locs.begin(), Locs.end());
Expand All @@ -499,6 +499,12 @@ bool ModelASTWalker::handleAttrLocs(SourceLoc BeginLoc,
);
Locs = SortedLocs;

// The BeginLoc is invalid if there's no leading '@', which happens if there
// are only virtual attributes. In that case we'll use the location of the
// first attribute.
if (BeginLoc.isInvalid())
BeginLoc = Locs.front();

std::vector<Token> Toks =
swift::tokenize(LangOpts, SM, BufferID,
SM.getLocOffsetInBuffer(BeginLoc, BufferID),
Expand Down

0 comments on commit 407e538

Please sign in to comment.