aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Serialization/ASTBitCodes.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-12-17 23:38:30 +0000
committerDouglas Gregor <dgregor@apple.com>2011-12-17 23:38:30 +0000
commita1be278c4f3a234ff61f04018d26c6beecde1654 (patch)
tree417374c22b99d713e9c7dbe093ec987d65cb7374 /include/clang/Serialization/ASTBitCodes.h
parent79cbbdc8affe52591f7ee487a789639aa38331ec (diff)
Completely re-implement (de-)serialization of declaration
chains. The previous implementation relied heavily on the declaration chain being stored as a (circular) linked list on disk, as it is in memory. However, when deserializing from multiple modules, the different chains could get mixed up, leading to broken declaration chains. The new solution keeps track of the first and last declarations in the chain for each module file. When we load a declaration, we search all of the module files for redeclarations of that declaration, then splice together all of the lists into a coherent whole (along with any redeclarations that were actually parsed). As a drive-by fix, (de-)serialize the redeclaration chains of TypedefNameDecls, which had somehow gotten missed previously. Add a test of this serialization. This new scheme creates a redeclaration table that is fairly large in the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The table is mmap'd in and searched via a binary search, but it's still quite large. A future tweak will eliminate entries for declarations that have no redeclarations anywhere, and should drastically reduce the size of this table. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146841 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Serialization/ASTBitCodes.h')
-rw-r--r--include/clang/Serialization/ASTBitCodes.h33
1 files changed, 32 insertions, 1 deletions
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h
index 41ef74ee0a..cce6916b4e 100644
--- a/include/clang/Serialization/ASTBitCodes.h
+++ b/include/clang/Serialization/ASTBitCodes.h
@@ -452,7 +452,11 @@ namespace clang {
/// \brief Record code for an array of all of the (sub)modules that were
/// imported by the AST file.
- IMPORTED_MODULES
+ IMPORTED_MODULES,
+
+ /// \brief Record code for the array describing the first/last local
+ /// redeclarations of each entity.
+ LOCAL_REDECLARATIONS
};
/// \brief Record types used within a source manager block.
@@ -1190,6 +1194,33 @@ namespace clang {
CTOR_INITIALIZER_INDIRECT_MEMBER
};
+ /// \brief Describes the redeclarations of a declaration.
+ struct LocalRedeclarationsInfo {
+ DeclID FirstID; // The ID of the first declaration
+ DeclID FirstLocalID; // The ID of the first local declaration
+ DeclID LastLocalID; // The ID of the last local declaration
+
+ friend bool operator<(const LocalRedeclarationsInfo &X,
+ const LocalRedeclarationsInfo &Y) {
+ return X.FirstID < Y.FirstID;
+ }
+
+ friend bool operator>(const LocalRedeclarationsInfo &X,
+ const LocalRedeclarationsInfo &Y) {
+ return X.FirstID > Y.FirstID;
+ }
+
+ friend bool operator<=(const LocalRedeclarationsInfo &X,
+ const LocalRedeclarationsInfo &Y) {
+ return X.FirstID <= Y.FirstID;
+ }
+
+ friend bool operator>=(const LocalRedeclarationsInfo &X,
+ const LocalRedeclarationsInfo &Y) {
+ return X.FirstID >= Y.FirstID;
+ }
+ };
+
/// @}
}
} // end namespace clang