Skip to content

Commit 07e7e7e

Browse files
committed
---
yaml --- r: 349383 b: refs/heads/master-next c: ee15a40 h: refs/heads/master i: 349381: 1ef8fca 349379: 9827d7e 349375: 077951a
1 parent b8338f9 commit 07e7e7e

File tree

3 files changed

+51
-12
lines changed

3 files changed

+51
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: 0cdd51d28ce070e7c4488a9409a52f4974b5f543
3+
refs/heads/master-next: ee15a40152caa12b974e404d4a2b1144062b3d56
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/AST/ASTDemangler.cpp

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "swift/AST/Types.h"
3333
#include "swift/Demangling/Demangler.h"
3434
#include "swift/Demangling/ManglingMacros.h"
35+
#include "llvm/ADT/StringSwitch.h"
3536

3637
using namespace swift;
3738

@@ -838,22 +839,45 @@ CanGenericSignature ASTBuilder::demangleGenericSignature(
838839
break;
839840
}
840841
case Demangle::Node::Kind::DependentGenericLayoutRequirement: {
841-
// FIXME: Other layout constraints
842-
LayoutConstraint constraint;
843842
auto kindChild = child->getChild(1);
844843
if (kindChild->getKind() != Demangle::Node::Kind::Identifier)
845844
return CanGenericSignature();
846845

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);
854875
}
855876

856-
return CanGenericSignature();
877+
builder.addRequirement(
878+
Requirement(RequirementKind::Layout, subjectType, layout),
879+
source, nullptr);
880+
break;
857881
}
858882
default:
859883
return CanGenericSignature();

branches/master-next/test/TypeDecoder/extensions.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,19 @@ extension Generic where T == Int {
4242
// CHECK-DECL: extensions.(file).Generic extension.Nested1
4343

4444
// DEMANGLE-DECL: $s10extensions7GenericVAASiRszlE7Nested2V
45-
// CHECK-DECL: extensions.(file).Generic extension.Nested2
45+
// CHECK-DECL: extensions.(file).Generic extension.Nested2
46+
47+
// Layout Constraints
48+
// FIXME: When other layout constraints are allowed in source level swift, test
49+
// that we correctly demangle those as well.
50+
51+
extension Generic where T: AnyObject {
52+
struct NestedViaAnyObject {}
53+
}
54+
55+
// DEMANGLE-TYPE: $s10extensions7GenericVAARlzClE18NestedViaAnyObjectVyx_GD
56+
// CHECK-TYPE: Generic<τ_0_0>.NestedViaAnyObject
57+
58+
// DEMANGLE-DECL: $s10extensions7GenericVAARlzClE18NestedViaAnyObjectV
59+
// CHECK-DECL: extensions.(file).Generic extension.NestedViaAnyObject
60+

0 commit comments

Comments
 (0)