]> granicus.if.org Git - clang/commitdiff
Make the reading of the line table from a PCH file more robust against
authorDouglas Gregor <dgregor@apple.com>
Mon, 13 Apr 2009 17:12:42 +0000 (17:12 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 13 Apr 2009 17:12:42 +0000 (17:12 +0000)
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

lib/Frontend/PCHReader.cpp

index 4998de371fe430ad631fa6291ae063229badb259..9a0061ea0eed264a8aa42bb4a170e8c8b7ed0793 100644 (file)
@@ -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<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++];