[cfe-commits] r138585 - in /cfe/trunk: include/clang/Serialization/ASTReader.h include/clang/Serialization/Module.h lib/Serialization/ASTReader.cpp

Douglas Gregor dgregor at apple.com
Thu Aug 25 14:09:44 PDT 2011


Author: dgregor
Date: Thu Aug 25 16:09:44 2011
New Revision: 138585

URL: http://llvm.org/viewvc/llvm-project?rev=138585&view=rev
Log:
Preload source location entries as soon as we've loaded a particular
AST file, rather than waiting until we finish loading the top-level
AST file.

Modified:
    cfe/trunk/include/clang/Serialization/ASTReader.h
    cfe/trunk/include/clang/Serialization/Module.h
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=138585&r1=138584&r2=138585&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Aug 25 16:09:44 2011
@@ -244,9 +244,6 @@
   /// at those bit offsets.
   ContinuousRangeMap<uint64_t, Module*, 4> GlobalBitOffsetsMap;
 
-  /// \brief SLocEntries that we're going to preload.
-  SmallVector<int, 64> PreloadSLocEntries;
-
   /// \brief A map of negated SLocEntryIDs to the modules containing them.
   ContinuousRangeMap<unsigned, Module*, 64> GlobalSLocEntryMap;
 

Modified: cfe/trunk/include/clang/Serialization/Module.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=138585&r1=138584&r2=138585&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/Module.h (original)
+++ cfe/trunk/include/clang/Serialization/Module.h Thu Aug 25 16:09:44 2011
@@ -111,6 +111,9 @@
   /// AST file.
   const uint32_t *SLocEntryOffsets;
   
+  /// \brief SLocEntries that we're going to preload.
+  SmallVector<uint64_t, 4> PreloadSLocEntries;
+
   /// \brief The number of source location file entries in this AST file.
   unsigned LocalNumSLocFileEntries;
   

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=138585&r1=138584&r2=138585&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Aug 25 16:09:44 2011
@@ -2216,9 +2216,12 @@
     case SOURCE_LOCATION_PRELOADS: {
       // Need to transform from the local view (1-based IDs) to the global view,
       // which is based off F.SLocEntryBaseID.
-      PreloadSLocEntries.reserve(PreloadSLocEntries.size() + Record.size());
-      for (unsigned I = 0, N = Record.size(); I != N; ++I)
-        PreloadSLocEntries.push_back(int(Record[I] - 1) + F.SLocEntryBaseID);
+      if (!F.PreloadSLocEntries.empty()) {
+        Error("Multiple SOURCE_LOCATION_PRELOADS records in AST file");
+        return Failure;
+      }
+      
+      F.PreloadSLocEntries.swap(Record);
       break;
     }
 
@@ -2546,14 +2549,6 @@
   }
 
   // Here comes stuff that we only do once the entire chain is loaded.
-
-  // Preload SLocEntries.
-  for (unsigned I = 0, N = PreloadSLocEntries.size(); I != N; ++I) {
-    ASTReadResult Result = ReadSLocEntryRecord(PreloadSLocEntries[I]);
-    if (Result != Success)
-      return Failure;
-  }
-  PreloadSLocEntries.clear();
   
   // Check the predefines buffers.
   if (!DisableValidation && Type != MK_Module && CheckPredefinesBuffers())
@@ -2742,6 +2737,15 @@
     case Success: break;
     }
   }
+  
+  // 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;
+  }
+
 
   return Success;
 }





More information about the cfe-commits mailing list