From: Douglas Gregor Date: Mon, 13 Apr 2009 17:12:42 +0000 (+0000) Subject: Make the reading of the line table from a PCH file more robust against X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff0a9872aafbe9c0c37b06f33ed013471fc361f8;p=clang Make the reading of the line table from a PCH file more robust against the unlikely event that the filename IDs in the stored line table end up being different from the filename IDs in the newly-created line table. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68965 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 4998de371f..9a0061ea0e 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -200,21 +200,20 @@ static bool ParseLineTable(SourceManager &SourceMgr, LineTableInfo &LineTable = SourceMgr.getLineTable(); // Parse the file names - for (unsigned I = 0, N = Record[Idx++]; I != N; ++I) { + std::map FileIDs; + for (int I = 0, N = Record[Idx++]; I != N; ++I) { // Extract the file name unsigned FilenameLen = Record[Idx++]; std::string Filename(&Record[Idx], &Record[Idx] + FilenameLen); Idx += FilenameLen; - unsigned ID = LineTable.getLineTableFilenameID(Filename.c_str(), - Filename.size()); - if (ID != I) - return Error("Filename ID mismatch in PCH line table"); + FileIDs[I] = LineTable.getLineTableFilenameID(Filename.c_str(), + Filename.size()); } // Parse the line entries std::vector Entries; while (Idx < Record.size()) { - unsigned FID = Record[Idx++]; + int FID = FileIDs[Record[Idx++]]; // Extract the line entries unsigned NumEntries = Record[Idx++];