Swift: workaround an internal crash coming from Swift 5.7.1

This commit is contained in:
Alex Denisov 2022-11-24 15:36:35 +01:00
Родитель f618d53302
Коммит 67fb56deb8
1 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -215,6 +215,17 @@ class SwiftDispatcher {
// Emits a Location TRAP entry and attaches it to a `Locatable` trap label
template <typename Locatable>
void attachLocation(Locatable* locatable, TrapLabel<LocatableTag> locatableLabel) {
// Swift 5.7.1 causing a crash when the Swift compiler uses .back() of and empty
// getPatternList() when getting the source location.
// So far this only observed with the entities coming from precompiled modules, so they
// should not have locations anyway.
if constexpr (std::is_base_of<swift::Decl, Locatable>::value) {
if (auto* decl = llvm::dyn_cast<swift::PatternBindingDecl>(locatable)) {
if (decl->getPatternList().empty()) {
return;
}
}
}
attachLocation(locatable->getStartLoc(), locatable->getEndLoc(), locatableLabel);
}