[cfe-commits] r140052 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Serialization/ASTReader.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Sep 19 13:39:54 PDT 2011


Author: akirtzidis
Date: Mon Sep 19 15:39:54 2011
New Revision: 140052

URL: http://llvm.org/viewvc/llvm-project?rev=140052&view=rev
Log:
[PCH] Preload the PreloadSLocEntries 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.

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

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=140052&r1=140051&r2=140052&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Sep 19 15:39:54 2011
@@ -1296,6 +1296,9 @@
   getDecomposedSpellingLocSlowCase(const SrcMgr::SLocEntry *E,
                                    unsigned Offset) const;
   void computeMacroArgsCache(SrcMgr::ContentCache *Content, FileID FID);
+
+  friend class ASTReader;
+  friend class ASTWriter;
 };
 
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=140052&r1=140051&r2=140052&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Sep 19 15:39:54 2011
@@ -2633,9 +2633,11 @@
   // 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);
   }
 
 





More information about the cfe-commits mailing list