[clang-tools-extra] [clangd] [Modules] Use ASTReader directly in IsModuleFileUpToDate (PR #113879)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 29 19:35:30 PDT 2024
================
@@ -127,50 +128,65 @@ 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;
+ clang::clangd::IgnoreDiagnostics IgnoreDiags;
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
+ CompilerInstance::createDiagnostics(new DiagnosticOptions, &D, /*ShouldOwnClient=*/false);
+
+ 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;
PCHContainerOperations PCHOperations;
- std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromASTFile(
- ModuleFilePath.str(), PCHOperations.getRawReader(), ASTUnit::LoadASTOnly,
- Diags, FileSystemOptions(), std::move(HSOpts));
+ ASTReader Reader(PP, *ModuleCache, /*ASTContext=*/nullptr,
+ PCHOperations.getRawReader(), {});
- if (!Unit)
- return false;
+ Reader.setListener(std::make_unique<PPIntializer>(PP));
----------------
ChuanqiXu9 wrote:
My bad. It was not updated. I guess I had a typo when verify it by typing `check-clangd` into `check-clang` : (
https://github.com/llvm/llvm-project/pull/113879
More information about the cfe-commits
mailing list