From e7cb6c0fb220b8360761a19d2671d4fb9caf05a9 Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Sat, 3 Sep 2022 11:13:59 +0200 Subject: [PATCH] Fixed include graph diagram visitor --- src/common/model/nested_trait.h | 2 -- .../visitor/translation_unit_visitor.cc | 29 +++++++------------ .../visitor/translation_unit_visitor.h | 3 -- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/common/model/nested_trait.h b/src/common/model/nested_trait.h index e902ad0b..285f69f2 100644 --- a/src/common/model/nested_trait.h +++ b/src/common/model/nested_trait.h @@ -79,8 +79,6 @@ public: template auto get_element(const Path &path) const { - LOG_DBG("Getting nested element at path: {}", path.to_string()); - if (path.is_empty() || !has_element(path[0])) { LOG_DBG("Nested element {} not found in element", path.to_string()); return optional_ref{}; diff --git a/src/include_diagram/visitor/translation_unit_visitor.cc b/src/include_diagram/visitor/translation_unit_visitor.cc index b7267df1..dda9dbc6 100644 --- a/src/include_diagram/visitor/translation_unit_visitor.cc +++ b/src/include_diagram/visitor/translation_unit_visitor.cc @@ -69,15 +69,9 @@ void translation_unit_visitor::include_visitor::InclusionDirective( include_path = include_path / file->getName().str(); include_path = include_path.lexically_normal(); - if (!diagram().should_include(source_file{include_path}) || - visited_.find(include_path.string()) != visited_.end()) - return; - - LOG_DBG("Processing include file {} in file {}", include_path.string(), + LOG_DBG("Processing include directive {} in file {}", include_path.string(), current_file.string()); - visited_.emplace(include_path.string()); - auto relative_include_path = include_path; if (config().relative_to) { const std::filesystem::path relative_to{config().relative_to()}; @@ -181,8 +175,6 @@ translation_unit_visitor::include_visitor::process_source_file( using common::model::source_file; using common::model::source_file_t; - LOG_DBG("Processing source file {}", file.string()); - auto file_path = std::filesystem::path{file}; // Make sure the file_path is absolute with respect to the @@ -193,14 +185,17 @@ translation_unit_visitor::include_visitor::process_source_file( file_path = file_path.lexically_normal(); - // Relativize the path with respect to relative_to config option - auto relative_file_path = file_path; - if (config().relative_to) { - const std::filesystem::path relative_to{config().relative_to()}; - relative_file_path = std::filesystem::relative(file_path, relative_to); - } - if (diagram().should_include(source_file{file_path})) { + LOG_DBG("Processing source file {}", file.string()); + + // Relativize the path with respect to relative_to config option + auto relative_file_path = file_path; + if (config().relative_to) { + const std::filesystem::path relative_to{config().relative_to()}; + relative_file_path = + std::filesystem::relative(file_path, relative_to); + } + [[maybe_unused]] const auto relative_file_path_str = relative_file_path.string(); @@ -231,8 +226,6 @@ translation_unit_visitor::include_visitor::process_source_file( return source_file.id(); } - LOG_DBG("Skipping source file {}", file_path.string()); - return {}; } diff --git a/src/include_diagram/visitor/translation_unit_visitor.h b/src/include_diagram/visitor/translation_unit_visitor.h index 277e26be..c74bcb19 100644 --- a/src/include_diagram/visitor/translation_unit_visitor.h +++ b/src/include_diagram/visitor/translation_unit_visitor.h @@ -81,9 +81,6 @@ public: // Reference to class diagram config const clanguml::config::include_diagram &config_; - - // Keep track of already visited headers and source files - std::set visited_; }; translation_unit_visitor(clang::SourceManager &sm,