]> granicus.if.org Git - clang/commitdiff
Preload source location entries as soon as we've loaded a particular
authorDouglas Gregor <dgregor@apple.com>
Thu, 25 Aug 2011 21:09:44 +0000 (21:09 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 25 Aug 2011 21:09:44 +0000 (21:09 +0000)
AST file, rather than waiting until we finish loading the top-level
AST file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138585 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Serialization/ASTReader.h
include/clang/Serialization/Module.h
lib/Serialization/ASTReader.cpp

index b145710a133a46f9e85575bd9072285a87316757..7eb512a51a77fb002d2fc036b1e653cb5aae960d 100644 (file)
@@ -244,9 +244,6 @@ private:
   /// 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;
 
index a6a7da4fbdbca017e9223e8d7a61a94286315065..b3c3bc3271ca8ca01c2329ee62b1e1882d5da300 100644 (file)
@@ -111,6 +111,9 @@ public:
   /// 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;
   
index c9a8380ff682b5e7d765b757834f8775e8e7b37f..86625b7bdf1b934d8c8bb7102c9d399d8761158a 100644 (file)
@@ -2216,9 +2216,12 @@ ASTReader::ReadASTBlock(Module &F) {
     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 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
   }
 
   // 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 @@ ASTReader::ASTReadResult ASTReader::ReadASTCore(StringRef FileName,
     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;
 }