diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-28 22:54:21 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-28 22:54:21 +0000 |
commit | 10f3df54486385e6497c9e5f229ff816e5a6c511 (patch) | |
tree | c59d129e93074e5c87cb3f2a4389332ae5dfc522 /lib/Serialization/ASTWriterDecl.cpp | |
parent | d0dcceae2a8ca0e37b5dd471a704de8583d49c95 (diff) |
[PCH] Keep track of file-level declarations that are contained by files.
Introduce a FILE_SORTED_DECLS [de]serialization record that contains
a file sorted array of file-level DeclIDs in a PCH/Module.
The rationale is to allow "targeted" deserialization of decls inside
a range of a source file.
Cocoa PCH increased by 0.8%
Difference of creation time for Cocoa PCH is below the noise level.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143238 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r-- | lib/Serialization/ASTWriterDecl.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index 13cdd0ef2b..1b95e927f9 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -18,6 +18,7 @@ #include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "clang/AST/DeclContextInternals.h" +#include "clang/Basic/SourceManager.h" #include "llvm/ADT/Twine.h" #include "llvm/Bitcode/BitstreamWriter.h" #include "llvm/Support/ErrorHandling.h" @@ -1651,14 +1652,20 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) { unsigned Index = ID - FirstDeclID; // Record the offset for this declaration + SourceLocation Loc = D->getLocation(); if (DeclOffsets.size() == Index) - DeclOffsets.push_back(DeclOffset(D->getLocation(), - Stream.GetCurrentBitNo())); + DeclOffsets.push_back(DeclOffset(Loc, Stream.GetCurrentBitNo())); else if (DeclOffsets.size() < Index) { DeclOffsets.resize(Index+1); - DeclOffsets[Index].setLocation(D->getLocation()); + DeclOffsets[Index].setLocation(Loc); DeclOffsets[Index].BitOffset = Stream.GetCurrentBitNo(); } + + SourceManager &SM = Context.getSourceManager(); + if (Loc.isValid() && SM.isLocalSourceLocation(Loc)) { + SourceLocation FileLoc = SM.getFileLoc(Loc); + associateDeclWithFile(D, ID, FileLoc); + } } // Build and emit a record for this declaration |