Skip to content

Commit 2ed1770

Browse files
authored
[SourceKit] Check location validity before getting the line number to fix a crash. rdar://26756189 (#3364)
1 parent 34dce93 commit 2ed1770

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/IDE/Formatting.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class FormatWalker : public SourceEntityWalker {
477477
return;
478478
SourceLoc PrevLoc;
479479
auto FindAlignLoc = [&](SourceLoc Loc) {
480-
if (PrevLoc.isValid() &&
480+
if (PrevLoc.isValid() && Loc.isValid() &&
481481
SM.getLineNumber(PrevLoc) == SM.getLineNumber(Loc))
482482
return PrevLoc;
483483
return PrevLoc = Loc;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
subscript (__PLACEHOLDER_0__) -> __PLACEHOLDER_1__ {
2+
get {
3+
__PLACEHOLDER_2__
4+
}
5+
set(__PLACEHOLDER_3__) {
6+
__PLACEHOLDER_4__
7+
}
8+
}
9+
10+
// RUN: %sourcekitd-test -req=format -line=1 -length=1 %s >%t.response

0 commit comments

Comments
 (0)