aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorVlad Serebrennikov <serebrennikov.vladislav@gmail.com>2024-05-17 13:01:37 +0400
committerGitHub <noreply@github.com>2024-05-17 13:01:37 +0400
commitee54c86ef70d7809e7d67cd44de2d3153b31c46e (patch)
tree88eac8c18450863a2b71c9dfcdf18c5f1810c665 /clang/lib/Basic/SourceManager.cpp
parent5a20a07fce88d54cf01cafde489bfc2fc447acc0 (diff)
downloadllvm-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.cpp4
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)