@@ -3037,12 +3037,17 @@ ASTReader::ReadControlBlock(ModuleFile &F,
30373037 // location info are setup, in ReadAST.
30383038 SourceLocation ImportLoc =
30393039 ReadUntranslatedSourceLocation (Record[Idx++]);
3040- off_t StoredSize = (off_t )Record[Idx++];
3041- time_t StoredModTime = (time_t )Record[Idx++];
3042- auto FirstSignatureByte = Record.begin () + Idx;
3043- ASTFileSignature StoredSignature = ASTFileSignature::create (
3044- FirstSignatureByte, FirstSignatureByte + ASTFileSignature::size);
3045- Idx += ASTFileSignature::size;
3040+ off_t StoredSize = !IsImportingStdCXXModule ? (off_t )Record[Idx++] : 0 ;
3041+ time_t StoredModTime =
3042+ !IsImportingStdCXXModule ? (time_t )Record[Idx++] : 0 ;
3043+
3044+ ASTFileSignature StoredSignature;
3045+ if (!IsImportingStdCXXModule) {
3046+ auto FirstSignatureByte = Record.begin () + Idx;
3047+ StoredSignature = ASTFileSignature::create (
3048+ FirstSignatureByte, FirstSignatureByte + ASTFileSignature::size);
3049+ Idx += ASTFileSignature::size;
3050+ }
30463051
30473052 std::string ImportedName = ReadString (Record, Idx);
30483053 std::string ImportedFile;
@@ -3057,18 +3062,19 @@ ASTReader::ReadControlBlock(ModuleFile &F,
30573062 ImportedFile = PP.getHeaderSearchInfo ().getPrebuiltModuleFileName (
30583063 ImportedName, /* FileMapOnly*/ !IsImportingStdCXXModule);
30593064
3060- if (ImportedFile.empty ()) {
3061- // It is deprecated for C++20 Named modules to use the implicitly
3062- // paths.
3063- if (IsImportingStdCXXModule)
3064- Diag (clang::diag::warn_reading_std_cxx_module_by_implicit_paths)
3065- << ImportedName;
3066-
3067- // Use BaseDirectoryAsWritten to ensure we use the same path in the
3068- // ModuleCache as when writing.
3069- ImportedFile = ReadPath (BaseDirectoryAsWritten, Record, Idx);
3070- } else
3071- SkipPath (Record, Idx);
3065+ // For C++20 Modules, we won't record the path to the imported modules
3066+ // in the BMI
3067+ if (!IsImportingStdCXXModule) {
3068+ if (ImportedFile.empty ()) {
3069+ // Use BaseDirectoryAsWritten to ensure we use the same path in the
3070+ // ModuleCache as when writing.
3071+ ImportedFile = ReadPath (BaseDirectoryAsWritten, Record, Idx);
3072+ } else
3073+ SkipPath (Record, Idx);
3074+ } else if (ImportedFile.empty ()) {
3075+ Diag (clang::diag::err_failed_to_find_module_file) << ImportedName;
3076+ return Missing;
3077+ }
30723078
30733079 // If our client can't cope with us being out of date, we can't cope with
30743080 // our dependency being missing.
@@ -5584,8 +5590,23 @@ bool ASTReader::readASTFileControlBlock(
55845590 while (Idx < N) {
55855591 // Read information about the AST file.
55865592
5587- // Kind, StandardCXXModule, ImportLoc, Size, ModTime, Signature
5588- Idx += 1 + 1 + 1 + 1 + 1 + ASTFileSignature::size;
5593+ // Skip Kind
5594+ Idx++;
5595+ bool IsStandardCXXModule = Record[Idx++];
5596+
5597+ // Skip ImportLoc
5598+ Idx++;
5599+
5600+ // In C++20 Modules, we don't record the path to imported
5601+ // modules in the BMI files.
5602+ if (IsStandardCXXModule) {
5603+ std::string ModuleName = ReadString (Record, Idx);
5604+ Listener.visitImport (ModuleName, /* Filename=*/ " " );
5605+ continue ;
5606+ }
5607+
5608+ // Skip Size, ModTime and Signature
5609+ Idx += 1 + 1 + ASTFileSignature::size;
55895610 std::string ModuleName = ReadString (Record, Idx);
55905611 std::string Filename = ReadString (Record, Idx);
55915612 ResolveImportedPath (Filename, ModuleDir);
0 commit comments