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 | 5fc727a0c29589d886d38aa074d9bcdff9e1ba5c (patch) | |
tree | b00d1be79e3ddebdd3fa10dc6ac9630de6c65b87 /clang/lib/Serialization/ASTWriterDecl.cpp | |
parent | 3d785edee273ee9fcb89d255dda1f787afa49197 (diff) | |
download | bcm5719-llvm-5fc727a0c29589d886d38aa074d9bcdff9e1ba5c.tar.gz bcm5719-llvm-5fc727a0c29589d886d38aa074d9bcdff9e1ba5c.zip |
[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.
llvm-svn: 143238
Diffstat (limited to 'clang/lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriterDecl.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 13cdd0ef2b6..1b95e927f9b 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/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 |