[clang] [clang][deps][modules] Allocate input file paths lazily (PR #114457)
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 31 13:53:50 PDT 2024
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/114457
>From 3be61a8f1eecdc64c0df5d6635f5bf7809c31de4 Mon Sep 17 00:00:00 2001
From: Jan Svoboda <jan_svoboda at apple.com>
Date: Tue, 22 Oct 2024 09:41:18 -0700
Subject: [PATCH 1/2] [clang][deps][modules] Reduce allocations of input file
paths
---
.../include/clang/Serialization/ModuleFile.h | 9 +++-
.../DependencyScanning/ModuleDepCollector.h | 16 ++++++--
clang/lib/Serialization/ASTReader.cpp | 41 ++++++++-----------
.../DependencyScanning/ModuleDepCollector.cpp | 41 +++++++++++--------
clang/test/ClangScanDeps/diagnostics.c | 2 +-
.../header-search-pruning-transitive.c | 18 ++++----
clang/test/ClangScanDeps/link-libraries.c | 12 +++---
.../test/ClangScanDeps/modules-context-hash.c | 8 ++--
clang/test/ClangScanDeps/modules-dep-args.c | 4 +-
.../ClangScanDeps/modules-extern-submodule.c | 4 +-
.../ClangScanDeps/modules-extern-unrelated.m | 14 +++----
.../modules-file-path-isolation.c | 4 +-
.../modules-fmodule-name-no-module-built.m | 8 ++--
.../ClangScanDeps/modules-full-by-mod-name.c | 8 ++--
clang/test/ClangScanDeps/modules-full.cpp | 12 +++---
.../modules-implicit-dot-private.m | 4 +-
.../modules-incomplete-umbrella.c | 14 +++----
clang/test/ClangScanDeps/modules-inferred.m | 4 +-
.../modules-no-undeclared-includes.c | 4 +-
.../modules-pch-common-submodule.c | 8 ++--
.../modules-pch-common-via-submodule.c | 8 ++--
clang/test/ClangScanDeps/modules-pch.c | 20 ++++-----
.../ClangScanDeps/modules-priv-fw-from-pub.m | 8 ++--
.../test/ClangScanDeps/modules-redefinition.m | 2 +-
.../ClangScanDeps/modules-symlink-dir-vfs.c | 4 +-
clang/test/ClangScanDeps/modules-transitive.c | 4 +-
clang/test/ClangScanDeps/optimize-vfs.m | 12 +++---
clang/test/ClangScanDeps/removed-args.c | 8 ++--
clang/tools/clang-scan-deps/ClangScanDeps.cpp | 11 ++---
29 files changed, 161 insertions(+), 151 deletions(-)
diff --git a/clang/include/clang/Serialization/ModuleFile.h b/clang/include/clang/Serialization/ModuleFile.h
index 29d3354d07a129..f20cb2f9f35ae8 100644
--- a/clang/include/clang/Serialization/ModuleFile.h
+++ b/clang/include/clang/Serialization/ModuleFile.h
@@ -62,8 +62,9 @@ enum ModuleKind {
/// The input file info that has been loaded from an AST file.
struct InputFileInfo {
- std::string FilenameAsRequested;
- std::string Filename;
+ StringRef UnresolvedImportedFilenameAsRequested;
+ StringRef UnresolvedImportedFilename;
+
uint64_t ContentHash;
off_t StoredSize;
time_t StoredTime;
@@ -71,6 +72,10 @@ struct InputFileInfo {
bool Transient;
bool TopLevel;
bool ModuleMap;
+
+ bool isValid() const {
+ return !UnresolvedImportedFilenameAsRequested.empty();
+ }
};
/// The input file that has been loaded from this AST file, along with
diff --git a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index 3de19d756da00d..c2071a6eadedd1 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -120,10 +120,6 @@ struct ModuleDeps {
/// additionally appear in \c FileDeps as a dependency.
std::string ClangModuleMapFile;
- /// A collection of absolute paths to files that this module directly depends
- /// on, not including transitive dependencies.
- llvm::StringSet<> FileDeps;
-
/// A collection of absolute paths to module map files that this module needs
/// to know about. The ordering is significant.
std::vector<std::string> ModuleMapFileDeps;
@@ -143,13 +139,25 @@ struct ModuleDeps {
/// an entity from this module is used.
llvm::SmallVector<Module::LinkLibrary, 2> LinkLibraries;
+ /// Invokes \c Cb for all file dependencies of this module. Each provided
+ /// \c StringRef is only valid within the individual callback invocation.
+ void forEachFileDep(llvm::function_ref<void(StringRef)> Cb) const;
+
/// Get (or compute) the compiler invocation that can be used to build this
/// module. Does not include argv[0].
const std::vector<std::string> &getBuildArguments();
private:
+ friend class ModuleDepCollector;
friend class ModuleDepCollectorPP;
+ /// The base directory for relative paths in \c FileDeps.
+ std::string FileDepsBaseDir;
+
+ /// A collection of paths to files that this module directly depends on, not
+ /// including transitive dependencies.
+ std::vector<std::string> FileDeps;
+
std::variant<std::monostate, CowCompilerInvocation, std::vector<std::string>>
BuildInfo;
};
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index d383b4f29a5264..acccf77a5b6cb9 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2473,7 +2473,7 @@ InputFileInfo ASTReader::getInputFileInfo(ModuleFile &F, unsigned ID) {
return InputFileInfo();
// If we've already loaded this input file, return it.
- if (!F.InputFileInfosLoaded[ID - 1].Filename.empty())
+ if (F.InputFileInfosLoaded[ID - 1].isValid())
return F.InputFileInfosLoaded[ID - 1];
// Go find this input file.
@@ -2510,21 +2510,11 @@ InputFileInfo ASTReader::getInputFileInfo(ModuleFile &F, unsigned ID) {
R.Transient = static_cast<bool>(Record[4]);
R.TopLevel = static_cast<bool>(Record[5]);
R.ModuleMap = static_cast<bool>(Record[6]);
- std::tie(R.FilenameAsRequested, R.Filename) = [&]() {
- uint16_t AsRequestedLength = Record[7];
-
- StringRef NameAsRequestedRef = Blob.substr(0, AsRequestedLength);
- StringRef NameRef = Blob.substr(AsRequestedLength);
-
- std::string NameAsRequested =
- ResolveImportedPathAndAllocate(PathBuf, NameAsRequestedRef, F);
- std::string Name = ResolveImportedPathAndAllocate(PathBuf, NameRef, F);
-
- if (Name.empty())
- Name = NameAsRequested;
-
- return std::make_pair(std::move(NameAsRequested), std::move(Name));
- }();
+ uint16_t AsRequestedLength = Record[7];
+ R.UnresolvedImportedFilenameAsRequested = Blob.substr(0, AsRequestedLength);
+ R.UnresolvedImportedFilename = Blob.substr(AsRequestedLength);
+ if (R.UnresolvedImportedFilename.empty())
+ R.UnresolvedImportedFilename = R.UnresolvedImportedFilenameAsRequested;
Expected<llvm::BitstreamEntry> MaybeEntry = Cursor.advance();
if (!MaybeEntry) // FIXME this drops errors on the floor.
@@ -2576,7 +2566,8 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
time_t StoredTime = FI.StoredTime;
bool Overridden = FI.Overridden;
bool Transient = FI.Transient;
- StringRef Filename = FI.FilenameAsRequested;
+ auto Filename =
+ ResolveImportedPath(PathBuf, FI.UnresolvedImportedFilenameAsRequested, F);
uint64_t StoredContentHash = FI.ContentHash;
// For standard C++ modules, we don't need to check the inputs.
@@ -2592,17 +2583,17 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
Overridden = false;
}
- auto File = FileMgr.getOptionalFileRef(Filename, /*OpenFile=*/false);
+ auto File = FileMgr.getOptionalFileRef(*Filename, /*OpenFile=*/false);
// For an overridden file, create a virtual file with the stored
// size/timestamp.
if ((Overridden || Transient || SkipChecks) && !File)
- File = FileMgr.getVirtualFileRef(Filename, StoredSize, StoredTime);
+ File = FileMgr.getVirtualFileRef(*Filename, StoredSize, StoredTime);
if (!File) {
if (Complain) {
std::string ErrorStr = "could not find file '";
- ErrorStr += Filename;
+ ErrorStr += *Filename;
ErrorStr += "' referenced by AST file '";
ErrorStr += F.FileName;
ErrorStr += "'";
@@ -2622,7 +2613,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
if ((!Overridden && !Transient) && !SkipChecks &&
SM.isFileOverridden(*File)) {
if (Complain)
- Error(diag::err_fe_pch_file_overridden, Filename);
+ Error(diag::err_fe_pch_file_overridden, *Filename);
// After emitting the diagnostic, bypass the overriding file to recover
// (this creates a separate FileEntry).
@@ -2714,7 +2705,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
// The top-level PCH is stale.
StringRef TopLevelPCHName(ImportStack.back()->FileName);
Diag(diag::err_fe_ast_file_modified)
- << Filename << moduleKindForDiagnostic(ImportStack.back()->Kind)
+ << *Filename << moduleKindForDiagnostic(ImportStack.back()->Kind)
<< TopLevelPCHName << FileChange.Kind
<< (FileChange.Old && FileChange.New)
<< llvm::itostr(FileChange.Old.value_or(0))
@@ -2723,7 +2714,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
// Print the import stack.
if (ImportStack.size() > 1) {
Diag(diag::note_pch_required_by)
- << Filename << ImportStack[0]->FileName;
+ << *Filename << ImportStack[0]->FileName;
for (unsigned I = 1; I < ImportStack.size(); ++I)
Diag(diag::note_pch_required_by)
<< ImportStack[I-1]->FileName << ImportStack[I]->FileName;
@@ -2971,8 +2962,10 @@ ASTReader::ReadControlBlock(ModuleFile &F,
for (unsigned I = 0; I < N; ++I) {
bool IsSystem = I >= NumUserInputs;
InputFileInfo FI = getInputFileInfo(F, I + 1);
+ auto FilenameAsRequested = ResolveImportedPath(
+ PathBuf, FI.UnresolvedImportedFilenameAsRequested, F);
Listener->visitInputFile(
- FI.FilenameAsRequested, IsSystem, FI.Overridden,
+ *FilenameAsRequested, IsSystem, FI.Overridden,
F.Kind == MK_ExplicitModule || F.Kind == MK_PrebuiltModule);
}
}
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 637416cd1fc621..2e97cac0796cee 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -21,6 +21,16 @@ using namespace clang;
using namespace tooling;
using namespace dependencies;
+void ModuleDeps::forEachFileDep(llvm::function_ref<void(StringRef)> Cb) const {
+ SmallString<0> PathBuf;
+ PathBuf.reserve(256);
+ for (StringRef FileDep : FileDeps) {
+ auto ResolvedFileDep =
+ ASTReader::ResolveImportedPath(PathBuf, FileDep, FileDepsBaseDir);
+ Cb(*ResolvedFileDep);
+ }
+}
+
const std::vector<std::string> &ModuleDeps::getBuildArguments() {
assert(!std::holds_alternative<std::monostate>(BuildInfo) &&
"Using uninitialized ModuleDeps");
@@ -596,6 +606,7 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
serialization::ModuleFile *MF =
MDC.ScanInstance.getASTReader()->getModuleManager().lookup(
*M->getASTFile());
+ MD.FileDepsBaseDir = MF->BaseDirectory;
MDC.ScanInstance.getASTReader()->visitInputFileInfos(
*MF, /*IncludeSystem=*/true,
[&](const serialization::InputFileInfo &IFI, bool IsSystem) {
@@ -604,9 +615,9 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
// actual on-disk module map file that allowed inferring the module,
// which is what we need for building the module explicitly
// Let's ignore this file.
- if (StringRef(IFI.Filename).ends_with("__inferred_module.map"))
+ if (IFI.UnresolvedImportedFilename.ends_with("__inferred_module.map"))
return;
- MDC.addFileDep(MD, IFI.Filename);
+ MDC.addFileDep(MD, IFI.UnresolvedImportedFilename);
});
llvm::DenseSet<const Module *> SeenDeps;
@@ -614,15 +625,20 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
addAllSubmoduleDeps(M, MD, SeenDeps);
addAllAffectingClangModules(M, MD, SeenDeps);
+ SmallString<0> PathBuf;
+ PathBuf.reserve(256);
MDC.ScanInstance.getASTReader()->visitInputFileInfos(
*MF, /*IncludeSystem=*/true,
[&](const serialization::InputFileInfo &IFI, bool IsSystem) {
if (!(IFI.TopLevel && IFI.ModuleMap))
return;
- if (StringRef(IFI.FilenameAsRequested)
- .ends_with("__inferred_module.map"))
+ if (IFI.UnresolvedImportedFilenameAsRequested.ends_with(
+ "__inferred_module.map"))
return;
- MD.ModuleMapFileDeps.emplace_back(IFI.FilenameAsRequested);
+ auto ResolvedFilenameAsRequested = ASTReader::ResolveImportedPath(
+ PathBuf, IFI.UnresolvedImportedFilenameAsRequested,
+ MF->BaseDirectory);
+ MD.ModuleMapFileDeps.emplace_back(*ResolvedFilenameAsRequested);
});
CowCompilerInvocation CI =
@@ -779,23 +795,16 @@ static StringRef makeAbsoluteAndPreferred(CompilerInstance &CI, StringRef Path,
void ModuleDepCollector::addFileDep(StringRef Path) {
if (IsStdModuleP1689Format) {
// Within P1689 format, we don't want all the paths to be absolute path
- // since it may violate the tranditional make style dependencies info.
- FileDeps.push_back(std::string(Path));
+ // since it may violate the traditional make style dependencies info.
+ FileDeps.emplace_back(Path);
return;
}
llvm::SmallString<256> Storage;
Path = makeAbsoluteAndPreferred(ScanInstance, Path, Storage);
- FileDeps.push_back(std::string(Path));
+ FileDeps.emplace_back(Path);
}
void ModuleDepCollector::addFileDep(ModuleDeps &MD, StringRef Path) {
- if (IsStdModuleP1689Format) {
- MD.FileDeps.insert(Path);
- return;
- }
-
- llvm::SmallString<256> Storage;
- Path = makeAbsoluteAndPreferred(ScanInstance, Path, Storage);
- MD.FileDeps.insert(Path);
+ MD.FileDeps.emplace_back(Path);
}
diff --git a/clang/test/ClangScanDeps/diagnostics.c b/clang/test/ClangScanDeps/diagnostics.c
index bc05594f7828dc..8e3cf4c9f9fa6d 100644
--- a/clang/test/ClangScanDeps/diagnostics.c
+++ b/clang/test/ClangScanDeps/diagnostics.c
@@ -34,8 +34,8 @@ module mod { header "mod.h" }
// CHECK: ],
// CHECK-NEXT: "context-hash": "[[HASH_MOD:.*]]",
// CHECK-NEXT: "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/mod.h"
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "mod"
diff --git a/clang/test/ClangScanDeps/header-search-pruning-transitive.c b/clang/test/ClangScanDeps/header-search-pruning-transitive.c
index 6c422650902689..1e829bb02ddc4a 100644
--- a/clang/test/ClangScanDeps/header-search-pruning-transitive.c
+++ b/clang/test/ClangScanDeps/header-search-pruning-transitive.c
@@ -72,8 +72,8 @@ module X { header "X.h" }
// CHECK: ],
// CHECK-NEXT: "context-hash": "[[HASH_X:.*]]",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/X.h",
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/X.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "X"
@@ -85,11 +85,11 @@ module X { header "X.h" }
// CHECK: ],
// CHECK-NEXT: "context-hash": "[[HASH_Y_WITH_A]]",
// CHECK-NEXT: "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/Y.h",
-// CHECK-NEXT: "[[PREFIX]]/a/a.h",
// CHECK-NEXT: "[[PREFIX]]/begin/begin.h",
-// CHECK-NEXT: "[[PREFIX]]/end/end.h",
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/a/a.h",
+// CHECK-NEXT: "[[PREFIX]]/end/end.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "Y"
@@ -128,8 +128,8 @@ module X { header "X.h" }
// also has a different context hash from the first version of module X.
// CHECK-NOT: "context-hash": "[[HASH_X]]",
// CHECK: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/X.h",
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/X.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "X"
@@ -141,10 +141,10 @@ module X { header "X.h" }
// CHECK: ],
// CHECK-NEXT: "context-hash": "[[HASH_Y_WITHOUT_A]]",
// CHECK-NEXT: "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/Y.h",
// CHECK-NEXT: "[[PREFIX]]/begin/begin.h",
-// CHECK-NEXT: "[[PREFIX]]/end/end.h",
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/end/end.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "Y"
diff --git a/clang/test/ClangScanDeps/link-libraries.c b/clang/test/ClangScanDeps/link-libraries.c
index bc0b0c546ea032..cc2e223102024b 100644
--- a/clang/test/ClangScanDeps/link-libraries.c
+++ b/clang/test/ClangScanDeps/link-libraries.c
@@ -44,8 +44,8 @@ module transitive {
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/Inputs/frameworks/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/Inputs/frameworks/Framework.framework/Headers/Framework.h"
-// CHECK-NEXT: "[[PREFIX]]/Inputs/frameworks/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [
// CHECK-NEXT: {
@@ -67,8 +67,8 @@ module transitive {
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/direct.h"
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "direct"
@@ -89,10 +89,10 @@ module transitive {
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/root.h",
+// CHECK-NEXT: "[[PREFIX]]/root/textual.h",
// CHECK-NEXT: "[[PREFIX]]/Inputs/frameworks/module.modulemap"
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
-// CHECK-NEXT: "[[PREFIX]]/root.h"
-// CHECK-NEXT: "[[PREFIX]]/root/textual.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "root"
@@ -104,7 +104,7 @@ module transitive {
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/transitive.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [
diff --git a/clang/test/ClangScanDeps/modules-context-hash.c b/clang/test/ClangScanDeps/modules-context-hash.c
index 69fd8561a2b32a..9489563576d3b1 100644
--- a/clang/test/ClangScanDeps/modules-context-hash.c
+++ b/clang/test/ClangScanDeps/modules-context-hash.c
@@ -34,9 +34,9 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "[[HASH_MOD_A:.*]]",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/a/dep.h",
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/mod.h",
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/a/dep.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "mod"
@@ -72,9 +72,9 @@
// CHECK: ],
// CHECK-NOT: "context-hash": "[[HASH_MOD_A]]",
// CHECK: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/b/dep.h",
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/mod.h",
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/b/dep.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "mod"
diff --git a/clang/test/ClangScanDeps/modules-dep-args.c b/clang/test/ClangScanDeps/modules-dep-args.c
index 14de2e8f4594a1..19f915923b84cf 100644
--- a/clang/test/ClangScanDeps/modules-dep-args.c
+++ b/clang/test/ClangScanDeps/modules-dep-args.c
@@ -58,8 +58,8 @@ module Direct { header "direct.h" }
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/direct.h",
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/direct.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "Direct"
diff --git a/clang/test/ClangScanDeps/modules-extern-submodule.c b/clang/test/ClangScanDeps/modules-extern-submodule.c
index 6e9082b0165fdf..01d3d6ba5e0d3a 100644
--- a/clang/test/ClangScanDeps/modules-extern-submodule.c
+++ b/clang/test/ClangScanDeps/modules-extern-submodule.c
@@ -49,8 +49,8 @@ module third {}
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/first/first/first.h",
// CHECK-NEXT: "[[PREFIX]]/first/first/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/first/first/first.h",
// CHECK-NEXT: "[[PREFIX]]/second/second/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/second/second/sub.modulemap"
// CHECK-NEXT: ],
@@ -73,8 +73,8 @@ module third {}
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/second/second/module.modulemap",
-// CHECK-NEXT: "[[PREFIX]]/second/second/sub.h",
// CHECK-NEXT: "[[PREFIX]]/second/second/sub.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/second/second/sub.h",
// CHECK-NEXT: "[[PREFIX]]/third/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
diff --git a/clang/test/ClangScanDeps/modules-extern-unrelated.m b/clang/test/ClangScanDeps/modules-extern-unrelated.m
index 724779c12a97b7..c003f0d9a2ee85 100644
--- a/clang/test/ClangScanDeps/modules-extern-unrelated.m
+++ b/clang/test/ClangScanDeps/modules-extern-unrelated.m
@@ -50,8 +50,8 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/first/first_other.h",
-// CHECK-NEXT: "[[PREFIX]]/first/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/first/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/first/first_other.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "first_other"
@@ -69,9 +69,9 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/first/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/second/second.modulemap",
// CHECK-NEXT: "[[PREFIX]]/second/second.h",
-// CHECK-NEXT: "[[PREFIX]]/second/second.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/first/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "second"
@@ -93,10 +93,10 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/first/module.modulemap",
-// CHECK-NEXT: "[[PREFIX]]/second/second.modulemap",
// CHECK-NEXT: "[[PREFIX]]/zeroth/module.modulemap",
-// CHECK-NEXT: "[[PREFIX]]/zeroth/zeroth.h"
+// CHECK-NEXT: "[[PREFIX]]/zeroth/zeroth.h",
+// CHECK-NEXT: "[[PREFIX]]/first/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/second/second.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "zeroth"
diff --git a/clang/test/ClangScanDeps/modules-file-path-isolation.c b/clang/test/ClangScanDeps/modules-file-path-isolation.c
index d4fef2f4fdd28e..2bd0a58ca9ae60 100644
--- a/clang/test/ClangScanDeps/modules-file-path-isolation.c
+++ b/clang/test/ClangScanDeps/modules-file-path-isolation.c
@@ -17,8 +17,8 @@
// CHECK: "modules": [
// CHECK-NEXT: {
// CHECK: "file-deps": [
-// CHECK-NEXT: "{{.*}}A.h",
-// CHECK-NEXT: "{{.*}}module.modulemap"
+// CHECK-NEXT: "{{.*}}module.modulemap",
+// CHECK-NEXT: "{{.*}}A.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "A"
diff --git a/clang/test/ClangScanDeps/modules-fmodule-name-no-module-built.m b/clang/test/ClangScanDeps/modules-fmodule-name-no-module-built.m
index e4d5caff9236e7..cfe29c2bf7cdbb 100644
--- a/clang/test/ClangScanDeps/modules-fmodule-name-no-module-built.m
+++ b/clang/test/ClangScanDeps/modules-fmodule-name-no-module-built.m
@@ -25,8 +25,8 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "[[HASH_H2:[A-Z0-9]+]]",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/Inputs/header2.h",
-// CHECK-NEXT: "[[PREFIX]]/Inputs/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/Inputs/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/Inputs/header2.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "header2"
@@ -44,8 +44,8 @@
// CHECK-NEXT: "command-line": [
// CHECK: ],
// CHECK: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/modules-fmodule-name-no-module-built.m"
-// CHECK-NEXT: "[[PREFIX]]/Inputs/header3.h"
+// CHECK-NEXT: "[[PREFIX]]/modules-fmodule-name-no-module-built.m",
+// CHECK-NEXT: "[[PREFIX]]/Inputs/header3.h",
// CHECK-NEXT: "[[PREFIX]]/Inputs/header.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "input-file": "[[PREFIX]]/modules-fmodule-name-no-module-built.m"
diff --git a/clang/test/ClangScanDeps/modules-full-by-mod-name.c b/clang/test/ClangScanDeps/modules-full-by-mod-name.c
index dd2b3f62e36635..c838614d0bfdea 100644
--- a/clang/test/ClangScanDeps/modules-full-by-mod-name.c
+++ b/clang/test/ClangScanDeps/modules-full-by-mod-name.c
@@ -42,8 +42,8 @@ module transitive { header "transitive.h" }
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/direct.h"
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "direct"
@@ -60,8 +60,8 @@ module transitive { header "transitive.h" }
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
-// CHECK-NEXT: "[[PREFIX]]/root.h"
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/root.h",
// CHECK-NEXT: "[[PREFIX]]/root/textual.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
@@ -74,7 +74,7 @@ module transitive { header "transitive.h" }
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/transitive.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
diff --git a/clang/test/ClangScanDeps/modules-full.cpp b/clang/test/ClangScanDeps/modules-full.cpp
index e9b4386da5b5e6..38db3af4403bb3 100644
--- a/clang/test/ClangScanDeps/modules-full.cpp
+++ b/clang/test/ClangScanDeps/modules-full.cpp
@@ -41,8 +41,8 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "[[HASH_H1_DINCLUDE:[A-Z0-9]+]]",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/Inputs/header.h",
-// CHECK-NEXT: "[[PREFIX]]/Inputs/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/Inputs/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/Inputs/header.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "header1"
@@ -60,8 +60,8 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "[[HASH_H1:[A-Z0-9]+]]",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/Inputs/header.h",
-// CHECK-NEXT: "[[PREFIX]]/Inputs/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/Inputs/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/Inputs/header.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "header1"
@@ -79,8 +79,8 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "[[HASH_H2_DINCLUDE]]",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/Inputs/header2.h",
-// CHECK-NEXT: "[[PREFIX]]/Inputs/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/Inputs/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/Inputs/header2.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "header2"
diff --git a/clang/test/ClangScanDeps/modules-implicit-dot-private.m b/clang/test/ClangScanDeps/modules-implicit-dot-private.m
index b3bc90f03f1799..aa8caf3451dc4a 100644
--- a/clang/test/ClangScanDeps/modules-implicit-dot-private.m
+++ b/clang/test/ClangScanDeps/modules-implicit-dot-private.m
@@ -32,8 +32,8 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h",
-// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [
// CHECK-NEXT: {
diff --git a/clang/test/ClangScanDeps/modules-incomplete-umbrella.c b/clang/test/ClangScanDeps/modules-incomplete-umbrella.c
index 2c5d5f547f3e7c..696e621960b6f6 100644
--- a/clang/test/ClangScanDeps/modules-incomplete-umbrella.c
+++ b/clang/test/ClangScanDeps/modules-incomplete-umbrella.c
@@ -44,8 +44,8 @@ framework module FW_Private {
// CHECK_TU: ],
// CHECK_TU-NEXT: "context-hash": "{{.*}}",
// CHECK_TU-NEXT: "file-deps": [
-// CHECK_TU-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h",
-// CHECK_TU-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap"
+// CHECK_TU-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
+// CHECK_TU-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h"
// CHECK_TU-NEXT: ],
// CHECK_TU-NEXT: "link-libraries": [
// CHECK_TU-NEXT: {
@@ -134,8 +134,8 @@ module Mod { header "Mod.h" }
// CHECK_MODULE: ],
// CHECK_MODULE-NEXT: "context-hash": "{{.*}}",
// CHECK_MODULE-NEXT: "file-deps": [
-// CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h",
-// CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap"
+// CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
+// CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h"
// CHECK_MODULE-NEXT: ],
// CHECK_MODULE-NEXT: "link-libraries": [
// CHECK_MODULE-NEXT: {
@@ -182,11 +182,11 @@ module Mod { header "Mod.h" }
// CHECK_MODULE: ],
// CHECK_MODULE-NEXT: "context-hash": "{{.*}}",
// CHECK_MODULE-NEXT: "file-deps": [
-// CHECK_MODULE-NEXT: "[[PREFIX]]/Mod.h"
+// CHECK_MODULE-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK_MODULE-NEXT: "[[PREFIX]]/Mod.h",
// CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
// CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
-// CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/Two.h",
-// CHECK_MODULE-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK_MODULE-NEXT: "[[PREFIX]]/frameworks/FW.framework/PrivateHeaders/Two.h"
// CHECK_MODULE-NEXT: ],
// CHECK_MODULE-NEXT: "link-libraries": [],
// CHECK_MODULE-NEXT: "name": "Mod"
diff --git a/clang/test/ClangScanDeps/modules-inferred.m b/clang/test/ClangScanDeps/modules-inferred.m
index b8f17b22082705..4c7a4095c9bef6 100644
--- a/clang/test/ClangScanDeps/modules-inferred.m
+++ b/clang/test/ClangScanDeps/modules-inferred.m
@@ -37,9 +37,9 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h",
+// CHECK-NEXT: "[[PREFIX]]/frameworks/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/frameworks/Inferred.framework/Headers/Inferred.h",
-// CHECK-NEXT: "[[PREFIX]]/frameworks/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [
// CHECK-NEXT: {
diff --git a/clang/test/ClangScanDeps/modules-no-undeclared-includes.c b/clang/test/ClangScanDeps/modules-no-undeclared-includes.c
index d288095cb0bd76..6110c419949f9c 100644
--- a/clang/test/ClangScanDeps/modules-no-undeclared-includes.c
+++ b/clang/test/ClangScanDeps/modules-no-undeclared-includes.c
@@ -44,8 +44,8 @@ module User [no_undeclared_includes] { header "user.h" }
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
-// CHECK-NEXT: "[[PREFIX]]/undeclared/module.modulemap",
-// CHECK-NEXT: "[[PREFIX]]/user.h"
+// CHECK-NEXT: "[[PREFIX]]/user.h",
+// CHECK-NEXT: "[[PREFIX]]/undeclared/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "User"
diff --git a/clang/test/ClangScanDeps/modules-pch-common-submodule.c b/clang/test/ClangScanDeps/modules-pch-common-submodule.c
index 03ebc62c1ab3cf..59dd3f172d8ee5 100644
--- a/clang/test/ClangScanDeps/modules-pch-common-submodule.c
+++ b/clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -27,9 +27,9 @@
// CHECK-PCH: ],
// CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON:.*]]",
// CHECK-PCH-NEXT: "file-deps": [
+// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common.h",
-// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_sub.h",
-// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_sub.h"
// CHECK-PCH-NEXT: ],
// CHECK-PCH-NEXT: "link-libraries": [],
// CHECK-PCH-NEXT: "name": "ModCommon"
@@ -76,8 +76,8 @@
// CHECK-TU: ],
// CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU:.*]]",
// CHECK-TU-NEXT: "file-deps": [
-// CHECK-TU-NEXT: "[[PREFIX]]/mod_tu.h",
-// CHECK-TU-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-TU-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-TU-NEXT: "[[PREFIX]]/mod_tu.h"
// CHECK-TU-NEXT: ],
// CHECK-TU-NEXT: "link-libraries": [],
// CHECK-TU-NEXT: "name": "ModTU"
diff --git a/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c b/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
index 725ac0e6b224fa..a12492c0bec707 100644
--- a/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
+++ b/clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
@@ -24,8 +24,8 @@
// CHECK-PCH: ],
// CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON:.*]]",
// CHECK-PCH-NEXT: "file-deps": [
-// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common.h",
-// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common.h"
// CHECK-PCH-NEXT: ],
// CHECK-PCH-NEXT: "link-libraries": [],
// CHECK-PCH-NEXT: "name": "ModCommon"
@@ -72,9 +72,9 @@
// CHECK-TU: ],
// CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU:.*]]",
// CHECK-TU-NEXT: "file-deps": [
+// CHECK-TU-NEXT: "[[PREFIX]]/module.modulemap",
// CHECK-TU-NEXT: "[[PREFIX]]/mod_tu.h",
-// CHECK-TU-NEXT: "[[PREFIX]]/mod_tu_sub.h",
-// CHECK-TU-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-TU-NEXT: "[[PREFIX]]/mod_tu_sub.h"
// CHECK-TU-NEXT: ],
// CHECK-TU-NEXT: "link-libraries": [],
// CHECK-TU-NEXT: "name": "ModTU"
diff --git a/clang/test/ClangScanDeps/modules-pch.c b/clang/test/ClangScanDeps/modules-pch.c
index 467bfd9af47ae5..92b7f41ac4b9f9 100644
--- a/clang/test/ClangScanDeps/modules-pch.c
+++ b/clang/test/ClangScanDeps/modules-pch.c
@@ -25,8 +25,8 @@
// CHECK-PCH: ],
// CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON_1:.*]]",
// CHECK-PCH-NEXT: "file-deps": [
-// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_1.h",
-// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_1.h"
// CHECK-PCH-NEXT: ],
// CHECK-PCH-NEXT: "link-libraries": [],
// CHECK-PCH-NEXT: "name": "ModCommon1"
@@ -38,8 +38,8 @@
// CHECK-PCH: ],
// CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_COMMON_2:.*]]",
// CHECK-PCH-NEXT: "file-deps": [
-// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_2.h",
-// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_2.h"
// CHECK-PCH-NEXT: ],
// CHECK-PCH-NEXT: "link-libraries": [],
// CHECK-PCH-NEXT: "name": "ModCommon2"
@@ -56,8 +56,8 @@
// CHECK-PCH: ],
// CHECK-PCH-NEXT: "context-hash": "[[HASH_MOD_PCH:.*]]",
// CHECK-PCH-NEXT: "file-deps": [
-// CHECK-PCH-NEXT: "[[PREFIX]]/mod_pch.h",
-// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_pch.h"
// CHECK-PCH-NEXT: ],
// CHECK-PCH-NEXT: "link-libraries": [],
// CHECK-PCH-NEXT: "name": "ModPCH"
@@ -113,8 +113,8 @@
// CHECK-TU: ],
// CHECK-TU-NEXT: "context-hash": "[[HASH_MOD_TU:.*]]",
// CHECK-TU-NEXT: "file-deps": [
-// CHECK-TU-NEXT: "[[PREFIX]]/mod_tu.h",
-// CHECK-TU-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-TU-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-TU-NEXT: "[[PREFIX]]/mod_tu.h"
// CHECK-TU-NEXT: ],
// CHECK-TU-NEXT: "link-libraries": [],
// CHECK-TU-NEXT: "name": "ModTU"
@@ -163,8 +163,8 @@
// CHECK-TU-WITH-COMMON: ],
// CHECK-TU-WITH-COMMON-NEXT: "context-hash": "[[HASH_MOD_TU_WITH_COMMON:.*]]",
// CHECK-TU-WITH-COMMON-NEXT: "file-deps": [
-// CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/mod_tu_with_common.h",
-// CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-TU-WITH-COMMON-NEXT: "[[PREFIX]]/mod_tu_with_common.h"
// CHECK-TU-WITH-COMMON-NEXT: ],
// CHECK-TU-WITH-COMMON-NEXT: "link-libraries": [],
// CHECK-TU-WITH-COMMON-NEXT: "name": "ModTUWithCommon"
diff --git a/clang/test/ClangScanDeps/modules-priv-fw-from-pub.m b/clang/test/ClangScanDeps/modules-priv-fw-from-pub.m
index e9613088463630..dd314e1a3006a7 100644
--- a/clang/test/ClangScanDeps/modules-priv-fw-from-pub.m
+++ b/clang/test/ClangScanDeps/modules-priv-fw-from-pub.m
@@ -42,8 +42,8 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/modules/dependency.h",
-// CHECK-NEXT: "[[PREFIX]]/modules/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/modules/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/modules/dependency.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "Dependency"
@@ -60,9 +60,9 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h",
// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.modulemap",
-// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Modules/module.private.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/frameworks/FW.framework/Headers/FW.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [
// CHECK-NEXT: {
diff --git a/clang/test/ClangScanDeps/modules-redefinition.m b/clang/test/ClangScanDeps/modules-redefinition.m
index 6954e1ed72f16e..3db06287241feb 100644
--- a/clang/test/ClangScanDeps/modules-redefinition.m
+++ b/clang/test/ClangScanDeps/modules-redefinition.m
@@ -45,8 +45,8 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: [[PREFIX]]/first/first.h",
// CHECK-NEXT: [[PREFIX]]/first/module.modulemap",
+// CHECK-NEXT: [[PREFIX]]/first/first.h",
// CHECK-NEXT: [[PREFIX]]/third/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
diff --git a/clang/test/ClangScanDeps/modules-symlink-dir-vfs.c b/clang/test/ClangScanDeps/modules-symlink-dir-vfs.c
index 127c0c6b6d2ab6..f2e5758aa41fb2 100644
--- a/clang/test/ClangScanDeps/modules-symlink-dir-vfs.c
+++ b/clang/test/ClangScanDeps/modules-symlink-dir-vfs.c
@@ -75,9 +75,9 @@ framework module FW { umbrella header "FW.h" }
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/frameworks-symlink/FW.framework/Modules/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/copy/FW.h",
-// CHECK-NEXT: "[[PREFIX]]/copy/Header.h",
-// CHECK-NEXT: "[[PREFIX]]/frameworks-symlink/FW.framework/Modules/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/copy/Header.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [
// CHECK-NEXT: {
diff --git a/clang/test/ClangScanDeps/modules-transitive.c b/clang/test/ClangScanDeps/modules-transitive.c
index 5d9bdbc95a7e96..1a3b8a36711815 100644
--- a/clang/test/ClangScanDeps/modules-transitive.c
+++ b/clang/test/ClangScanDeps/modules-transitive.c
@@ -48,8 +48,8 @@ module third { header "third.h" }
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/first/first.h"
-// CHECK-NEXT: "[[PREFIX]]/first/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/first/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/first/first.h",
// CHECK-NEXT: "[[PREFIX]]/second/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
diff --git a/clang/test/ClangScanDeps/optimize-vfs.m b/clang/test/ClangScanDeps/optimize-vfs.m
index 05968715358ea7..2043a603179fe8 100644
--- a/clang/test/ClangScanDeps/optimize-vfs.m
+++ b/clang/test/ClangScanDeps/optimize-vfs.m
@@ -24,8 +24,8 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/build/A.h",
-// CHECK-NEXT: "[[PREFIX]]/build/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/build/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/build/A.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "A"
@@ -38,8 +38,8 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/modules/B/B.h",
-// CHECK-NEXT: "[[PREFIX]]/modules/B/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/modules/B/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/modules/B/B.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "B"
@@ -57,9 +57,9 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "{{.*}}",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/modules/B/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/modules/C/module.modulemap",
// CHECK-NEXT: "[[PREFIX]]/modules/C/C.h",
-// CHECK-NEXT: "[[PREFIX]]/modules/C/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/modules/B/module.modulemap"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "C"
diff --git a/clang/test/ClangScanDeps/removed-args.c b/clang/test/ClangScanDeps/removed-args.c
index c1d779dbe06105..16f053f71e6bae 100644
--- a/clang/test/ClangScanDeps/removed-args.c
+++ b/clang/test/ClangScanDeps/removed-args.c
@@ -39,8 +39,8 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "[[HASH_MOD_HEADER:.*]]",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/mod_header.h",
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/mod_header.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "ModHeader"
@@ -66,8 +66,8 @@
// CHECK: ],
// CHECK-NEXT: "context-hash": "[[HASH_MOD_TU:.*]]",
// CHECK-NEXT: "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/mod_tu.h",
-// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT: "[[PREFIX]]/mod_tu.h"
// CHECK-NEXT: ],
// CHECK-NEXT: "link-libraries": [],
// CHECK-NEXT: "name": "ModTU"
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index f474b1346b1be1..9b30799c3ab263 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -338,13 +338,6 @@ static auto toJSONStrings(llvm::json::OStream &JOS, Container &&Strings) {
};
}
-static auto toJSONSorted(llvm::json::OStream &JOS,
- const llvm::StringSet<> &Set) {
- SmallVector<StringRef> Strings(Set.keys());
- llvm::sort(Strings);
- return toJSONStrings(JOS, std::move(Strings));
-}
-
// Technically, we don't need to sort the dependency list to get determinism.
// Leaving these be will simply preserve the import order.
static auto toJSONSorted(llvm::json::OStream &JOS, std::vector<ModuleID> V) {
@@ -472,7 +465,9 @@ class FullDeps {
JOS.attributeArray("command-line",
toJSONStrings(JOS, MD.getBuildArguments()));
JOS.attribute("context-hash", StringRef(MD.ID.ContextHash));
- JOS.attributeArray("file-deps", toJSONSorted(JOS, MD.FileDeps));
+ JOS.attributeArray("file-deps", [&] {
+ MD.forEachFileDep([&](StringRef FileDep) { JOS.value(FileDep); });
+ });
JOS.attributeArray("link-libraries",
toJSONSorted(JOS, MD.LinkLibraries));
JOS.attribute("name", StringRef(MD.ID.ModuleName));
>From 2a118a6f139e766f61f6108761606acb586f138a Mon Sep 17 00:00:00 2001
From: Jan Svoboda <jan_svoboda at apple.com>
Date: Thu, 31 Oct 2024 13:53:33 -0700
Subject: [PATCH 2/2] clang-format
---
clang/lib/Serialization/ASTReader.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index acccf77a5b6cb9..77a823d45af385 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2714,7 +2714,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
// Print the import stack.
if (ImportStack.size() > 1) {
Diag(diag::note_pch_required_by)
- << *Filename << ImportStack[0]->FileName;
+ << *Filename << ImportStack[0]->FileName;
for (unsigned I = 1; I < ImportStack.size(); ++I)
Diag(diag::note_pch_required_by)
<< ImportStack[I-1]->FileName << ImportStack[I]->FileName;
More information about the cfe-commits
mailing list