aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorkadir çetinkaya <kadircet@google.com>2025-06-12 10:49:23 +0200
committerGitHub <noreply@github.com>2025-06-12 10:49:23 +0200
commit4551e5035565606eb04253a35f31d51685657436 (patch)
tree7890f21fb4f7c7d3f22b38d383bbfbb1ecb1a727 /clang/lib/Basic/SourceManager.cpp
parentce621041c2f162c50d630810491c2feee8eb6c64 (diff)
downloadllvm-4551e5035565606eb04253a35f31d51685657436.zip
llvm-4551e5035565606eb04253a35f31d51685657436.tar.gz
llvm-4551e5035565606eb04253a35f31d51685657436.tar.bz2
[clang] Reset FileID based diag state mappings (#143695)
When sharing same compiler instance for multiple compilations, we reset source manager's file id tables in between runs. Diagnostics engine keeps a cache based on these file ids, that became dangling references across compilations. This patch makes sure we reset those whenever sourcemanager is trashing its FileIDs.
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r--clang/lib/Basic/SourceManager.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 09e5c65..053e826 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -344,6 +344,9 @@ void SourceManager::clearIDTables() {
NextLocalOffset = 0;
CurrentLoadedOffset = MaxLoadedOffset;
createExpansionLoc(SourceLocation(), SourceLocation(), SourceLocation(), 1);
+ // Diagnostics engine keeps some references to fileids, mostly for dealing
+ // with diagnostic pragmas, make sure they're reset as well.
+ Diag.ResetPragmas();
}
bool SourceManager::isMainFile(const FileEntry &SourceFile) {