]> granicus.if.org Git - clang/commitdiff
[PCH] Preload the PreloadSLocEntries through the SourceManager and
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 19 Sep 2011 20:39:54 +0000 (20:39 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 19 Sep 2011 20:39:54 +0000 (20:39 +0000)
don't call ReadSLocEntryRecord() directly because the entry may have
already been loaded in which case calling ReadSLocEntryRecord()
directly would trigger an assertion in SourceManager.

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

include/clang/Basic/SourceManager.h
lib/Serialization/ASTReader.cpp

index fb48430e25cea4c33bce3c92c92b8d64501885b0..9dc19458521cf01c9806c22f5bc2a1508c721993 100644 (file)
@@ -1296,6 +1296,9 @@ private:
   getDecomposedSpellingLocSlowCase(const SrcMgr::SLocEntry *E,
                                    unsigned Offset) const;
   void computeMacroArgsCache(SrcMgr::ContentCache *Content, FileID FID);
+
+  friend class ASTReader;
+  friend class ASTWriter;
 };
 
 
index e4f9fa693c8ad7c2d252e81989762554c6c52987..6c0afb59b40c30374eebb18492f8d5697cf5dac8 100644 (file)
@@ -2633,9 +2633,11 @@ ASTReader::ASTReadResult ASTReader::ReadASTCore(StringRef FileName,
   // 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;
+    // Load it through the SourceManager and don't call ReadSLocEntryRecord()
+    // directly because the entry may have already been loaded in which case
+    // calling ReadSLocEntryRecord() directly would trigger an assertion in
+    // SourceManager.
+    SourceMgr.getLoadedSLocEntryByID(Index);
   }