================
@@ -3158,6 +3158,49 @@ ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
}
}
+ASTReader::RelocationCheckResult
+ASTReader::checkIfModuleRelocated(ModuleFile &F, bool DirectoryCheck) {
+ // Don't emit module relocation errors if we have -fno-validate-pch.
+ const bool IgnoreError =
+ bool(PP.getPreprocessorOpts().DisablePCHOrModuleValidation &
+ DisableValidationForModuleKind::Module);
+
+ if (!PP.getPreprocessorOpts().ModulesCheckRelocated)
+ return {std::nullopt, IgnoreError};
+
+ const bool IsImplicitModule = F.Kind == MK_ImplicitModule;
+
+ if (!DirectoryCheck &&
+ (!IsImplicitModule || ModuleMgr.begin()->Kind == MK_MainFile))
+ return {std::nullopt, IgnoreError};
+
+ const HeaderSearchOptions &HSOpts =
+ PP.getHeaderSearchInfo().getHeaderSearchOpts();
+
+ // When only validating modules once per build session,
+ // Skip check if the timestamp is up to date or module was built in same
build
+ // session.
+ if (HSOpts.ModulesValidateOncePerBuildSession && IsImplicitModule) {
+ if (F.InputFilesValidationTimestamp >= HSOpts.BuildSessionTimestamp)
+ return {std::nullopt, IgnoreError};
+ if (static_cast<uint64_t>(F.File.getModificationTime()) >=
+ HSOpts.BuildSessionTimestamp)
+ return {std::nullopt, IgnoreError};
----------------
cyndyishida wrote:
>Maybe you're observing the newly-built PCM being read before the timestamp is
>written?
Yea I think thats whats happening. I'd prefer to keep this check here and
refactor the `ModuleManager` through the `ModuleCache` service to provide a
service for this check in a future patch so we don't explicitly need to check
for these kinds of things through the `ModuleFile` directly. My preference is
that I believe this check helps with avoiding cost during clean builds.
https://github.com/llvm/llvm-project/pull/181836
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits