Fixed progress indicators ranges with multiple commands per TU (#240)

This commit is contained in:
Bartek Kryza
2024-03-04 22:04:44 +01:00
parent 51a9242b49
commit b057407809
4 changed files with 23 additions and 2 deletions

View File

@@ -31,6 +31,7 @@ Checks: >-
-google-explicit-constructor,
-google-build-using-namespace,
-google-upgrade-*,
-google-runtime-int,
-hicpp-signed-bitwise,
-hicpp-explicit-conversions,
-llvmlibc-*,

View File

@@ -88,6 +88,21 @@ std::string compilation_database::guess_language_from_filename(
return "c++";
}
long compilation_database::count_matching_commands(
const std::vector<std::string> &files) const
{
auto result{0L};
auto commands = base().getAllCompileCommands();
for (const auto &command : commands) {
result += std::count_if(files.begin(), files.end(),
[&command](const auto &file) { return command.Filename == file; });
}
return result;
}
void compilation_database::adjust_compilation_database(
std::vector<clang::tooling::CompileCommand> &commands) const
{

View File

@@ -103,6 +103,8 @@ public:
std::string guess_language_from_filename(const std::string &filename) const;
long count_matching_commands(const std::vector<std::string> &files) const;
private:
void adjust_compilation_database(
std::vector<clang::tooling::CompileCommand> &commands) const;

View File

@@ -246,13 +246,16 @@ void generate_diagrams(const std::vector<std::string> &diagram_names,
continue;
}
const auto matching_commands_count =
db->count_matching_commands(valid_translation_units);
auto generator = [&name = name, &diagram = diagram, &indicator,
db = std::ref(*db),
db = std::ref(*db), matching_commands_count,
translation_units = valid_translation_units,
runtime_config]() mutable {
try {
if (indicator)
indicator->add_progress_bar(name, translation_units.size(),
indicator->add_progress_bar(name, matching_commands_count,
diagram_type_to_color(diagram->type()));
generate_diagram(name, diagram, db, translation_units,