[clang-tools-extra] [NFC] [clangd] [C++20] [Modules] Rename and move scanningProjectModules (PR #193128)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 20 19:18:59 PDT 2026


https://github.com/ChuanqiXu9 updated https://github.com/llvm/llvm-project/pull/193128

>From 84810245aaef9c350087779fb93cfb833f30210a Mon Sep 17 00:00:00 2001
From: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
Date: Mon, 20 Apr 2026 19:03:23 +0800
Subject: [PATCH] [NFC] [clangd] [C++20] [Modules] Rename and move
 scanningProjectModules

I am going to add more stuff to ProjectModules and the current structure
and the file name scanningProjectModules may be confusing.

This NFC patch changes that.
---
 clang-tools-extra/clangd/CMakeLists.txt       |  2 +-
 .../clangd/GlobalCompilationDatabase.cpp      |  3 +--
 ...gProjectModules.cpp => ProjectModules.cpp} |  5 ++--
 clang-tools-extra/clangd/ProjectModules.h     |  5 ++++
 .../clangd/ScanningProjectModules.h           | 26 -------------------
 .../unittests/PrerequisiteModulesTest.cpp     |  5 ++--
 6 files changed, 13 insertions(+), 33 deletions(-)
 rename clang-tools-extra/clangd/{ScanningProjectModules.cpp => ProjectModules.cpp} (98%)
 delete mode 100644 clang-tools-extra/clangd/ScanningProjectModules.h

diff --git a/clang-tools-extra/clangd/CMakeLists.txt b/clang-tools-extra/clangd/CMakeLists.txt
index a0e8036038d30..890562dde1792 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -98,12 +98,12 @@ add_clang_library(clangDaemon STATIC
   JSONTransport.cpp
   ModulesBuilder.cpp
   PathMapping.cpp
+  ProjectModules.cpp
   Protocol.cpp
   Quality.cpp
   ParsedAST.cpp
   Preamble.cpp
   RIFF.cpp
-  ScanningProjectModules.cpp
   Selection.cpp
   SemanticHighlighting.cpp
   SemanticSelection.cpp
diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index a1d9135111ca8..adb771ecbbaad 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -10,7 +10,6 @@
 #include "Config.h"
 #include "FS.h"
 #include "ProjectModules.h"
-#include "ScanningProjectModules.h"
 #include "SourceCode.h"
 #include "support/Logger.h"
 #include "support/Path.h"
@@ -772,7 +771,7 @@ DirectoryBasedGlobalCompilationDatabase::getProjectModules(PathRef File) const {
   if (!Res)
     return {};
 
-  return scanningProjectModules(Res->CDB, Opts.TFS);
+  return clang::clangd::getProjectModules(Res->CDB, Opts.TFS);
 }
 
 OverlayCDB::OverlayCDB(const GlobalCompilationDatabase *Base,
diff --git a/clang-tools-extra/clangd/ScanningProjectModules.cpp b/clang-tools-extra/clangd/ProjectModules.cpp
similarity index 98%
rename from clang-tools-extra/clangd/ScanningProjectModules.cpp
rename to clang-tools-extra/clangd/ProjectModules.cpp
index d9863085d3827..67b2a3bd9096a 100644
--- a/clang-tools-extra/clangd/ScanningProjectModules.cpp
+++ b/clang-tools-extra/clangd/ProjectModules.cpp
@@ -1,4 +1,5 @@
-//===------------------ ProjectModules.h -------------------------*- C++-*-===//
+//===------------------ ProjectModules.cpp -------------------------*-
+//C++-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -231,7 +232,7 @@ class ScanningAllProjectModules : public ProjectModules {
   CommandMangler Mangler;
 };
 
-std::unique_ptr<ProjectModules> scanningProjectModules(
+std::unique_ptr<ProjectModules> getProjectModules(
     std::shared_ptr<const clang::tooling::CompilationDatabase> CDB,
     const ThreadsafeFS &TFS) {
   return std::make_unique<ScanningAllProjectModules>(CDB, TFS);
diff --git a/clang-tools-extra/clangd/ProjectModules.h b/clang-tools-extra/clangd/ProjectModules.h
index 41812674f12f4..057e1b83764b7 100644
--- a/clang-tools-extra/clangd/ProjectModules.h
+++ b/clang-tools-extra/clangd/ProjectModules.h
@@ -51,6 +51,11 @@ class ProjectModules {
   virtual ~ProjectModules() = default;
 };
 
+/// Providing modules information for the project by scanning every file.
+std::unique_ptr<ProjectModules> getProjectModules(
+    std::shared_ptr<const clang::tooling::CompilationDatabase> CDB,
+    const ThreadsafeFS &TFS);
+
 } // namespace clangd
 } // namespace clang
 
diff --git a/clang-tools-extra/clangd/ScanningProjectModules.h b/clang-tools-extra/clangd/ScanningProjectModules.h
deleted file mode 100644
index 75fc7dbcebce5..0000000000000
--- a/clang-tools-extra/clangd/ScanningProjectModules.h
+++ /dev/null
@@ -1,26 +0,0 @@
-//===------------ ScanningProjectModules.h -----------------------*- C++-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SCANNINGPROJECTMODULES_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SCANNINGPROJECTMODULES_H
-
-#include "ProjectModules.h"
-#include "clang/Tooling/CompilationDatabase.h"
-
-namespace clang {
-namespace clangd {
-
-/// Providing modules information for the project by scanning every file.
-std::unique_ptr<ProjectModules> scanningProjectModules(
-    std::shared_ptr<const clang::tooling::CompilationDatabase> CDB,
-    const ThreadsafeFS &TFS);
-
-} // namespace clangd
-} // namespace clang
-
-#endif
diff --git a/clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp b/clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp
index 1a5d805d730f6..6a4250cb5389a 100644
--- a/clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp
+++ b/clang-tools-extra/clangd/unittests/PrerequisiteModulesTest.cpp
@@ -15,7 +15,7 @@
 #include "CodeComplete.h"
 #include "Compiler.h"
 #include "ModulesBuilder.h"
-#include "ScanningProjectModules.h"
+#include "ProjectModules.h"
 #include "TestTU.h"
 #include "support/Path.h"
 #include "support/ThreadsafeFS.h"
@@ -73,7 +73,8 @@ class MockDirectoryCompilationDatabase : public MockCompilationDatabase {
 
   std::unique_ptr<ProjectModules> getProjectModules(PathRef) const override {
     return std::make_unique<GlobalScanningCounterProjectModules>(
-        scanningProjectModules(MockedCDBPtr, TFS), GlobalScanningCount);
+        clang::clangd::getProjectModules(MockedCDBPtr, TFS),
+        GlobalScanningCount);
   }
 
   unsigned getGlobalScanningCount() const { return GlobalScanningCount; }



More information about the cfe-commits mailing list