[PCH] Preload the PreloadSLocEntries through the SourceManager and

don't call ReadSLocEntryRecord() directly because the entry may have
already been loaded in which case calling ReadSLocEntryRecord()
directly would trigger an assertion in SourceManager.

llvm-svn: 140052
This commit is contained in:
Argyrios Kyrtzidis 2011-09-19 20:39:54 +00:00
parent 8b7c08b897
commit b527a7cbf8
2 changed files with 8 additions and 3 deletions

View File

@ -1296,6 +1296,9 @@ private:
getDecomposedSpellingLocSlowCase(const SrcMgr::SLocEntry *E,
unsigned Offset) const;
void computeMacroArgsCache(SrcMgr::ContentCache *Content, FileID FID);
friend class ASTReader;
friend class ASTWriter;
};

View File

@ -2633,9 +2633,11 @@ ASTReader::ASTReadResult ASTReader::ReadASTCore(StringRef FileName,
// Preload SLocEntries.
for (unsigned I = 0, N = M->PreloadSLocEntries.size(); I != N; ++I) {
int Index = int(M->PreloadSLocEntries[I] - 1) + F.SLocEntryBaseID;
ASTReadResult Result = ReadSLocEntryRecord(Index);
if (Result != Success)
return Failure;
// Load it through the SourceManager and don't call ReadSLocEntryRecord()
// directly because the entry may have already been loaded in which case
// calling ReadSLocEntryRecord() directly would trigger an assertion in
// SourceManager.
SourceMgr.getLoadedSLocEntryByID(Index);
}