From: Argyrios Kyrtzidis Date: Mon, 19 Sep 2011 20:39:54 +0000 (+0000) Subject: [PCH] Preload the PreloadSLocEntries through the SourceManager and X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac1ffcc55b861737ba2466cd1ca1accd8eafceaa;p=clang [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140052 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index fb48430e25..9dc1945852 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -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; }; diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index e4f9fa693c..6c0afb59b4 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -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); }