Fixed clang-tidy warnings

This commit is contained in:
Bartek Kryza
2023-03-25 22:49:47 +01:00
parent 90307793d8
commit fc3110fd4e
9 changed files with 44 additions and 42 deletions

View File

@@ -54,12 +54,12 @@ void to_json(nlohmann::json &j, const element &c)
void to_json(nlohmann::json &j, const template_parameter &c)
{
j["kind"] = to_string(c.kind());
if (c.type())
j["type"] = c.type().value();
if (c.name())
j["name"] = c.name().value();
if (c.default_value())
j["default"] = c.default_value().value();
if (const auto &t = c.type(); t)
j["type"] = t.value();
if (const auto &n = c.name(); n)
j["name"] = n.value();
if (const auto &d = c.default_value(); d)
j["default"] = d.value();
j["is_variadic"] = c.is_variadic();
j["template_parameters"] = c.template_params();
}

View File

@@ -81,7 +81,7 @@ std::string to_string(message_t m);
std::string to_string(diagram_t r);
std::string to_string(message_scope_t);
std::string to_string(message_scope_t t);
diagram_t from_string(const std::string &s);

View File

@@ -44,20 +44,21 @@ std::string to_string(template_parameter_kind_t k);
/// nested templates
class template_parameter {
public:
static template_parameter make_template_type(std::string name,
static template_parameter make_template_type(const std::string &name,
const std::optional<std::string> &default_value = {},
bool is_variadic = false)
{
template_parameter p;
p.set_kind(template_parameter_kind_t::template_type);
p.set_name(std::move(name));
p.set_name(name);
p.is_variadic(is_variadic);
if (default_value)
p.set_default_value(default_value.value());
return p;
}
static template_parameter make_template_template_type(std::string name,
static template_parameter make_template_template_type(
const std::string &name,
const std::optional<std::string> &default_value = {},
bool is_variadic = false)
{
@@ -70,14 +71,14 @@ public:
return p;
}
static template_parameter make_non_type_template(std::string type,
static template_parameter make_non_type_template(const std::string &type,
const std::optional<std::string> &name,
const std::optional<std::string> &default_value = {},
bool is_variadic = false)
{
template_parameter p;
p.set_kind(template_parameter_kind_t::non_type_template);
p.set_type(std::move(type));
p.set_type(type);
if (name)
p.set_name(name.value());
if (default_value)
@@ -86,21 +87,21 @@ public:
return p;
}
static template_parameter make_argument(
std::string type, const std::optional<std::string> &default_value = {})
static template_parameter make_argument(const std::string &type,
const std::optional<std::string> &default_value = {})
{
template_parameter p;
p.set_kind(template_parameter_kind_t::argument);
p.set_type(std::move(type));
p.set_type(type);
if (default_value)
p.set_default_value(default_value.value());
return p;
}
static template_parameter make_unexposed_argument(
std::string type, const std::optional<std::string> &default_value = {})
static template_parameter make_unexposed_argument(const std::string &type,
const std::optional<std::string> &default_value = {})
{
template_parameter p = make_argument(std::move(type), default_value);
template_parameter p = make_argument(type, default_value);
p.set_unexposed(true);
return p;
}
@@ -178,7 +179,7 @@ public:
private:
template_parameter() = default;
template_parameter_kind_t kind_;
template_parameter_kind_t kind_{template_parameter_kind_t::template_type};
/// Represents the type of non-type template parameters
/// e.g. 'int' or type of template arguments