This revision was automatically updated to reflect the committed changes. Closed by commit rGaab50af8c18a: SourceManager: Use the same fake SLocEntry whenever it fails to load (authored by dexonsmith). Herald added a project: clang.
Changed prior to commit: https://reviews.llvm.org/D89748?vs=299209&id=300844#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D89748/new/ https://reviews.llvm.org/D89748 Files: clang/include/clang/Basic/SourceManager.h clang/lib/Basic/SourceManager.cpp Index: clang/lib/Basic/SourceManager.cpp =================================================================== --- clang/lib/Basic/SourceManager.cpp +++ clang/lib/Basic/SourceManager.cpp @@ -434,9 +434,11 @@ // If the file of the SLocEntry changed we could still have loaded it. if (!SLocEntryLoaded[Index]) { // Try to recover; create a SLocEntry so the rest of clang can handle it. - LoadedSLocEntryTable[Index] = SLocEntry::get( - 0, FileInfo::get(SourceLocation(), getFakeContentCacheForRecovery(), - SrcMgr::C_User, "")); + if (!FakeSLocEntryForRecovery) + FakeSLocEntryForRecovery = std::make_unique<SLocEntry>(SLocEntry::get( + 0, FileInfo::get(SourceLocation(), getFakeContentCacheForRecovery(), + SrcMgr::C_User, ""))); + return *FakeSLocEntryForRecovery; } } Index: clang/include/clang/Basic/SourceManager.h =================================================================== --- clang/include/clang/Basic/SourceManager.h +++ clang/include/clang/Basic/SourceManager.h @@ -693,7 +693,7 @@ /// /// Negative FileIDs are indexes into this table. To get from ID to an index, /// use (-ID - 2). - mutable SmallVector<SrcMgr::SLocEntry, 0> LoadedSLocEntryTable; + SmallVector<SrcMgr::SLocEntry, 0> LoadedSLocEntryTable; /// The starting offset of the next local SLocEntry. /// @@ -775,6 +775,8 @@ mutable std::unique_ptr<SrcMgr::ContentCache> FakeContentCacheForRecovery; + mutable std::unique_ptr<SrcMgr::SLocEntry> FakeSLocEntryForRecovery; + /// Lazily computed map of macro argument chunks to their expanded /// source location. using MacroArgsMap = std::map<unsigned, SourceLocation>;
Index: clang/lib/Basic/SourceManager.cpp =================================================================== --- clang/lib/Basic/SourceManager.cpp +++ clang/lib/Basic/SourceManager.cpp @@ -434,9 +434,11 @@ // If the file of the SLocEntry changed we could still have loaded it. if (!SLocEntryLoaded[Index]) { // Try to recover; create a SLocEntry so the rest of clang can handle it. - LoadedSLocEntryTable[Index] = SLocEntry::get( - 0, FileInfo::get(SourceLocation(), getFakeContentCacheForRecovery(), - SrcMgr::C_User, "")); + if (!FakeSLocEntryForRecovery) + FakeSLocEntryForRecovery = std::make_unique<SLocEntry>(SLocEntry::get( + 0, FileInfo::get(SourceLocation(), getFakeContentCacheForRecovery(), + SrcMgr::C_User, ""))); + return *FakeSLocEntryForRecovery; } } Index: clang/include/clang/Basic/SourceManager.h =================================================================== --- clang/include/clang/Basic/SourceManager.h +++ clang/include/clang/Basic/SourceManager.h @@ -693,7 +693,7 @@ /// /// Negative FileIDs are indexes into this table. To get from ID to an index, /// use (-ID - 2). - mutable SmallVector<SrcMgr::SLocEntry, 0> LoadedSLocEntryTable; + SmallVector<SrcMgr::SLocEntry, 0> LoadedSLocEntryTable; /// The starting offset of the next local SLocEntry. /// @@ -775,6 +775,8 @@ mutable std::unique_ptr<SrcMgr::ContentCache> FakeContentCacheForRecovery; + mutable std::unique_ptr<SrcMgr::SLocEntry> FakeSLocEntryForRecovery; + /// Lazily computed map of macro argument chunks to their expanded /// source location. using MacroArgsMap = std::map<unsigned, SourceLocation>;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits