[clang-tools-extra] d68059b - [NFC] [clangd] [Modules] Change the argument type of IsModuleFileUpToDate to reference
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 30 00:16:35 PDT 2024
Author: Chuanqi Xu
Date: 2024-08-30T15:15:24+08:00
New Revision: d68059bcfd1cc27e378c43b1f16019c5baccb06d
URL: https://github.com/llvm/llvm-project/commit/d68059bcfd1cc27e378c43b1f16019c5baccb06d
DIFF: https://github.com/llvm/llvm-project/commit/d68059bcfd1cc27e378c43b1f16019c5baccb06d.diff
LOG: [NFC] [clangd] [Modules] Change the argument type of IsModuleFileUpToDate to reference
It is better to use references instead of pointers as the argument type
of IsModuleFileUpToDate. Since the PrerequisiteModules is always
expected to exist.
Added:
Modified:
clang-tools-extra/clangd/ModulesBuilder.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/ModulesBuilder.cpp b/clang-tools-extra/clangd/ModulesBuilder.cpp
index dd00adc6f6c8d2..1eeff468ef1236 100644
--- a/clang-tools-extra/clangd/ModulesBuilder.cpp
+++ b/clang-tools-extra/clangd/ModulesBuilder.cpp
@@ -129,13 +129,12 @@ struct ModuleFile {
bool IsModuleFileUpToDate(
PathRef ModuleFilePath,
- const PrerequisiteModules *RequisiteModules) {
+ const PrerequisiteModules &RequisiteModules) {
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
CompilerInstance::createDiagnostics(new DiagnosticOptions());
auto HSOpts = std::make_shared<HeaderSearchOptions>();
- if (RequisiteModules)
- RequisiteModules->adjustHeaderSearchOptions(*HSOpts);
+ RequisiteModules.adjustHeaderSearchOptions(*HSOpts);
HSOpts->ForceCheckCXX20ModulesInputFiles = true;
HSOpts->ValidateASTInputFilesContent = true;
@@ -168,8 +167,8 @@ IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
bool IsModuleFilesUpToDate(
llvm::SmallVector<PathRef> ModuleFilePaths,
- const PrerequisiteModules *RequisiteModules = nullptr) {
- return llvm::all_of(ModuleFilePaths, [RequisiteModules](auto ModuleFilePath) {
+ const PrerequisiteModules &RequisiteModules) {
+ return llvm::all_of(ModuleFilePaths, [&RequisiteModules](auto ModuleFilePath) {
return IsModuleFileUpToDate(ModuleFilePath, RequisiteModules);
});
}
@@ -348,7 +347,7 @@ bool StandalonePrerequisiteModules::canReuse(
SmallVector<StringRef> BMIPaths;
for (auto &MF : RequiredModules)
BMIPaths.push_back(MF.ModuleFilePath);
- return IsModuleFilesUpToDate(BMIPaths, this);
+ return IsModuleFilesUpToDate(BMIPaths, *this);
}
} // namespace clangd
More information about the cfe-commits
mailing list