Skip to content

Commit 7b05724

Browse files
mathstufbradking
authored andcommitted
cmCxxModuleMapper: give transitive usages to Clang as well
In the future, Clang plans to require transitive module usage to be specified on the command line. This is in order to keep BMI files more reproducible. Handily, MSVC has already required this, so the logic can be reused for Clang easily. See: llvm/llvm-project@e22fa1d See: llvm/llvm-project#62707 See: https://discourse.llvm.org/t/c-20-modules-should-the-bmis-contain-paths-to-their-dependent-bmis/70422
1 parent c9df456 commit 7b05724

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Source/cmCxxModuleMapper.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ std::vector<TransitiveUsage> GetTransitiveUsages(
128128
}
129129

130130
std::string CxxModuleMapContentClang(CxxModuleLocations const& loc,
131-
cmScanDepInfo const& obj)
131+
cmScanDepInfo const& obj,
132+
CxxModuleUsage const& usages)
132133
{
133134
std::stringstream mm;
134135

@@ -151,12 +152,11 @@ std::string CxxModuleMapContentClang(CxxModuleLocations const& loc,
151152
break;
152153
}
153154
}
154-
for (auto const& r : obj.Requires) {
155-
auto bmi_loc = loc.BmiGeneratorPathForModule(r.LogicalName);
156-
if (bmi_loc.IsKnown()) {
157-
mm << "-fmodule-file=" << r.LogicalName << "=" << bmi_loc.Location()
158-
<< '\n';
159-
}
155+
156+
auto all_usages = GetTransitiveUsages(loc, obj.Requires, usages);
157+
for (auto const& usage : all_usages) {
158+
mm << "-fmodule-file=" << usage.LogicalName << '=' << usage.Location
159+
<< '\n';
160160
}
161161

162162
return mm.str();
@@ -420,7 +420,7 @@ std::string CxxModuleMapContent(CxxModuleMapFormat format,
420420
{
421421
switch (format) {
422422
case CxxModuleMapFormat::Clang:
423-
return CxxModuleMapContentClang(loc, obj);
423+
return CxxModuleMapContentClang(loc, obj, usages);
424424
case CxxModuleMapFormat::Gcc:
425425
return CxxModuleMapContentGcc(loc, obj);
426426
case CxxModuleMapFormat::Msvc:

0 commit comments

Comments
 (0)