mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +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:
@@ -246,7 +246,12 @@ private:
|
||||
using SerializedDeclTable =
|
||||
llvm::OnDiskIterableChainedHashTable<DeclTableInfo>;
|
||||
|
||||
class LocalDeclTableInfo;
|
||||
using SerializedLocalDeclTable =
|
||||
llvm::OnDiskIterableChainedHashTable<LocalDeclTableInfo>;
|
||||
|
||||
std::unique_ptr<SerializedDeclTable> TopLevelDecls;
|
||||
std::unique_ptr<SerializedLocalDeclTable> LocalTypeDecls;
|
||||
std::unique_ptr<SerializedDeclTable> OperatorDecls;
|
||||
std::unique_ptr<SerializedDeclTable> ExtensionDecls;
|
||||
std::unique_ptr<SerializedDeclTable> ClassMembersByName;
|
||||
@@ -258,7 +263,7 @@ private:
|
||||
|
||||
std::unique_ptr<SerializedObjCMethodTable> ObjCMethods;
|
||||
|
||||
llvm::DenseMap<const ValueDecl *, Identifier> PrivateDiscriminatorsByValue;
|
||||
llvm::DenseMap<const ValueDecl *, Identifier> DiscriminatorsByValue;
|
||||
|
||||
TinyPtrVector<Decl *> ImportDecls;
|
||||
|
||||
@@ -329,6 +334,11 @@ private:
|
||||
std::unique_ptr<SerializedDeclTable>
|
||||
readDeclTable(ArrayRef<uint64_t> fields, StringRef blobData);
|
||||
|
||||
/// Read an on-disk local decl hash table stored in
|
||||
/// index_block::DeclListLayout.
|
||||
std::unique_ptr<ModuleFile::SerializedLocalDeclTable>
|
||||
readLocalTypeDeclTable(ArrayRef<uint64_t> fields, StringRef blobData);
|
||||
|
||||
/// Read an on-disk Objective-C method table stored in
|
||||
/// index_block::ObjCMethodTableLayout format.
|
||||
std::unique_ptr<ModuleFile::SerializedObjCMethodTable>
|
||||
@@ -439,6 +449,10 @@ public:
|
||||
/// Searches the module's top-level decls for the given identifier.
|
||||
void lookupValue(DeclName name, SmallVectorImpl<ValueDecl*> &results);
|
||||
|
||||
/// Searches the module's local decls.
|
||||
TypeDecl *lookupLocalType(StringRef FileHash, unsigned LocalDiscriminator,
|
||||
StringRef Name);
|
||||
|
||||
/// Searches the module's operators for one with the given name and fixity.
|
||||
///
|
||||
/// If none is found, returns null.
|
||||
@@ -498,6 +512,9 @@ public:
|
||||
/// Adds all top-level decls to the given vector.
|
||||
void getTopLevelDecls(SmallVectorImpl<Decl*> &Results);
|
||||
|
||||
/// Adds all local decls in this module.
|
||||
void getLocalTypeDecls(SmallVectorImpl<Decl *> &results);
|
||||
|
||||
/// Adds all top-level decls to the given vector.
|
||||
///
|
||||
/// This includes all decls that should be displayed to clients of the module.
|
||||
@@ -536,6 +553,7 @@ public:
|
||||
Optional<BriefAndRawComment> getCommentForDeclByUSR(StringRef USR);
|
||||
|
||||
Identifier getDiscriminatorForPrivateValue(const ValueDecl *D);
|
||||
Identifier getDiscriminatorForLocalValue(const ValueDecl *D);
|
||||
|
||||
// MARK: Deserialization interface
|
||||
|
||||
|
||||
Reference in New Issue
Block a user