Author: Jan Svoboda
Date: 2025-12-04T13:46:26-08:00
New Revision: 27c4520dc25747703567d68d3704c9b9cc644163

URL: 
https://github.com/llvm/llvm-project/commit/27c4520dc25747703567d68d3704c9b9cc644163
DIFF: 
https://github.com/llvm/llvm-project/commit/27c4520dc25747703567d68d3704c9b9cc644163.diff

LOG: [clang][deps] Simplify namespaces (#170742)

Added: 
    

Modified: 
    clang-tools-extra/clangd/ScanningProjectModules.cpp
    clang/include/clang/DependencyScanning/DependencyScanningUtils.h
    clang/include/clang/Tooling/DependencyScanningTool.h
    clang/lib/Tooling/DependencyScanningTool.cpp
    clang/tools/clang-scan-deps/ClangScanDeps.cpp
    clang/unittests/Tooling/DependencyScannerTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/ScanningProjectModules.cpp 
b/clang-tools-extra/clangd/ScanningProjectModules.cpp
index 6a21ad2920764..e1b6cbe1ae818 100644
--- a/clang-tools-extra/clangd/ScanningProjectModules.cpp
+++ b/clang-tools-extra/clangd/ScanningProjectModules.cpp
@@ -104,7 +104,7 @@ ModuleDependencyScanner::scan(PathRef FilePath,
   if (Mangler)
     Mangler(Cmd, FilePath);
 
-  using namespace clang::tooling::dependencies;
+  using namespace clang::tooling;
 
   llvm::SmallString<128> FilePathDir(FilePath);
   llvm::sys::path::remove_filename(FilePathDir);

diff  --git a/clang/include/clang/DependencyScanning/DependencyScanningUtils.h 
b/clang/include/clang/DependencyScanning/DependencyScanningUtils.h
index 80b73cefc942f..124f1eaa6cbba 100644
--- a/clang/include/clang/DependencyScanning/DependencyScanningUtils.h
+++ b/clang/include/clang/DependencyScanning/DependencyScanningUtils.h
@@ -21,7 +21,7 @@ namespace clang {
 namespace dependencies {
 
 /// Graph of modular dependencies.
-using ModuleDepsGraph = std::vector<clang::dependencies::ModuleDeps>;
+using ModuleDepsGraph = std::vector<ModuleDeps>;
 
 /// The full dependencies and module graph for a specific input.
 struct TranslationUnitDeps {
@@ -31,7 +31,7 @@ struct TranslationUnitDeps {
   /// The identifier of the C++20 module this translation unit exports.
   ///
   /// If the translation unit is not a module then \c ID.ModuleName is empty.
-  clang::dependencies::ModuleID ID;
+  ModuleID ID;
 
   /// A collection of absolute paths to files that this translation unit
   /// directly depends on, not including transitive dependencies.
@@ -39,14 +39,14 @@ struct TranslationUnitDeps {
 
   /// A collection of prebuilt modules this translation unit directly depends
   /// on, not including transitive dependencies.
-  std::vector<clang::dependencies::PrebuiltModuleDep> PrebuiltModuleDeps;
+  std::vector<PrebuiltModuleDep> PrebuiltModuleDeps;
 
   /// A list of modules this translation unit directly depends on, not 
including
   /// transitive dependencies.
   ///
   /// This may include modules with a 
diff erent context hash when it can be
   /// determined that the 
diff erences are benign for this compilation.
-  std::vector<clang::dependencies::ModuleID> ClangModuleDeps;
+  std::vector<ModuleID> ClangModuleDeps;
 
   /// A list of module names that are visible to this translation unit. This
   /// includes both direct and transitive module dependencies.
@@ -61,19 +61,18 @@ struct TranslationUnitDeps {
   /// FIXME: If we add support for multi-arch builds in clang-scan-deps, we
   /// should make the dependencies between commands explicit to enable parallel
   /// builds of each architecture.
-  std::vector<clang::dependencies::Command> Commands;
+  std::vector<Command> Commands;
 
   /// Deprecated driver command-line. This will be removed in a future version.
   std::vector<std::string> DriverCommandLine;
 };
 
-class FullDependencyConsumer : public clang::dependencies::DependencyConsumer {
+class FullDependencyConsumer : public DependencyConsumer {
 public:
-  FullDependencyConsumer(
-      const llvm::DenseSet<clang::dependencies::ModuleID> &AlreadySeen)
+  FullDependencyConsumer(const llvm::DenseSet<ModuleID> &AlreadySeen)
       : AlreadySeen(AlreadySeen) {}
 
-  void handleBuildCommand(clang::dependencies::Command Cmd) override {
+  void handleBuildCommand(Command Cmd) override {
     Commands.push_back(std::move(Cmd));
   }
 
@@ -83,16 +82,15 @@ class FullDependencyConsumer : public 
clang::dependencies::DependencyConsumer {
     Dependencies.push_back(std::string(File));
   }
 
-  void handlePrebuiltModuleDependency(
-      clang::dependencies::PrebuiltModuleDep PMD) override {
+  void handlePrebuiltModuleDependency(PrebuiltModuleDep PMD) override {
     PrebuiltModuleDeps.emplace_back(std::move(PMD));
   }
 
-  void handleModuleDependency(clang::dependencies::ModuleDeps MD) override {
+  void handleModuleDependency(ModuleDeps MD) override {
     ClangModuleDeps[MD.ID] = std::move(MD);
   }
 
-  void handleDirectModuleDependency(clang::dependencies::ModuleID ID) override 
{
+  void handleDirectModuleDependency(ModuleID ID) override {
     DirectModuleDeps.push_back(ID);
   }
 
@@ -105,8 +103,8 @@ class FullDependencyConsumer : public 
clang::dependencies::DependencyConsumer {
   }
 
   void handleProvidedAndRequiredStdCXXModules(
-      std::optional<clang::dependencies::P1689ModuleInfo> Provided,
-      std::vector<clang::dependencies::P1689ModuleInfo> Requires) override {
+      std::optional<P1689ModuleInfo> Provided,
+      std::vector<P1689ModuleInfo> Requires) override {
     ModuleName = Provided ? Provided->ModuleName : "";
     llvm::transform(Requires, std::back_inserter(NamedModuleDeps),
                     [](const auto &Module) { return Module.ModuleName; });
@@ -116,34 +114,29 @@ class FullDependencyConsumer : public 
clang::dependencies::DependencyConsumer {
 
 private:
   std::vector<std::string> Dependencies;
-  std::vector<clang::dependencies::PrebuiltModuleDep> PrebuiltModuleDeps;
-  llvm::MapVector<clang::dependencies::ModuleID,
-                  clang::dependencies::ModuleDeps>
-      ClangModuleDeps;
+  std::vector<PrebuiltModuleDep> PrebuiltModuleDeps;
+  llvm::MapVector<ModuleID, ModuleDeps> ClangModuleDeps;
   std::string ModuleName;
   std::vector<std::string> NamedModuleDeps;
-  std::vector<clang::dependencies::ModuleID> DirectModuleDeps;
+  std::vector<ModuleID> DirectModuleDeps;
   std::vector<std::string> VisibleModules;
-  std::vector<clang::dependencies::Command> Commands;
+  std::vector<Command> Commands;
   std::string ContextHash;
-  const llvm::DenseSet<clang::dependencies::ModuleID> &AlreadySeen;
+  const llvm::DenseSet<ModuleID> &AlreadySeen;
 };
 
 /// A callback to lookup module outputs for "-fmodule-file=", "-o" etc.
 using LookupModuleOutputCallback =
-    llvm::function_ref<std::string(const clang::dependencies::ModuleDeps &,
-                                   clang::dependencies::ModuleOutputKind)>;
+    llvm::function_ref<std::string(const ModuleDeps &, ModuleOutputKind)>;
 
 /// A simple dependency action controller that uses a callback. If no callback
 /// is provided, it is assumed that looking up module outputs is unreachable.
-class CallbackActionController
-    : public clang::dependencies::DependencyActionController {
+class CallbackActionController : public DependencyActionController {
 public:
   virtual ~CallbackActionController();
 
-  static std::string
-  lookupUnreachableModuleOutput(const clang::dependencies::ModuleDeps &MD,
-                                clang::dependencies::ModuleOutputKind Kind) {
+  static std::string lookupUnreachableModuleOutput(const ModuleDeps &MD,
+                                                   ModuleOutputKind Kind) {
     llvm::report_fatal_error("unexpected call to lookupModuleOutput");
   };
 
@@ -154,9 +147,8 @@ class CallbackActionController
     }
   }
 
-  std::string
-  lookupModuleOutput(const clang::dependencies::ModuleDeps &MD,
-                     clang::dependencies::ModuleOutputKind Kind) override {
+  std::string lookupModuleOutput(const ModuleDeps &MD,
+                                 ModuleOutputKind Kind) override {
     return LookupModuleOutput(MD, Kind);
   }
 

diff  --git a/clang/include/clang/Tooling/DependencyScanningTool.h 
b/clang/include/clang/Tooling/DependencyScanningTool.h
index 0ac142a3fc673..9d9c734df6c0d 100644
--- a/clang/include/clang/Tooling/DependencyScanningTool.h
+++ b/clang/include/clang/Tooling/DependencyScanningTool.h
@@ -13,23 +13,19 @@
 #include "clang/DependencyScanning/DependencyScanningUtils.h"
 #include "clang/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/DependencyScanning/ModuleDepCollector.h"
-#include "clang/Tooling/JSONCompilationDatabase.h"
+#include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/MapVector.h"
-#include "llvm/ADT/STLExtras.h"
-#include <functional>
 #include <optional>
 #include <string>
 #include <vector>
 
 namespace clang {
 namespace tooling {
-namespace dependencies {
 
 struct P1689Rule {
   std::string PrimaryOutput;
-  std::optional<clang::dependencies::P1689ModuleInfo> Provides;
-  std::vector<clang::dependencies::P1689ModuleInfo> Requires;
+  std::optional<dependencies::P1689ModuleInfo> Provides;
+  std::vector<dependencies::P1689ModuleInfo> Requires;
 };
 
 /// The high-level implementation of the dependency discovery tool that runs on
@@ -40,10 +36,9 @@ class DependencyScanningTool {
   ///
   /// @param Service  The parent service. Must outlive the tool.
   /// @param FS The filesystem for the tool to use. Defaults to the physical 
FS.
-  DependencyScanningTool(
-      clang::dependencies::DependencyScanningService &Service,
-      llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS =
-          llvm::vfs::createPhysicalFileSystem());
+  DependencyScanningTool(dependencies::DependencyScanningService &Service,
+                         llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS =
+                             llvm::vfs::createPhysicalFileSystem());
 
   /// Print out the dependency information into a string using the dependency
   /// file format that is specified in the options (-MD is the default) and
@@ -66,12 +61,11 @@ class DependencyScanningTool {
   /// \returns A \c StringError with the diagnostic output if clang errors
   /// occurred, P1689 dependency format rules otherwise.
   llvm::Expected<P1689Rule>
-  getP1689ModuleDependencyFile(const clang::tooling::CompileCommand &Command,
-                               StringRef CWD, std::string &MakeformatOutput,
+  getP1689ModuleDependencyFile(const CompileCommand &Command, StringRef CWD,
+                               std::string &MakeformatOutput,
                                std::string &MakeformatOutputPath);
   llvm::Expected<P1689Rule>
-  getP1689ModuleDependencyFile(const clang::tooling::CompileCommand &Command,
-                               StringRef CWD) {
+  getP1689ModuleDependencyFile(const CompileCommand &Command, StringRef CWD) {
     std::string MakeformatOutput;
     std::string MakeformatOutputPath;
 
@@ -96,11 +90,11 @@ class DependencyScanningTool {
   ///
   /// \returns a \c StringError with the diagnostic output if clang errors
   /// occurred, \c TranslationUnitDeps otherwise.
-  llvm::Expected<clang::dependencies::TranslationUnitDeps>
+  llvm::Expected<dependencies::TranslationUnitDeps>
   getTranslationUnitDependencies(
       const std::vector<std::string> &CommandLine, StringRef CWD,
-      const llvm::DenseSet<clang::dependencies::ModuleID> &AlreadySeen,
-      clang::dependencies::LookupModuleOutputCallback LookupModuleOutput,
+      const llvm::DenseSet<dependencies::ModuleID> &AlreadySeen,
+      dependencies::LookupModuleOutputCallback LookupModuleOutput,
       std::optional<llvm::MemoryBufferRef> TUBuffer = std::nullopt);
 
   /// Given a compilation context specified via the Clang driver command-line,
@@ -109,12 +103,10 @@ class DependencyScanningTool {
   /// TODO: this method should be removed as soon as Swift and our C-APIs adopt
   /// CompilerInstanceWithContext. We are keeping it here so that it is easier
   /// to coordinate with Swift and C-API changes.
-  llvm::Expected<clang::dependencies::TranslationUnitDeps>
-  getModuleDependencies(
+  llvm::Expected<dependencies::TranslationUnitDeps> getModuleDependencies(
       StringRef ModuleName, const std::vector<std::string> &CommandLine,
-      StringRef CWD,
-      const llvm::DenseSet<clang::dependencies::ModuleID> &AlreadySeen,
-      clang::dependencies::LookupModuleOutputCallback LookupModuleOutput);
+      StringRef CWD, const llvm::DenseSet<dependencies::ModuleID> &AlreadySeen,
+      dependencies::LookupModuleOutputCallback LookupModuleOutput);
 
   /// The following three methods provide a new interface to perform
   /// by name dependency scan. The new interface's intention is to improve
@@ -144,11 +136,11 @@ class DependencyScanningTool {
   ///                           arguments for dependencies.
   /// @return An instance of \c TranslationUnitDeps if the scan is successful.
   ///         Otherwise it returns an error.
-  llvm::Expected<clang::dependencies::TranslationUnitDeps>
+  llvm::Expected<dependencies::TranslationUnitDeps>
   computeDependenciesByNameWithContext(
       StringRef ModuleName,
-      const llvm::DenseSet<clang::dependencies::ModuleID> &AlreadySeen,
-      clang::dependencies::LookupModuleOutputCallback LookupModuleOutput);
+      const llvm::DenseSet<dependencies::ModuleID> &AlreadySeen,
+      dependencies::LookupModuleOutputCallback LookupModuleOutput);
 
   /// @brief This method finializes the compiler instance. It finalizes the
   ///        diagnostics and deletes the compiler instance. Call this method
@@ -159,12 +151,11 @@ class DependencyScanningTool {
   llvm::vfs::FileSystem &getWorkerVFS() const { return Worker.getVFS(); }
 
 private:
-  clang::dependencies::DependencyScanningWorker Worker;
-  std::unique_ptr<clang::dependencies::TextDiagnosticsPrinterWithOutput>
+  dependencies::DependencyScanningWorker Worker;
+  std::unique_ptr<dependencies::TextDiagnosticsPrinterWithOutput>
       DiagPrinterWithOS;
 };
 
-} // end namespace dependencies
 } // end namespace tooling
 } // end namespace clang
 

diff  --git a/clang/lib/Tooling/DependencyScanningTool.cpp 
b/clang/lib/Tooling/DependencyScanningTool.cpp
index e037420f4fcf2..1c3a35d1db3a3 100644
--- a/clang/lib/Tooling/DependencyScanningTool.cpp
+++ b/clang/lib/Tooling/DependencyScanningTool.cpp
@@ -12,8 +12,7 @@
 
 using namespace clang;
 using namespace tooling;
-using namespace clang::dependencies;
-using namespace clang::tooling::dependencies;
+using namespace dependencies;
 
 DependencyScanningTool::DependencyScanningTool(
     DependencyScanningService &Service,

diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 6a2acb0d4f20e..07157ae2dc06a 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -41,8 +41,7 @@
 
 using namespace clang;
 using namespace tooling;
-using namespace clang::dependencies;
-using namespace clang::tooling::dependencies;
+using namespace dependencies;
 
 namespace {
 

diff  --git a/clang/unittests/Tooling/DependencyScannerTest.cpp 
b/clang/unittests/Tooling/DependencyScannerTest.cpp
index 9fcd0545b17fa..da47252b37097 100644
--- a/clang/unittests/Tooling/DependencyScannerTest.cpp
+++ b/clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -29,8 +29,7 @@
 
 using namespace clang;
 using namespace tooling;
-using namespace clang::dependencies;
-using namespace tooling::dependencies;
+using namespace dependencies;
 
 namespace {
 


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to