|
32 | 32 | #include "swift/AST/Types.h"
|
33 | 33 | #include "swift/Demangling/Demangler.h"
|
34 | 34 | #include "swift/Demangling/ManglingMacros.h"
|
| 35 | +#include "llvm/ADT/StringSwitch.h" |
35 | 36 |
|
36 | 37 | using namespace swift;
|
37 | 38 |
|
@@ -838,22 +839,45 @@ CanGenericSignature ASTBuilder::demangleGenericSignature(
|
838 | 839 | break;
|
839 | 840 | }
|
840 | 841 | case Demangle::Node::Kind::DependentGenericLayoutRequirement: {
|
841 |
| - // FIXME: Other layout constraints |
842 |
| - LayoutConstraint constraint; |
843 | 842 | auto kindChild = child->getChild(1);
|
844 | 843 | if (kindChild->getKind() != Demangle::Node::Kind::Identifier)
|
845 | 844 | return CanGenericSignature();
|
846 | 845 |
|
847 |
| - if (kindChild->getText() == "C") { |
848 |
| - auto kind = LayoutConstraintKind::Class; |
849 |
| - auto layout = LayoutConstraint::getLayoutConstraint(kind, Ctx); |
850 |
| - builder.addRequirement( |
851 |
| - Requirement(RequirementKind::Layout, subjectType, layout), |
852 |
| - source, nullptr); |
853 |
| - break; |
| 846 | + auto kind = llvm::StringSwitch<Optional< |
| 847 | + LayoutConstraintKind>>(kindChild->getText()) |
| 848 | + .Case("U", LayoutConstraintKind::UnknownLayout) |
| 849 | + .Case("R", LayoutConstraintKind::RefCountedObject) |
| 850 | + .Case("N", LayoutConstraintKind::NativeRefCountedObject) |
| 851 | + .Case("C", LayoutConstraintKind::Class) |
| 852 | + .Case("D", LayoutConstraintKind::NativeClass) |
| 853 | + .Case("T", LayoutConstraintKind::Trivial) |
| 854 | + .Cases("E", "e", LayoutConstraintKind::TrivialOfExactSize) |
| 855 | + .Cases("M", "m", LayoutConstraintKind::TrivialOfAtMostSize) |
| 856 | + .Default(None); |
| 857 | + |
| 858 | + if (!kind) |
| 859 | + return CanGenericSignature(); |
| 860 | + |
| 861 | + LayoutConstraint layout; |
| 862 | + |
| 863 | + if (kind != LayoutConstraintKind::TrivialOfExactSize && |
| 864 | + kind != LayoutConstraintKind::TrivialOfAtMostSize) { |
| 865 | + layout = LayoutConstraint::getLayoutConstraint(*kind, Ctx); |
| 866 | + } else { |
| 867 | + auto size = child->getChild(2)->getIndex(); |
| 868 | + auto alignment = 0; |
| 869 | + |
| 870 | + if (child->getNumChildren() == 4) |
| 871 | + alignment = child->getChild(3)->getIndex(); |
| 872 | + |
| 873 | + layout = LayoutConstraint::getLayoutConstraint(*kind, size, alignment, |
| 874 | + Ctx); |
854 | 875 | }
|
855 | 876 |
|
856 |
| - return CanGenericSignature(); |
| 877 | + builder.addRequirement( |
| 878 | + Requirement(RequirementKind::Layout, subjectType, layout), |
| 879 | + source, nullptr); |
| 880 | + break; |
857 | 881 | }
|
858 | 882 | default:
|
859 | 883 | return CanGenericSignature();
|
|
0 commit comments