[clang] [clang][Modules] Diagnose mismatching pcm dependencies in explicit buiilds (PR #137068)
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 23 15:27:03 PDT 2025
================
@@ -3311,11 +3312,22 @@ ASTReader::ReadControlBlock(ModuleFile &F,
SignatureBytes.end());
Blob = Blob.substr(ASTFileSignature::size);
+ // Use BaseDirectoryAsWritten to ensure we use the same path in the
+ // ModuleCache as when writing.
+ StoredFile = ReadPathBlob(BaseDirectoryAsWritten, Record, Idx, Blob);
if (ImportedFile.empty()) {
- // Use BaseDirectoryAsWritten to ensure we use the same path in the
- // ModuleCache as when writing.
- ImportedFile =
- ReadPathBlob(BaseDirectoryAsWritten, Record, Idx, Blob);
+ ImportedFile = StoredFile;
+ } else {
+ auto ImportedFileRef =
+ PP.getFileManager().getOptionalFileRef(ImportedFile);
+ auto StoredFileRef =
+ PP.getFileManager().getOptionalFileRef(StoredFile);
+ if ((ImportedFileRef && StoredFileRef) &&
+ (*ImportedFileRef != *StoredFileRef)) {
+ Diag(diag::warn_lazy_pcm_mismatch) << ImportedFile << StoredFile;
+ Diag(diag::note_module_file_imported_by)
----------------
jansvoboda11 wrote:
Could we avoid this by having something like this up top?
```c++
auto NoteImportedByOnce = [&, NotedAlready = false] mutable {
if (NotedAlready)
return;
Diag(diag::note_module_file_imported_by)
<< F.FileName << !F.ModuleName.empty() << F.ModuleName;
NotedAlready = true;
};
```
And then calling it whenever needed?
https://github.com/llvm/llvm-project/pull/137068
More information about the cfe-commits
mailing list