diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-10-02 21:09:17 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-10-02 21:09:17 +0000 |
commit | 4db774a8ef09260aae80b7cba6702d0cfe9e0dbc (patch) | |
tree | ee31b5d63beecb993842f4fac514488e25388672 | |
parent | 10e7846abf4e69f03dfb65b36d866c01ece66645 (diff) | |
download | bcm5719-llvm-4db774a8ef09260aae80b7cba6702d0cfe9e0dbc.tar.gz bcm5719-llvm-4db774a8ef09260aae80b7cba6702d0cfe9e0dbc.zip |
[PCH/Module] Change the map of file-level DeclIDs to use a FileID
as key instead of a SLocEntry pointer. This allows the array of
file sorted declarations in a PCH/module to be deterministic.
llvm-svn: 165047
-rw-r--r-- | clang/include/clang/Serialization/ASTWriter.h | 3 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 9 |
2 files changed, 6 insertions, 6 deletions
diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h index d038d58aed8..d95b249a28b 100644 --- a/clang/include/clang/Serialization/ASTWriter.h +++ b/clang/include/clang/Serialization/ASTWriter.h @@ -171,8 +171,7 @@ private: /// indicates the index that this particular vector has in the global one. unsigned FirstDeclIndex; }; - typedef llvm::DenseMap<const SrcMgr::SLocEntry *, - DeclIDInFileInfo *> FileDeclIDsTy; + typedef llvm::DenseMap<FileID, DeclIDInFileInfo *> FileDeclIDsTy; /// \brief Map from file SLocEntries to info about the file-level declarations /// that it contains. diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 384995722af..6e19977a94a 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1435,6 +1435,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr, I != N; ++I) { // Get this source location entry. const SrcMgr::SLocEntry *SLoc = &SourceMgr.getLocalSLocEntry(I); + FileID FID = FileID::get(I); + assert(&SourceMgr.getSLocEntry(FID) == SLoc); // Record the offset of this source-location entry. SLocEntryOffsets.push_back(Stream.GetCurrentBitNo()); @@ -1475,7 +1477,7 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr, Record.push_back(Content->BufferOverridden); Record.push_back(File.NumCreatedFIDs); - FileDeclIDsTy::iterator FDI = FileDeclIDs.find(SLoc); + FileDeclIDsTy::iterator FDI = FileDeclIDs.find(FID); if (FDI != FileDeclIDs.end()) { Record.push_back(FDI->second->FirstDeclIndex); Record.push_back(FDI->second->DeclIDs.size()); @@ -3954,10 +3956,9 @@ void ASTWriter::associateDeclWithFile(const Decl *D, DeclID ID) { llvm::tie(FID, Offset) = SM.getDecomposedLoc(FileLoc); if (FID.isInvalid()) return; - const SrcMgr::SLocEntry *Entry = &SM.getSLocEntry(FID); - assert(Entry->isFile()); + assert(SM.getSLocEntry(FID).isFile()); - DeclIDInFileInfo *&Info = FileDeclIDs[Entry]; + DeclIDInFileInfo *&Info = FileDeclIDs[FID]; if (!Info) Info = new DeclIDInFileInfo(); |