diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-28 23:57:47 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-28 23:57:47 +0000 |
commit | fab8d5b478e6fb112b4414c4698a7cc2a350b0f0 (patch) | |
tree | 2e7fc24b585026c0b84ccc1a0dcb486832780985 | |
parent | 19645d2ae928580b62f9feff91c5aa5e19f5f20d (diff) |
[PCH] Sort the file decls by file offset not raw source location.
Currently sorting by raw source location does work as intended but who knows
what may change in the future..
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143256 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Serialization/ASTWriter.h | 2 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index 2c747d8ea8..bad5c379bc 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -146,7 +146,7 @@ private: /// the declaration's ID. std::vector<serialization::DeclOffset> DeclOffsets; - /// \brief Vector of pairs of raw location/DeclID. + /// \brief Sorted (by file offset) vector of pairs of file offset/DeclID. typedef SmallVector<std::pair<unsigned, serialization::DeclID>, 64> LocDeclIDsTy; struct DeclIDInFileInfo { diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 0c9f0a1247..1b44baa9ce 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -3501,7 +3501,9 @@ void ASTWriter::associateDeclWithFile(const Decl *D, DeclID ID) { SourceManager &SM = Context->getSourceManager(); SourceLocation FileLoc = SM.getFileLoc(Loc); assert(SM.isLocalSourceLocation(FileLoc)); - FileID FID = SM.getFileID(FileLoc); + FileID FID; + unsigned Offset; + llvm::tie(FID, Offset) = SM.getDecomposedLoc(FileLoc); if (FID.isInvalid()) return; const SrcMgr::SLocEntry *Entry = &SM.getSLocEntry(FID); @@ -3511,11 +3513,10 @@ void ASTWriter::associateDeclWithFile(const Decl *D, DeclID ID) { if (!Info) Info = new DeclIDInFileInfo(); - unsigned RawLoc = FileLoc.getRawEncoding(); - std::pair<unsigned, serialization::DeclID> LocDecl(RawLoc, ID); + std::pair<unsigned, serialization::DeclID> LocDecl(Offset, ID); LocDeclIDsTy &Decls = Info->DeclIDs; - if (Decls.empty() || Decls.back().first <= RawLoc) { + if (Decls.empty() || Decls.back().first <= Offset) { Decls.push_back(LocDecl); return; } |