[cfe-commits] r68965 - /cfe/trunk/lib/Frontend/PCHReader.cpp

Douglas Gregor dgregor at apple.com
Mon Apr 13 10:12:43 PDT 2009


Author: dgregor
Date: Mon Apr 13 12:12:42 2009
New Revision: 68965

URL: http://llvm.org/viewvc/llvm-project?rev=68965&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Frontend/PCHReader.cpp

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=68965&r1=68964&r2=68965&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Mon Apr 13 12:12:42 2009
@@ -200,21 +200,20 @@
   LineTableInfo &LineTable = SourceMgr.getLineTable();
 
   // Parse the file names
-  for (unsigned I = 0, N = Record[Idx++]; I != N; ++I) {
+  std::map<int, int> 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<LineEntry> Entries;
   while (Idx < Record.size()) {
-    unsigned FID = Record[Idx++];
+    int FID = FileIDs[Record[Idx++]];
 
     // Extract the line entries
     unsigned NumEntries = Record[Idx++];





More information about the cfe-commits mailing list