[clang] [clang][modules] Erase PCMs not meeting expectations from in-memory cache (PR #177004)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 21 09:26:47 PST 2026


================
@@ -5153,13 +5155,28 @@ ASTReader::ReadASTCore(StringRef FileName,
         << moduleKindForDiagnostic(Type) << FileName << !ErrorStr.empty()
         << ErrorStr;
     return Failure;
+  case ModuleManager::ExpectationNotMet:
+    if (!MC.isPCMFinal(FileName)) {
+      // The importer expected a different PCM. We don't know for sure whether
+      // it's this PCM that's out of date, or whether it's the importer and it
+      // therefore has out-of-date expectations.
+      // Let's defensively remove this PCM from the in-memory cache so that we
+      // are able to properly validate a fresh one later on.
+      MC.erasePCM(FileName);
+    }
----------------
jansvoboda11 wrote:

Because `tryToDropPCM()` would bring the state for this PCM to `ToBuild` or `Final`. To force re-loading fresh one from the disk, the state needs to be `Unknown`.

https://github.com/llvm/llvm-project/pull/177004


More information about the cfe-commits mailing list