Force all and extra warnings as errors except for tests

This commit is contained in:
Bartek Kryza
2022-06-08 20:32:32 +02:00
parent fbcecdab50
commit 0e7c30541a
20 changed files with 45 additions and 51 deletions

View File

@@ -46,7 +46,8 @@ set(LLVM_PREFERRED_VERSION 12.0.0)
# to use custom LLVM version
find_package(LibClang REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 ${LIBCLANG_CXXFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -std=c++17 ${LIBCLANG_CXXFLAGS}")
message(STATUS "Using CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# Thirdparty sources

View File

@@ -450,8 +450,6 @@ void generator::generate(const package &p, std::ostream &ostr) const
void generator::generate_relationships(
const package &p, std::ostream &ostr) const
{
const auto &uns = m_config.using_namespace();
for (const auto &subpackage : p) {
if (dynamic_cast<package *>(subpackage.get())) {
// TODO: add option - generate_empty_packages

View File

@@ -174,7 +174,7 @@ int class_::calculate_template_specialization_match(
}
// Iterate over all template arguments
for (int i = 0; i < other.templates().size(); i++) {
for (auto i = 0U; i < other.templates().size(); i++) {
const auto &template_arg = templates().at(i);
const auto &other_template_arg = other.templates().at(i);

View File

@@ -901,10 +901,10 @@ void translation_unit_visitor::process_field(
!template_instantiation_added_as_aggregation &&
(tr.kind() != cppast::cpp_type_kind::builtin_t) &&
(tr.kind() != cppast::cpp_type_kind::template_parameter_t)) {
const auto &ttt = resolve_alias(mv.type());
found_relationships_t relationships;
auto found = find_relationships(ttt, relationships);
const auto &unaliased_type = resolve_alias(mv.type());
find_relationships(unaliased_type, relationships);
for (const auto &[type, relationship_type] : relationships) {
if (relationship_type != relationship_t::kNone) {
@@ -1350,9 +1350,9 @@ void translation_unit_visitor::process_friend(const cppast::cpp_friend &f,
{
// Only process friends to other classes or class templates
if (!f.entity() ||
(f.entity().value().kind() != cppast::cpp_entity_kind::class_t) &&
((f.entity().value().kind() != cppast::cpp_entity_kind::class_t) &&
(f.entity().value().kind() !=
cppast::cpp_entity_kind::class_template_t))
cppast::cpp_entity_kind::class_template_t)))
return;
relationship r{relationship_t::kFriendship, "",
@@ -1384,11 +1384,11 @@ void translation_unit_visitor::process_friend(const cppast::cpp_friend &f,
f.entity().value());
const auto &class_ = ft.class_();
auto scope = cppast::cpp_scope_name(type_safe::ref(ft));
if (ft.class_().user_data() == nullptr) {
if (class_.user_data() == nullptr) {
spdlog::warn(
"Empty user data in friend class template: {}, {}, {}",
ft.name(),
fmt::ptr(reinterpret_cast<const void *>(&ft.class_())),
fmt::ptr(reinterpret_cast<const void *>(&class_)),
scope.name());
return;
}
@@ -1940,8 +1940,6 @@ void translation_unit_visitor::
const auto &function_argument =
static_cast<const cppast::cpp_function_type &>(targ_type);
const auto &rt = function_argument.return_type();
// Search for relationships in argument return type
// TODO...

View File

@@ -261,7 +261,7 @@ std::unique_ptr<DiagramModel> generate(
diagram->set_complete(true);
return std::move(diagram);
return diagram;
}
template <typename C, typename D> void generator<C, D>::init_context()

View File

@@ -42,7 +42,7 @@ public:
std::string name() const { return name_; }
virtual std::string full_name(bool relative) const { return name(); }
virtual std::string full_name(bool /*relative*/) const { return name(); }
std::vector<relationship> &relationships();

View File

@@ -90,31 +90,31 @@ filter_visitor::filter_visitor(filter_t type)
}
tvl::value_t filter_visitor::match(
const diagram &d, const common::model::element &e) const
const diagram & /*d*/, const common::model::element & /*e*/) const
{
return {};
}
tvl::value_t filter_visitor::match(
const diagram &d, const common::model::relationship_t &r) const
const diagram & /*d*/, const common::model::relationship_t & /*r*/) const
{
return {};
}
tvl::value_t filter_visitor::match(
const diagram &d, const common::model::access_t &a) const
const diagram & /*d*/, const common::model::access_t & /*a*/) const
{
return {};
}
tvl::value_t filter_visitor::match(
const diagram &d, const common::model::namespace_ &ns) const
const diagram & /*d*/, const common::model::namespace_ & /*ns*/) const
{
return {};
}
tvl::value_t filter_visitor::match(
const diagram &d, const common::model::source_file &f) const
const diagram & /*d*/, const common::model::source_file & /*f*/) const
{
return {};
}
@@ -160,7 +160,7 @@ namespace_filter::namespace_filter(
}
tvl::value_t namespace_filter::match(
const diagram &d, const namespace_ &ns) const
const diagram & /*d*/, const namespace_ &ns) const
{
if (ns.is_empty())
return {};
@@ -169,7 +169,8 @@ tvl::value_t namespace_filter::match(
[&ns](const auto &nsit) { return ns.starts_with(nsit) || ns == nsit; });
}
tvl::value_t namespace_filter::match(const diagram &d, const element &e) const
tvl::value_t namespace_filter::match(
const diagram & /*d*/, const element &e) const
{
if (dynamic_cast<const package *>(&e) != nullptr) {
return tvl::any_of(
@@ -193,7 +194,8 @@ element_filter::element_filter(filter_t type, std::vector<std::string> elements)
{
}
tvl::value_t element_filter::match(const diagram &d, const element &e) const
tvl::value_t element_filter::match(
const diagram & /*d*/, const element &e) const
{
return tvl::any_of(elements_.begin(), elements_.end(),
[&e](const auto &el) { return e.full_name(false) == el; });
@@ -253,7 +255,7 @@ relationship_filter::relationship_filter(
}
tvl::value_t relationship_filter::match(
const diagram &d, const relationship_t &r) const
const diagram & /*d*/, const relationship_t &r) const
{
return tvl::any_of(relationships_.begin(), relationships_.end(),
[&r](const auto &rel) { return r == rel; });
@@ -265,7 +267,8 @@ access_filter::access_filter(filter_t type, std::vector<access_t> access)
{
}
tvl::value_t access_filter::match(const diagram &d, const access_t &a) const
tvl::value_t access_filter::match(
const diagram & /*d*/, const access_t &a) const
{
return tvl::any_of(access_.begin(), access_.end(),
[&a](const auto &access) { return a == access; });
@@ -349,7 +352,7 @@ paths_filter::paths_filter(filter_t type, const std::filesystem::path &root,
}
tvl::value_t paths_filter::match(
const diagram &d, const common::model::source_file &p) const
const diagram & /*d*/, const common::model::source_file &p) const
{
if (paths_.empty()) {
return {};

View File

@@ -131,8 +131,8 @@ struct edge_traversal_filter : public filter_visitor {
edge_traversal_filter(filter_t type, relationship_t relationship,
std::vector<std::string> roots, bool forward = false)
: filter_visitor{type}
, relationship_{relationship}
, roots_{roots}
, relationship_{relationship}
, forward_{forward}
{
}

View File

@@ -55,7 +55,7 @@ public:
const namespace_ &path() const { return ns_; }
std::string full_name(bool relative) const override
std::string full_name(bool /*relative*/) const override
{
return name_and_ns();
}

View File

@@ -26,10 +26,10 @@ relationship::relationship(relationship_t type, const std::string &destination,
const std::string &multiplicity_destination)
: type_{type}
, destination_{destination}
, access_{access}
, label_{label}
, multiplicity_source_{multiplicity_source}
, multiplicity_destination_{multiplicity_destination}
, label_{label}
, access_{access}
{
}

View File

@@ -56,11 +56,11 @@ public:
friend bool operator==(const relationship &l, const relationship &r);
private:
relationship_t type_{relationship_t::kAssociation};
relationship_t type_;
std::string destination_;
std::string multiplicity_source_;
std::string multiplicity_destination_;
std::string label_;
access_t access_{access_t::kPublic};
access_t access_;
};
}

View File

@@ -72,7 +72,7 @@ public:
const filesystem_path &path() const { return path_; }
std::string full_name(bool relative) const override
std::string full_name(bool /*relative*/) const override
{
return (path_ | name()).to_string();
}

View File

@@ -262,7 +262,6 @@ parse_unexposed_template_params(const std::string &params,
std::vector<template_parameter> res;
int nested_template_level{0};
auto it = params.begin();
std::string type{};

View File

@@ -119,12 +119,13 @@ std::shared_ptr<decorator> note::from_string(std::string_view c)
return res;
}
std::shared_ptr<decorator> skip::from_string(std::string_view c)
std::shared_ptr<decorator> skip::from_string(std::string_view /*c*/)
{
return std::make_shared<skip>();
}
std::shared_ptr<decorator> skip_relationship::from_string(std::string_view c)
std::shared_ptr<decorator> skip_relationship::from_string(
std::string_view /*c*/)
{
return std::make_shared<skip_relationship>();
}

View File

@@ -40,7 +40,7 @@ void translation_unit_visitor::operator()(const cppast::cpp_entity &file)
process_source_file(static_cast<const cppast::cpp_file &>(file));
cppast::visit(file,
[&, this](const cppast::cpp_entity &e, cppast::visitor_info info) {
[&, this](const cppast::cpp_entity &e, cppast::visitor_info /*info*/) {
if (e.kind() == cppast::cpp_entity_kind::include_directive_t) {
const auto &inc =
static_cast<const cppast::cpp_include_directive &>(e);

View File

@@ -215,34 +215,26 @@ void translation_unit_visitor::operator()(const cppast::cpp_entity &file)
LOG_DBG("========== Visiting '{}' - {}",
cx::util::full_name(ctx.get_namespace(), e),
cppast::to_string(e.kind()));
auto &at = static_cast<const cppast::cpp_alias_template &>(e);
}
});
}
void translation_unit_visitor::process_class_declaration(
const cppast::cpp_class &cls,
type_safe::optional_ref<const cppast::cpp_template_specialization> tspec)
type_safe::optional_ref<
const cppast::cpp_template_specialization> /*tspec*/)
{
auto current_package = ctx.get_current_package();
if (!current_package)
return;
cppast::cpp_access_specifier_kind last_access_specifier =
cppast::cpp_access_specifier_kind::cpp_private;
std::vector<std::pair<std::string, relationship_t>> relationships;
// Process class elements
for (auto &child : cls) {
auto name = child.name();
if (child.kind() == cppast::cpp_entity_kind::access_specifier_t) {
auto &as = static_cast<const cppast::cpp_access_specifier &>(child);
last_access_specifier = as.access_specifier();
}
else if (child.kind() == cppast::cpp_entity_kind::member_variable_t) {
if (child.kind() == cppast::cpp_entity_kind::member_variable_t) {
auto &mv = static_cast<const cppast::cpp_member_variable &>(child);
find_relationships(
mv.type(), relationships, relationship_t::kDependency);

View File

@@ -29,7 +29,7 @@ common::model::diagram_t diagram::type() const
}
type_safe::optional_ref<const common::model::diagram_element> diagram::get(
const std::string &full_name) const
const std::string & /*full_name*/) const
{
return {};
}

View File

@@ -138,7 +138,7 @@ void translation_unit_visitor::operator()(const cppast::cpp_entity &file)
using cppast::cpp_member_function_call;
using cppast::visitor_info;
cppast::visit(file, [&, this](const cpp_entity &e, visitor_info info) {
cppast::visit(file, [&, this](const cpp_entity &e, visitor_info /*info*/) {
if (e.kind() == cpp_entity_kind::function_t) {
const auto &function = static_cast<const cpp_function &>(e);
process_activities(function);

View File

@@ -109,7 +109,7 @@ std::vector<std::string> split(std::string str, std::string_view delimiter)
result.push_back(str);
else
while (str.size()) {
int index = str.find(delimiter);
auto index = str.find(delimiter);
if (index != std::string::npos) {
result.push_back(str.substr(0, index));
str = str.substr(index + delimiter.size());

View File

@@ -4,6 +4,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-std=c++17 ${LIBCLANG_CXXFLAGS}")
file(GLOB_RECURSE TEST_CASE_SOURCES t*/*.cc)
file(GLOB_RECURSE TEST_CASE_CONFIGS t*/.clang-uml)
file(GLOB_RECURSE TEST_CONFIG_YMLS test_config_data/*.yml)