mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Demangler: make the demangler more tolerant with malformed symbols.
Instead of crashing it just should not demangle malformed symbols. rdar://problem/32113006
This commit is contained in:
@@ -28,12 +28,6 @@ using swift::Demangle::FunctionSigSpecializationParamKind;
|
||||
// Private utility functions //
|
||||
//////////////////////////////////
|
||||
|
||||
[[noreturn]]
|
||||
static void demangler_unreachable(const char *Message) {
|
||||
fprintf(stderr, "fatal error: %s\n", Message);
|
||||
std::abort();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
static bool isDeclName(Node::Kind kind) {
|
||||
@@ -1283,6 +1277,8 @@ NodePointer Demangler::demangleThunkOrSpecialization() {
|
||||
|
||||
NodePointer Demangler::demangleGenericSpecialization(Node::Kind SpecKind) {
|
||||
NodePointer Spec = demangleSpecAttributes(SpecKind);
|
||||
if (!Spec)
|
||||
return nullptr;
|
||||
NodePointer TyList = popTypeList();
|
||||
if (!TyList)
|
||||
return nullptr;
|
||||
@@ -1907,21 +1903,21 @@ NodePointer Demangler::demangleGenericRequirement() {
|
||||
return nullptr;
|
||||
name = "m";
|
||||
} else {
|
||||
demangler_unreachable("Unknown layout constraint");
|
||||
// Unknown layout constraint.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto NameNode = createNode(Node::Kind::Identifier, name);
|
||||
auto LayoutRequirement = createWithChildren(
|
||||
Node::Kind::DependentGenericLayoutRequirement, ConstrTy, NameNode);
|
||||
if (size)
|
||||
LayoutRequirement->addChild(size, *this);
|
||||
addChild(LayoutRequirement, size);
|
||||
if (alignment)
|
||||
LayoutRequirement->addChild(alignment, *this);
|
||||
addChild(LayoutRequirement, alignment);
|
||||
return LayoutRequirement;
|
||||
}
|
||||
}
|
||||
|
||||
demangler_unreachable("Unhandled TypeKind in switch.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NodePointer Demangler::demangleGenericType() {
|
||||
|
||||
Reference in New Issue
Block a user