diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-03-25 01:17:43 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-03-25 01:17:43 +0000 |
commit | e37e9f43b73bfd67a90d3b4d0719d25f65007e9c (patch) | |
tree | d684bbc658ce9e7c76259073ade545f4e80b7258 /clang/lib/Serialization/ASTReaderDecl.cpp | |
parent | 8c8fcb2585b45dec7091fc9f3617dd8ef2bc4ac4 (diff) | |
download | llvm-e37e9f43b73bfd67a90d3b4d0719d25f65007e9c.zip llvm-e37e9f43b73bfd67a90d3b4d0719d25f65007e9c.tar.gz llvm-e37e9f43b73bfd67a90d3b4d0719d25f65007e9c.tar.bz2 |
[modules] Store a local offset to DeclContext lexical and visible contents. Saves a few bytes for each primary DeclContext.
llvm-svn: 264377
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 573a13a..abfee00 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -53,6 +53,12 @@ namespace clang { uint64_t GetCurrentCursorOffset(); + uint64_t ReadLocalOffset(const RecordData &R, unsigned &I) { + uint64_t LocalOffset = R[I++]; + assert(LocalOffset < Offset && "offset point after current record"); + return LocalOffset ? Offset - LocalOffset : 0; + } + SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) { return Reader.ReadSourceLocation(F, R, I); } @@ -2189,8 +2195,8 @@ void ASTDeclReader::VisitEmptyDecl(EmptyDecl *D) { std::pair<uint64_t, uint64_t> ASTDeclReader::VisitDeclContext(DeclContext *DC) { - uint64_t LexicalOffset = Record[Idx++]; - uint64_t VisibleOffset = Record[Idx++]; + uint64_t LexicalOffset = ReadLocalOffset(Record, Idx); + uint64_t VisibleOffset = ReadLocalOffset(Record, Idx); return std::make_pair(LexicalOffset, VisibleOffset); } @@ -2225,10 +2231,7 @@ ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) { for (unsigned I = 0; I != N - 1; ++I) MergeWith = ReadDecl(Record, Idx/*, MergeWith*/); - RedeclOffset = Record[Idx++]; - // RedeclOffset is a delta relative to the start of this record. - if (RedeclOffset) - RedeclOffset = Offset - RedeclOffset; + RedeclOffset = ReadLocalOffset(Record, Idx); } else { // This declaration was not the first local declaration. Read the first // local declaration now, to trigger the import of other redeclarations. |