[SourceKit] Fix a crash when performing related identifers request on self

Performing a related identifiers request on `self` returns an empty result because `self` is not an identifier. We thus can’t retrieve the first location to compute the old name.

rdar://121668042
This commit is contained in:
Alex Hoppen
2024-01-29 15:51:27 -08:00
parent 4bc7726d43
commit f0ea24dd29
4 changed files with 18 additions and 4 deletions

View File

@@ -2550,7 +2550,10 @@ void SwiftLangSupport::findRelatedIdentifiersInFile(
RenameLocs Locs = localRenameLocs(SrcFile, Info->VD);
std::string OldName = Locs.getLocations().front().OldName.str();
std::optional<std::string> OldName;
if (!Locs.getLocations().empty()) {
OldName = Locs.getLocations().front().OldName.str();
}
#ifndef NDEBUG
for (auto loc : Locs.getLocations()) {
assert(loc.OldName == OldName &&