Runtime: Generate a mangled name as the ObjC runtime name of generic class instances.

Our hack to generate a unique name by appending the class pointer doesn't produce a stable class name that can persist in NSKeyedArchiver, or eventually be used as a key for dynamic runtime instantiation. Generate a proper mangled name for the class instance by building a demangling AST from the metadata nodes and feeding it into the remangler. Should fix rdar://problem/18884563, though I need to try using an archiver with a generic class to verify.

Swift SVN r29316
This commit is contained in:
Joe Groff
2015-06-05 14:27:58 +00:00
parent 0386c7fe60
commit 2bf783dfe8
9 changed files with 389 additions and 49 deletions

View File

@@ -73,29 +73,6 @@ std::ostream &operator<<(std::ostream &OS, const QuotedString &QS) {
return OS;
}
namespace swift {
namespace Demangle {
struct NodeFactory {
static NodePointer create(Node::Kind K) {
return NodePointer(new Node(K));
}
static NodePointer create(Node::Kind K, Node::IndexType Index) {
return NodePointer(new Node(K, Index));
}
static NodePointer create(Node::Kind K, llvm::StringRef Text) {
return NodePointer(new Node(K, Text));
}
static NodePointer create(Node::Kind K, std::string &&Text) {
return NodePointer(new Node(K, std::move(Text)));
}
template <size_t N>
static NodePointer create(Node::Kind K, const char (&Text)[N]) {
return NodePointer(new Node(K, llvm::StringRef(Text)));
}
};
} // end namespace Demangle
} // end namespace swift
Node::~Node() {
switch (NodePayloadKind) {
case PayloadKind::None: return;