[clang] b5088cb - [clang][deps] Ensure deterministic order of TU '-fmodule-file=' arguments
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 25 02:14:21 PDT 2021
Author: Jan Svoboda
Date: 2021-08-25T11:14:16+02:00
New Revision: b5088cb408222eba4611e6121293166904ca48e6
URL: https://github.com/llvm/llvm-project/commit/b5088cb408222eba4611e6121293166904ca48e6
DIFF: https://github.com/llvm/llvm-project/commit/b5088cb408222eba4611e6121293166904ca48e6.diff
LOG: [clang][deps] Ensure deterministic order of TU '-fmodule-file=' arguments
Translation units with multiple direct modular dependencies trigger a non-deterministic ordering in `clang-scan-deps`. This boils down to usage of `std::unordered_map`, which gets replaced by `std::map` in this patch.
Depends on D103526.
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D103807
Added:
Modified:
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/test/ClangScanDeps/modules-pch.c
Removed:
################################################################################
diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
index 2fd12f7e12b1..43b6a0c95f04 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -180,7 +180,7 @@ DependencyScanningTool::getFullDependencies(
private:
std::vector<std::string> Dependencies;
std::vector<PrebuiltModuleDep> PrebuiltModuleDeps;
- std::unordered_map<std::string, ModuleDeps> ClangModuleDeps;
+ std::map<std::string, ModuleDeps> ClangModuleDeps;
std::string ContextHash;
std::vector<std::string> OutputPaths;
const llvm::StringSet<> &AlreadySeen;
diff --git a/clang/test/ClangScanDeps/modules-pch.c b/clang/test/ClangScanDeps/modules-pch.c
index b9b7ed7badd1..1f368f9e87fb 100644
--- a/clang/test/ClangScanDeps/modules-pch.c
+++ b/clang/test/ClangScanDeps/modules-pch.c
@@ -90,9 +90,9 @@
// CHECK-PCH-NEXT: "command-line": [
// CHECK-PCH-NEXT: "-fno-implicit-modules",
// CHECK-PCH-NEXT: "-fno-implicit-module-maps",
-// CHECK-PCH-DAG: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_1]]/ModCommon1-{{.*}}.pcm",
-// CHECK-PCH-DAG: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm",
-// CHECK-PCH-DAG: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_PCH]]/ModPCH-{{.*}}.pcm",
+// CHECK-PCH-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_1]]/ModCommon1-{{.*}}.pcm",
+// CHECK-PCH-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON_2]]/ModCommon2-{{.*}}.pcm",
+// CHECK-PCH-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_PCH]]/ModPCH-{{.*}}.pcm",
// CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap",
// CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap",
// CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
More information about the cfe-commits
mailing list