forked from OSchip/llvm-project
[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.. llvm-svn: 143256
This commit is contained in:
parent
df53da8725
commit
7362e9bacb
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue