diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Serialization/GlobalModuleIndex.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Serialization/GlobalModuleIndex.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/contrib/llvm/tools/clang/lib/Serialization/GlobalModuleIndex.cpp b/contrib/llvm/tools/clang/lib/Serialization/GlobalModuleIndex.cpp index 4791388..17c7914 100644 --- a/contrib/llvm/tools/clang/lib/Serialization/GlobalModuleIndex.cpp +++ b/contrib/llvm/tools/clang/lib/Serialization/GlobalModuleIndex.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "ASTReaderInternals.h" +#include "clang/Frontend/PCHContainerOperations.h" #include "clang/Basic/FileManager.h" #include "clang/Lex/HeaderSearch.h" #include "clang/Serialization/ASTBitCodes.h" @@ -384,6 +385,7 @@ namespace { /// \brief Builder that generates the global module index file. class GlobalModuleIndexBuilder { FileManager &FileMgr; + const PCHContainerReader &PCHContainerRdr; /// \brief Mapping from files to module file information. typedef llvm::MapVector<const FileEntry *, ModuleFileInfo> ModuleFilesMap; @@ -416,7 +418,9 @@ namespace { } public: - explicit GlobalModuleIndexBuilder(FileManager &FileMgr) : FileMgr(FileMgr){} + explicit GlobalModuleIndexBuilder( + FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr) + : FileMgr(FileMgr), PCHContainerRdr(PCHContainerRdr) {} /// \brief Load the contents of the given module file into the builder. /// @@ -501,8 +505,7 @@ bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) { // Initialize the input stream llvm::BitstreamReader InStreamFile; - InStreamFile.init((const unsigned char *)(*Buffer)->getBufferStart(), - (const unsigned char *)(*Buffer)->getBufferEnd()); + PCHContainerRdr.ExtractPCH((*Buffer)->getMemBufferRef(), InStreamFile); llvm::BitstreamCursor InStream(InStreamFile); // Sniff for the signature. @@ -757,14 +760,16 @@ void GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) { Record.clear(); Record.push_back(IDENTIFIER_INDEX); Record.push_back(BucketOffset); - Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable.str()); + Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable); } Stream.ExitBlock(); } GlobalModuleIndex::ErrorCode -GlobalModuleIndex::writeIndex(FileManager &FileMgr, StringRef Path) { +GlobalModuleIndex::writeIndex(FileManager &FileMgr, + const PCHContainerReader &PCHContainerRdr, + StringRef Path) { llvm::SmallString<128> IndexPath; IndexPath += Path; llvm::sys::path::append(IndexPath, IndexFileName); @@ -787,8 +792,8 @@ GlobalModuleIndex::writeIndex(FileManager &FileMgr, StringRef Path) { } // The module index builder. - GlobalModuleIndexBuilder Builder(FileMgr); - + GlobalModuleIndexBuilder Builder(FileMgr, PCHContainerRdr); + // Load each of the module files. std::error_code EC; for (llvm::sys::fs::directory_iterator D(Path, EC), DEnd; @@ -841,12 +846,12 @@ GlobalModuleIndex::writeIndex(FileManager &FileMgr, StringRef Path) { return EC_IOError; // Remove the old index file. It isn't relevant any more. - llvm::sys::fs::remove(IndexPath.str()); + llvm::sys::fs::remove(IndexPath); // Rename the newly-written index file to the proper name. - if (llvm::sys::fs::rename(IndexTmpPath.str(), IndexPath.str())) { + if (llvm::sys::fs::rename(IndexTmpPath, IndexPath)) { // Rename failed; just remove the - llvm::sys::fs::remove(IndexTmpPath.str()); + llvm::sys::fs::remove(IndexTmpPath); return EC_IOError; } |