diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 9c31f9db14679..bdf476cf128a3 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -4507,18 +4507,16 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, } } - if (PP.getHeaderSearchInfo() - .getHeaderSearchOpts() - .ModulesValidateOncePerBuildSession) { + HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts(); + if (HSOpts.ModulesValidateOncePerBuildSession) { // Now we are certain that the module and all modules it depends on are - // up to date. Create or update timestamp files for modules that are - // located in the module cache (not for PCH files that could be anywhere - // in the filesystem). + // up-to-date. For implicitly-built module files, ensure the corresponding + // timestamp files are up-to-date in this build session. for (unsigned I = 0, N = Loaded.size(); I != N; ++I) { ImportedModule &M = Loaded[I]; - if (M.Mod->Kind == MK_ImplicitModule) { + if (M.Mod->Kind == MK_ImplicitModule && + M.Mod->InputFilesValidationTimestamp < HSOpts.BuildSessionTimestamp) updateModuleTimestamp(*M.Mod); - } } }