Skip to content

Commit cbcfb37

Browse files
committed
[Parse] Fix a couple of SourceRanges
These should point to the last token of the attribute, not the token that follows. rdar://123405070
1 parent 0affb27 commit cbcfb37

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ bool Parser::parseExternAttribute(DeclAttributes &Attributes,
15061506
return false;
15071507
}
15081508

1509-
auto AttrRange = SourceRange(Loc, Tok.getLoc());
1509+
auto AttrRange = SourceRange(Loc, rParenLoc);
15101510

15111511
// Reject duplicate attributes with the same kind.
15121512
if (ExternAttr::find(Attributes, kind)) {
@@ -2329,7 +2329,7 @@ bool Parser::parseBackDeployedAttribute(DeclAttributes &Attributes,
23292329
}
23302330

23312331
assert(!PlatformAndVersions.empty());
2332-
auto AttrRange = SourceRange(Loc, Tok.getLoc());
2332+
auto AttrRange = SourceRange(Loc, RightLoc);
23332333
for (auto &Item : PlatformAndVersions) {
23342334
Attributes.add(new (Context) BackDeployedAttr(AtLoc, AttrRange, Item.first,
23352335
Item.second,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %sourcekitd-test -req=open %s -- %s
2+
// Test that this doesn't crash sourcekitd
3+
4+
@_backDeploy(before: macOS 14.0)
5+
@inline(never)
6+
public func foo() {}
7+
8+
@_extern(wasm, module: "b", name: "c")
9+
@_extern(c)
10+
private func bar()

0 commit comments

Comments
 (0)