mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Serialize local types and provide a lookup API
rdar://problem/18295292 Locally scoped type declarations were previously not serialized into the module, which meant that the debugger couldn't reason about the structure of instances of those types. Introduce a new mangling for local types: [file basename MD5][counter][identifier] This allows the demangle node's data to be used directly for lookup without having to backtrack in the debugger. Local decls are now serialized into a LOCAL_TYPE_DECLS table in the module, which acts as the backing hash table for looking up [file basename MD5][counter][identifier] -> DeclID mappings. New tests: * swift-ide-test mode for testing the demangle/lookup/mangle lifecycle of a module that contains local decls * mangling * module merging with local decls Swift SVN r24426
This commit is contained in:
@@ -936,19 +936,22 @@ private:
|
||||
|
||||
NodePointer demangleDeclName() {
|
||||
// decl-name ::= local-decl-name
|
||||
// local-decl-name ::= 'L' index identifier
|
||||
// local-decl-name ::= 'L' filehash index identifier
|
||||
if (Mangled.nextIf('L')) {
|
||||
NodePointer fileHash = demangleIdentifier();
|
||||
if (!fileHash) return nullptr;
|
||||
|
||||
NodePointer discriminator = demangleIndexAsNode();
|
||||
if (!discriminator) return nullptr;
|
||||
|
||||
NodePointer name = demangleIdentifier();
|
||||
if (!name) return nullptr;
|
||||
|
||||
NodePointer localName = NodeFactory::create(Node::Kind::LocalDeclName);
|
||||
localName->addChild(std::move(discriminator));
|
||||
localName->addChild(std::move(name));
|
||||
return localName;
|
||||
|
||||
NodePointer localDecl = NodeFactory::create(Node::Kind::LocalDeclName);
|
||||
localDecl->addChild(std::move(fileHash));
|
||||
localDecl->addChild(std::move(discriminator));
|
||||
localDecl->addChild(std::move(name));
|
||||
return localDecl;
|
||||
} else if (Mangled.nextIf('P')) {
|
||||
NodePointer discriminator = demangleIdentifier();
|
||||
if (!discriminator) return nullptr;
|
||||
@@ -2641,8 +2644,11 @@ void NodePrinter::print(NodePointer pointer, bool asContext, bool suppressType)
|
||||
return;
|
||||
case Node::Kind::LocalDeclName:
|
||||
Printer << '(';
|
||||
print(pointer->getChild(1));
|
||||
Printer << " #" << (pointer->getChild(0)->getIndex() + 1) << ')';
|
||||
print(pointer->getChild(2));
|
||||
Printer << " #" << (pointer->getChild(1)->getIndex() + 1);
|
||||
Printer << " in ";
|
||||
print(pointer->getChild(0));
|
||||
Printer << ')';
|
||||
return;
|
||||
case Node::Kind::PrivateDeclName:
|
||||
Printer << '(';
|
||||
|
||||
Reference in New Issue
Block a user