[clang] [clang-tools-extra] [clang][modules] Remove `Module::ASTFile` (PR #185994)

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 24 09:00:03 PDT 2026


================
@@ -6339,15 +6339,16 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
                                        "too many submodules");
 
       if (!ParentModule) {
-        if (OptionalFileEntryRef CurFile = CurrentModule->getASTFile()) {
+        if (const ModuleFileKey *CurFileKey = CurrentModule->getASTFileKey()) {
           // Don't emit module relocation error if we have -fno-validate-pch
           if (!bool(PP.getPreprocessorOpts().DisablePCHOrModuleValidation &
                     DisableValidationForModuleKind::Module)) {
-            assert(CurFile != F.File && "ModuleManager did not de-duplicate");
+            assert(*CurFileKey != F.FileKey &&
+                   "ModuleManager did not de-duplicate");
 
             Diag(diag::err_module_file_conflict)
-                << CurrentModule->getTopLevelModuleName() << CurFile->getName()
-                << F.File.getName();
+                << CurrentModule->getTopLevelModuleName()
+                << *CurrentModule->getASTFileName() << F.FileName;
----------------
benlangmuir wrote:

The key and name can only be set together. The fact `getASTFileKey()` is set here means the name cannot be null. Maybe worth an assert, but it is correct AFAICT.

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


More information about the cfe-commits mailing list