diff options
author | Vlad Serebrennikov <serebrennikov.vladislav@gmail.com> | 2024-05-17 13:01:37 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-17 13:01:37 +0400 |
commit | ee54c86ef70d7809e7d67cd44de2d3153b31c46e (patch) | |
tree | 88eac8c18450863a2b71c9dfcdf18c5f1810c665 /clang/lib/Basic/SourceManager.cpp | |
parent | 5a20a07fce88d54cf01cafde489bfc2fc447acc0 (diff) | |
download | llvm-ee54c86ef70d7809e7d67cd44de2d3153b31c46e.zip llvm-ee54c86ef70d7809e7d67cd44de2d3153b31c46e.tar.gz llvm-ee54c86ef70d7809e7d67cd44de2d3153b31c46e.tar.bz2 |
[clang][NFC] Improve const-correctness in `SourceManager` (#92436)
This patch adds several const-qualified variants of existing member
functions to `SourceManager`.
I started with removing const qualification from
`setNumCreatedFIDsForFileID`, and removing `const_cast` in the body of
this function, as I think it doesn't make sense to const-qualify
setters.
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 37734d3..afdb5b0 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -431,6 +431,10 @@ ContentCache &SourceManager::createMemBufferContentCache( const SrcMgr::SLocEntry &SourceManager::loadSLocEntry(unsigned Index, bool *Invalid) const { + return const_cast<SourceManager *>(this)->loadSLocEntry(Index, Invalid); +} + +SrcMgr::SLocEntry &SourceManager::loadSLocEntry(unsigned Index, bool *Invalid) { assert(!SLocEntryLoaded[Index]); if (ExternalSLocEntries->ReadSLocEntry(-(static_cast<int>(Index) + 2))) { if (Invalid) |