[clang-tools-extra] [clangd] [Modules] Use ASTReader directly in IsModuleFileUpToDate (PR #113879)
kadir çetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 28 05:21:36 PDT 2024
================
@@ -127,50 +128,64 @@ struct ModuleFile {
std::string ModuleFilePath;
};
-bool IsModuleFileUpToDate(
- PathRef ModuleFilePath,
- const PrerequisiteModules &RequisiteModules) {
-IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
- CompilerInstance::createDiagnostics(new DiagnosticOptions());
-
+bool IsModuleFileUpToDate(PathRef ModuleFilePath,
+ const PrerequisiteModules &RequisiteModules,
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
auto HSOpts = std::make_shared<HeaderSearchOptions>();
RequisiteModules.adjustHeaderSearchOptions(*HSOpts);
HSOpts->ForceCheckCXX20ModulesInputFiles = true;
HSOpts->ValidateASTInputFilesContent = true;
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
+ CompilerInstance::createDiagnostics(new DiagnosticOptions());
+
+ LangOptions LangOpts;
+ LangOpts.SkipODRCheckInGMF = true;
+
+ FileManager FileMgr(FileSystemOptions(), VFS);
+
+ SourceManager SourceMgr(*Diags, FileMgr);
+
+ HeaderSearch HeaderInfo(HSOpts, SourceMgr, *Diags, LangOpts,
+ /*Target=*/nullptr);
+
+ TrivialModuleLoader ModuleLoader;
+ Preprocessor PP(std::make_shared<PreprocessorOptions>(), *Diags, LangOpts,
+ SourceMgr, HeaderInfo, ModuleLoader);
+
+ IntrusiveRefCntPtr<InMemoryModuleCache> ModuleCache = new InMemoryModuleCache;
----------------
kadircet wrote:
no need to allocate on the heap, you can just have a `InMemoryModuleCache ModuleCache;`
https://github.com/llvm/llvm-project/pull/113879
More information about the cfe-commits
mailing list