[clang] Revert "[clang][Dependency Scanning] Report What a Module Exports during Scanning (#137421)" (PR #140820)

2025-05-29 Thread Qiongsi Wu via cfe-commits

https://github.com/qiongsiwu closed 
https://github.com/llvm/llvm-project/pull/140820
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[clang][Dependency Scanning] Report What a Module Exports during Scanning (#137421)" (PR #140820)

2025-05-20 Thread Cyndy Ishida via cfe-commits

https://github.com/cyndyishida approved this pull request.


https://github.com/llvm/llvm-project/pull/140820
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[clang][Dependency Scanning] Report What a Module Exports during Scanning (#137421)" (PR #140820)

2025-05-20 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Qiongsi Wu (qiongsiwu)


Changes

This reverts commit ea1bfbf3f6399b7d2d840722f0e87542d00f6a35.

The commit did not solve the fundamental issue we need to handle and is no 
longer necessary. 

rdar://144794793

---
Full diff: https://github.com/llvm/llvm-project/pull/140820.diff


5 Files Affected:

- (modified) 
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h (+8-22) 
- (modified) clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
(+27-38) 
- (removed) clang/test/ClangScanDeps/export.c (-133) 
- (modified) clang/test/ClangScanDeps/optimize-vfs-pch.m (+1-2) 
- (modified) clang/tools/clang-scan-deps/ClangScanDeps.cpp (+5-21) 


``diff
diff --git 
a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h 
b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index 06717a64c9a78..d2d0d56e5212c 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -178,25 +178,12 @@ struct ModuleDeps {
   /// on, not including transitive dependencies.
   std::vector PrebuiltModuleDeps;
 
-  /// This struct contains information about a single dependency.
-  struct DepInfo {
-/// Identifies the dependency.
-ModuleID ID;
-
-/// Indicates if the module that has this dependency exports it or not.
-bool Exported = false;
-
-bool operator<(const DepInfo &Other) const {
-  return std::tie(ID, Exported) < std::tie(Other.ID, Other.Exported);
-}
-  };
-
-  /// A list of DepsInfo containing information about modules this module
-  /// directly depends on, not including transitive dependencies.
+  /// A list of module identifiers this module directly depends on, not
+  /// including transitive dependencies.
   ///
   /// This may include modules with a different context hash when it can be
   /// determined that the differences are benign for this compilation.
-  std::vector ClangModuleDeps;
+  std::vector ClangModuleDeps;
 
   /// The set of libraries or frameworks to link against when
   /// an entity from this module is used.
@@ -283,8 +270,7 @@ class ModuleDepCollectorPP final : public PPCallbacks {
   llvm::DenseSet &AddedModules);
 
   /// Add discovered module dependency for the given module.
-  void addOneModuleDep(const Module *M, bool Exported, const ModuleID ID,
-   ModuleDeps &MD);
+  void addOneModuleDep(const Module *M, const ModuleID ID, ModuleDeps &MD);
 };
 
 /// Collects modular and non-modular dependencies of the main file by attaching
@@ -366,16 +352,16 @@ class ModuleDepCollector final : public 
DependencyCollector {
 
   /// Collect module map files for given modules.
   llvm::DenseSet
-  collectModuleMapFiles(ArrayRef ClangModuleDeps) const;
+  collectModuleMapFiles(ArrayRef ClangModuleDeps) const;
 
   /// Add module map files to the invocation, if needed.
   void addModuleMapFiles(CompilerInvocation &CI,
- ArrayRef ClangModuleDeps) const;
+ ArrayRef ClangModuleDeps) const;
   /// Add module files (pcm) to the invocation, if needed.
   void addModuleFiles(CompilerInvocation &CI,
-  ArrayRef ClangModuleDeps) const;
+  ArrayRef ClangModuleDeps) const;
   void addModuleFiles(CowCompilerInvocation &CI,
-  ArrayRef ClangModuleDeps) const;
+  ArrayRef ClangModuleDeps) const;
 
   /// Add paths that require looking up outputs to the given dependencies.
   void addOutputPaths(CowCompilerInvocation &CI, ModuleDeps &Deps);
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 45901cbcedcb7..eb674246e2d51 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -389,10 +389,10 @@ 
ModuleDepCollector::getInvocationAdjustedForModuleBuildWithoutOutputs(
 }
 
 llvm::DenseSet ModuleDepCollector::collectModuleMapFiles(
-ArrayRef ClangModuleDeps) const {
+ArrayRef ClangModuleDeps) const {
   llvm::DenseSet ModuleMapFiles;
-  for (const auto &Info : ClangModuleDeps) {
-ModuleDeps *MD = ModuleDepsByID.lookup(Info.ID);
+  for (const ModuleID &MID : ClangModuleDeps) {
+ModuleDeps *MD = ModuleDepsByID.lookup(MID);
 assert(MD && "Inconsistent dependency info");
 // TODO: Track ClangModuleMapFile as `FileEntryRef`.
 auto FE = ScanInstance.getFileManager().getOptionalFileRef(
@@ -404,23 +404,21 @@ llvm::DenseSet 
ModuleDepCollector::collectModuleMapFiles(
 }
 
 void ModuleDepCollector::addModuleMapFiles(
-CompilerInvocation &CI,
-ArrayRef ClangModuleDeps) const {
+CompilerInvocation &CI, ArrayRef ClangModuleDeps) const {
   if (Service.shouldEagerLoadModules())
 return; // Only pcm is needed for eager load.
 
-

[clang] Revert "[clang][Dependency Scanning] Report What a Module Exports during Scanning (#137421)" (PR #140820)

2025-05-20 Thread Qiongsi Wu via cfe-commits

https://github.com/qiongsiwu created 
https://github.com/llvm/llvm-project/pull/140820

This reverts commit ea1bfbf3f6399b7d2d840722f0e87542d00f6a35.

The commit did not solve the fundamental issue we need to handle and is no 
longer necessary. 

rdar://144794793

>From 22c4747a1232756c672691a14ae2b72caa92b294 Mon Sep 17 00:00:00 2001
From: Qiongsi Wu 
Date: Tue, 20 May 2025 16:39:45 -0700
Subject: [PATCH] Revert "[clang][Dependency Scanning] Report What a Module
 Exports during Scanning (#137421)"

This reverts commit ea1bfbf3f6399b7d2d840722f0e87542d00f6a35.
---
 .../DependencyScanning/ModuleDepCollector.h   |  30 ++--
 .../DependencyScanning/ModuleDepCollector.cpp |  65 -
 clang/test/ClangScanDeps/export.c | 133 --
 clang/test/ClangScanDeps/optimize-vfs-pch.m   |   3 +-
 clang/tools/clang-scan-deps/ClangScanDeps.cpp |  26 +---
 5 files changed, 41 insertions(+), 216 deletions(-)
 delete mode 100644 clang/test/ClangScanDeps/export.c

diff --git 
a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h 
b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index 06717a64c9a78..d2d0d56e5212c 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -178,25 +178,12 @@ struct ModuleDeps {
   /// on, not including transitive dependencies.
   std::vector PrebuiltModuleDeps;
 
-  /// This struct contains information about a single dependency.
-  struct DepInfo {
-/// Identifies the dependency.
-ModuleID ID;
-
-/// Indicates if the module that has this dependency exports it or not.
-bool Exported = false;
-
-bool operator<(const DepInfo &Other) const {
-  return std::tie(ID, Exported) < std::tie(Other.ID, Other.Exported);
-}
-  };
-
-  /// A list of DepsInfo containing information about modules this module
-  /// directly depends on, not including transitive dependencies.
+  /// A list of module identifiers this module directly depends on, not
+  /// including transitive dependencies.
   ///
   /// This may include modules with a different context hash when it can be
   /// determined that the differences are benign for this compilation.
-  std::vector ClangModuleDeps;
+  std::vector ClangModuleDeps;
 
   /// The set of libraries or frameworks to link against when
   /// an entity from this module is used.
@@ -283,8 +270,7 @@ class ModuleDepCollectorPP final : public PPCallbacks {
   llvm::DenseSet &AddedModules);
 
   /// Add discovered module dependency for the given module.
-  void addOneModuleDep(const Module *M, bool Exported, const ModuleID ID,
-   ModuleDeps &MD);
+  void addOneModuleDep(const Module *M, const ModuleID ID, ModuleDeps &MD);
 };
 
 /// Collects modular and non-modular dependencies of the main file by attaching
@@ -366,16 +352,16 @@ class ModuleDepCollector final : public 
DependencyCollector {
 
   /// Collect module map files for given modules.
   llvm::DenseSet
-  collectModuleMapFiles(ArrayRef ClangModuleDeps) const;
+  collectModuleMapFiles(ArrayRef ClangModuleDeps) const;
 
   /// Add module map files to the invocation, if needed.
   void addModuleMapFiles(CompilerInvocation &CI,
- ArrayRef ClangModuleDeps) const;
+ ArrayRef ClangModuleDeps) const;
   /// Add module files (pcm) to the invocation, if needed.
   void addModuleFiles(CompilerInvocation &CI,
-  ArrayRef ClangModuleDeps) const;
+  ArrayRef ClangModuleDeps) const;
   void addModuleFiles(CowCompilerInvocation &CI,
-  ArrayRef ClangModuleDeps) const;
+  ArrayRef ClangModuleDeps) const;
 
   /// Add paths that require looking up outputs to the given dependencies.
   void addOutputPaths(CowCompilerInvocation &CI, ModuleDeps &Deps);
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 45901cbcedcb7..eb674246e2d51 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -389,10 +389,10 @@ 
ModuleDepCollector::getInvocationAdjustedForModuleBuildWithoutOutputs(
 }
 
 llvm::DenseSet ModuleDepCollector::collectModuleMapFiles(
-ArrayRef ClangModuleDeps) const {
+ArrayRef ClangModuleDeps) const {
   llvm::DenseSet ModuleMapFiles;
-  for (const auto &Info : ClangModuleDeps) {
-ModuleDeps *MD = ModuleDepsByID.lookup(Info.ID);
+  for (const ModuleID &MID : ClangModuleDeps) {
+ModuleDeps *MD = ModuleDepsByID.lookup(MID);
 assert(MD && "Inconsistent dependency info");
 // TODO: Track ClangModuleMapFile as `FileEntryRef`.
 auto FE = ScanInstance.getFileManager().getOptionalFileRef(
@@ -404,23 +404,21 @@ llvm::DenseSet 
ModuleDepCollector::collectModuleMapFiles(
 }
 
 void ModuleDepColle