Fixed release build

This commit is contained in:
Bartek Kryza
2022-06-08 23:33:53 +02:00
parent 0e7c30541a
commit 844bfcdbcd
8 changed files with 45 additions and 28 deletions

View File

@@ -250,6 +250,7 @@ void generator::generate_relationships(
std::stringstream all_relations_str;
std::set<std::string> unique_relations;
for (const auto &r : c.relationships()) {
if (!m_model.should_include(r.type()))
continue;

View File

@@ -28,6 +28,8 @@ public:
class_member(common::model::access_t access, const std::string &name,
const std::string &type);
virtual ~class_member() = default;
bool is_relationship() const;
void is_relationship(bool is_relationship);

View File

@@ -139,8 +139,9 @@ bool diagram::add_class(std::unique_ptr<class_> &&c)
const auto &el = get_element<class_>(name_and_ns).value();
assert(el.name() == name);
assert(el.get_relative_namespace() == ns);
if ((el.name() != name) || !(el.get_relative_namespace() == ns))
throw std::runtime_error(
"Invalid element stored in the diagram tree");
return true;
}

View File

@@ -139,7 +139,7 @@ void translation_unit_visitor::operator()(const cppast::cpp_entity &file)
auto &cls = static_cast<const cppast::cpp_class &>(e);
if (cppast::get_definition(ctx.entity_index(), cls)) {
auto &clsdef = static_cast<const cppast::cpp_class &>(
const auto &clsdef = static_cast<const cppast::cpp_class &>(
cppast::get_definition(ctx.entity_index(), cls)
.value());
if (&cls != &clsdef) {
@@ -862,7 +862,7 @@ void translation_unit_visitor::process_field(
if (m.skip())
return;
auto &tr = cx::util::unreferenced(cppast::remove_cv(mv.type()));
const auto &tr = cx::util::unreferenced(cppast::remove_cv(mv.type()));
auto tr_declaration = cppast::to_string(tr);
@@ -995,7 +995,8 @@ void translation_unit_visitor::process_method(
if (m.skip())
return;
for (auto &param : mf.parameters())
const auto params = mf.parameters();
for (auto &param : params)
process_function_parameter(param, m, c);
LOG_DBG("Adding method: {}", m.name());
@@ -1040,11 +1041,13 @@ void translation_unit_visitor::process_template_method(
return;
std::set<std::string> template_parameter_names;
for (const auto &template_parameter : mf.parameters()) {
const auto template_params = mf.parameters();
for (const auto &template_parameter : template_params) {
template_parameter_names.emplace(template_parameter.name());
}
for (auto &param : mf.function().parameters())
const auto params = mf.function().parameters();
for (auto &param : params)
process_function_parameter(param, m, c, template_parameter_names);
LOG_DBG("Adding template method: {}", m.name());
@@ -1229,6 +1232,9 @@ void translation_unit_visitor::
auto &template_instantiation_type =
static_cast<const cppast::cpp_template_instantiation_type &>(t);
const auto &full_name =
cx::util::full_name(cppast::remove_cv(t), ctx.entity_index(), false);
if (template_instantiation_type.primary_template()
.get(ctx.entity_index())
.size()) {
@@ -1241,8 +1247,8 @@ void translation_unit_visitor::
LOG_DBG("Processing template method argument exposed "
"parameters...");
for (const auto &template_argument :
template_instantiation_type.arguments().value()) {
const auto targs = template_instantiation_type.arguments();
for (const auto &template_argument : targs.value()) {
if (!template_argument.type().has_value())
continue;
@@ -1272,18 +1278,18 @@ void translation_unit_visitor::
}
if (template_is_not_instantiation) {
relationship rr{relationship_t::kDependency, full_name};
LOG_DBG("Template is not an instantiation - "
"only adding reference to template {}",
cx::util::full_name(
cppast::remove_cv(t), ctx.entity_index(), false));
relationship rr{relationship_t::kDependency,
cx::util::full_name(
cppast::remove_cv(t), ctx.entity_index(), false)};
full_name);
LOG_DBG("Adding field template dependency relationship "
"{} {} {} "
": {}",
rr.destination(), common::model::to_string(rr.type()),
c.full_name(), rr.label());
c.add_relationship(std::move(rr));
}
else {
@@ -1483,8 +1489,6 @@ bool translation_unit_visitor::find_relationships_in_template_instantiation(
assert(tinst.arguments().has_value());
assert(tinst.arguments().value().size() > 0u);
[[maybe_unused]] const auto args_count = tinst.arguments().value().size();
const auto args = tinst.arguments().value();
const auto [ns, base_name] = cx::util::split_ns(fn);
@@ -1542,7 +1546,8 @@ bool translation_unit_visitor::find_relationships_in_user_defined_type(
const std::string &fn, relationship_t &relationship_type,
const cppast::cpp_type &t) const
{
bool found;
bool found{false};
LOG_DBG("Finding relationships in user defined type: {} | {}",
cppast::to_string(t_), cppast::to_string(t_.canonical()));
@@ -1715,7 +1720,8 @@ std::unique_ptr<class_> translation_unit_visitor::build_template_instantiation(
// to the variadic tuple
auto has_variadic_params = false;
for (const auto &targ : t.arguments().value()) {
const auto targs = t.arguments().value();
for (const auto &targ : targs) {
template_parameter ct;
if (targ.type()) {
build_template_instantiation_process_type_argument(
@@ -1821,12 +1827,14 @@ void translation_unit_visitor::
build_template_instantiation_process_expression_argument(
const cppast::cpp_template_argument &targ, template_parameter &ct) const
{
const auto &exp = targ.expression().value();
if (exp.kind() == cppast::cpp_expression_kind::literal_t)
const auto exp = targ.expression();
if (exp.value().kind() == cppast::cpp_expression_kind::literal_t)
ct.set_type(
static_cast<const cppast::cpp_literal_expression &>(exp).value());
else if (exp.kind() == cppast::cpp_expression_kind::unexposed_t)
ct.set_type(static_cast<const cppast::cpp_unexposed_expression &>(exp)
static_cast<const cppast::cpp_literal_expression &>(exp.value())
.value());
else if (exp.value().kind() == cppast::cpp_expression_kind::unexposed_t)
ct.set_type(
static_cast<const cppast::cpp_unexposed_expression &>(exp.value())
.expression()
.as_string());

View File

@@ -48,6 +48,7 @@ std::string to_string(relationship_t r)
return "alias";
default:
assert(false);
return "";
}
}
@@ -62,6 +63,7 @@ std::string to_string(access_t a)
return "private";
default:
assert(false);
return "";
}
}
@@ -74,6 +76,7 @@ std::string to_string(message_t r)
return "return";
default:
assert(false);
return "";
}
}
@@ -90,6 +93,7 @@ std::string to_string(const diagram_t t)
return "include";
default:
assert(false);
return "";
}
}

View File

@@ -73,6 +73,7 @@ std::string to_string(const hint_t t)
return "right";
default:
assert(false);
return "";
}
}

View File

@@ -434,7 +434,7 @@ bool translation_unit_visitor::find_relationships(const cppast::cpp_type &t_,
}
}
else if (t.kind() == cppast::cpp_type_kind::template_instantiation_t) {
auto &tinst =
const auto &tinst =
static_cast<const cppast::cpp_template_instantiation_type &>(t);
if (!tinst.arguments_exposed()) {
@@ -443,7 +443,7 @@ bool translation_unit_visitor::find_relationships(const cppast::cpp_type &t_,
return found;
}
const auto &args = tinst.arguments().value();
const auto args = tinst.arguments().value();
// Try to match common containers
// TODO: Refactor to a separate class with configurable

View File

@@ -267,7 +267,7 @@ static inline std::vector<fs::path> rlistdir(
// This helper function recursively yields relative pathnames inside a literal
// directory.
static inline std::vector<fs::path> glob2(
const fs::path &dirname, const std::string &pattern, bool dironly)
const fs::path &dirname, [[maybe_unused]] const std::string &pattern, bool dironly)
{
// std::cout << "In glob2\n";
std::vector<fs::path> result;