Skip to content

Commit 139d3f4

Browse files
committed
[TCling] Use clang::Module::HeaderKind to avoid hardcoded index
Use HK_* enums instead. Will reduce the diff when upgrading to LLVM20 Ref: llvm/llvm-project@6194668
1 parent 4ff4841 commit 139d3f4

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

Diff for: core/clingutils/src/TClingUtils.cxx

+4-14
Original file line numberDiff line numberDiff line change
@@ -2786,18 +2786,6 @@ void ROOT::TMetaUtils::foreachHeaderInModule(const clang::Module &module,
27862786
{
27872787
// Iterates over all headers in a module and calls the closure on each.
27882788

2789-
// FIXME: We currently have to hardcode '4' to do this. Maybe we
2790-
// will have a nicer way to do this in the future.
2791-
// NOTE: This is on purpose '4', not '5' which is the size of the
2792-
// vector. The last element is the list of excluded headers which we
2793-
// obviously don't want to check here.
2794-
const std::size_t publicHeaderIndex = 4;
2795-
2796-
// Integrity check in case this array changes its size at some point.
2797-
const std::size_t maxArrayLength = ((sizeof module.Headers) / (sizeof *module.Headers));
2798-
static_assert(publicHeaderIndex + 1 == maxArrayLength,
2799-
"'Headers' has changed it's size, we need to update publicHeaderIndex");
2800-
28012789
// Make a list of modules and submodules that we can check for headers.
28022790
// We use a SetVector to prevent an infinite loop in unlikely case the
28032791
// modules somehow are messed up and don't form a tree...
@@ -2816,8 +2804,10 @@ void ROOT::TMetaUtils::foreachHeaderInModule(const clang::Module &module,
28162804
}
28172805
}
28182806

2819-
for (std::size_t i = 0; i < publicHeaderIndex; i++) {
2820-
auto &headerList = m->Headers[i];
2807+
// We want to check for all headers except the list of excluded headers here.
2808+
for (auto HK : {clang::Module::HK_Normal, clang::Module::HK_Textual, clang::Module::HK_Private,
2809+
clang::Module::HK_PrivateTextual}) {
2810+
auto &headerList = m->Headers[HK];
28212811
for (const clang::Module::Header &moduleHeader : headerList) {
28222812
closure(moduleHeader);
28232813
}

0 commit comments

Comments
 (0)