[cfe-commits] r143256 - in /cfe/trunk: include/clang/Serialization/ASTWriter.h lib/Serialization/ASTWriter.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Oct 28 16:57:47 PDT 2011
Author: akirtzidis
Date: Fri Oct 28 18:57:47 2011
New Revision: 143256
URL: http://llvm.org/viewvc/llvm-project?rev=143256&view=rev
Log:
[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..
Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=143256&r1=143255&r2=143256&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Fri Oct 28 18:57:47 2011
@@ -146,7 +146,7 @@
/// 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 {
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=143256&r1=143255&r2=143256&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Oct 28 18:57:47 2011
@@ -3501,7 +3501,9 @@
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 @@
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;
}
More information about the cfe-commits
mailing list