Applied readability-implicit-bool-conversion fixes
This commit is contained in:
@@ -438,19 +438,19 @@ void generator::generate(const package &p, std::ostream &ostr) const
|
||||
}
|
||||
|
||||
for (const auto &subpackage : p) {
|
||||
if (dynamic_cast<package *>(subpackage.get())) {
|
||||
if (dynamic_cast<package *>(subpackage.get()) != nullptr) {
|
||||
// TODO: add option - generate_empty_packages
|
||||
const auto &sp = dynamic_cast<package &>(*subpackage);
|
||||
if (!sp.is_empty())
|
||||
generate(sp, ostr);
|
||||
}
|
||||
else if (dynamic_cast<class_ *>(subpackage.get())) {
|
||||
else if (dynamic_cast<class_ *>(subpackage.get()) != nullptr) {
|
||||
if (m_model.should_include(*subpackage)) {
|
||||
generate_alias(dynamic_cast<class_ &>(*subpackage), ostr);
|
||||
generate(dynamic_cast<class_ &>(*subpackage), ostr);
|
||||
}
|
||||
}
|
||||
else if (dynamic_cast<enum_ *>(subpackage.get())) {
|
||||
else if (dynamic_cast<enum_ *>(subpackage.get()) != nullptr) {
|
||||
if (m_model.should_include(*subpackage)) {
|
||||
generate_alias(dynamic_cast<enum_ &>(*subpackage), ostr);
|
||||
generate(dynamic_cast<enum_ &>(*subpackage), ostr);
|
||||
@@ -473,19 +473,19 @@ void generator::generate_relationships(
|
||||
const package &p, std::ostream &ostr) const
|
||||
{
|
||||
for (const auto &subpackage : p) {
|
||||
if (dynamic_cast<package *>(subpackage.get())) {
|
||||
if (dynamic_cast<package *>(subpackage.get()) != nullptr) {
|
||||
// TODO: add option - generate_empty_packages
|
||||
const auto &sp = dynamic_cast<package &>(*subpackage);
|
||||
if (!sp.is_empty())
|
||||
generate_relationships(sp, ostr);
|
||||
}
|
||||
else if (dynamic_cast<class_ *>(subpackage.get())) {
|
||||
else if (dynamic_cast<class_ *>(subpackage.get()) != nullptr) {
|
||||
if (m_model.should_include(*subpackage)) {
|
||||
generate_relationships(
|
||||
dynamic_cast<class_ &>(*subpackage), ostr);
|
||||
}
|
||||
}
|
||||
else if (dynamic_cast<enum_ *>(subpackage.get())) {
|
||||
else if (dynamic_cast<enum_ *>(subpackage.get()) != nullptr) {
|
||||
if (m_model.should_include(*subpackage)) {
|
||||
generate_relationships(
|
||||
dynamic_cast<enum_ &>(*subpackage), ostr);
|
||||
@@ -503,18 +503,18 @@ void generator::generate(std::ostream &ostr) const
|
||||
generate_plantuml_directives(ostr, m_config.puml().before);
|
||||
|
||||
for (const auto &p : m_model) {
|
||||
if (dynamic_cast<package *>(p.get())) {
|
||||
if (dynamic_cast<package *>(p.get()) != nullptr) {
|
||||
const auto &sp = dynamic_cast<package &>(*p);
|
||||
if (!sp.is_empty())
|
||||
generate(sp, ostr);
|
||||
}
|
||||
else if (dynamic_cast<class_ *>(p.get())) {
|
||||
else if (dynamic_cast<class_ *>(p.get()) != nullptr) {
|
||||
if (m_model.should_include(*p)) {
|
||||
generate_alias(dynamic_cast<class_ &>(*p), ostr);
|
||||
generate(dynamic_cast<class_ &>(*p), ostr);
|
||||
}
|
||||
}
|
||||
else if (dynamic_cast<enum_ *>(p.get())) {
|
||||
else if (dynamic_cast<enum_ *>(p.get()) != nullptr) {
|
||||
if (m_model.should_include(*p)) {
|
||||
generate_alias(dynamic_cast<enum_ &>(*p), ostr);
|
||||
generate(dynamic_cast<enum_ &>(*p), ostr);
|
||||
@@ -523,15 +523,15 @@ void generator::generate(std::ostream &ostr) const
|
||||
}
|
||||
|
||||
for (const auto &p : m_model) {
|
||||
if (dynamic_cast<package *>(p.get())) {
|
||||
if (dynamic_cast<package *>(p.get()) != nullptr) {
|
||||
generate_relationships(dynamic_cast<package &>(*p), ostr);
|
||||
}
|
||||
else if (dynamic_cast<class_ *>(p.get())) {
|
||||
else if (dynamic_cast<class_ *>(p.get()) != nullptr) {
|
||||
if (m_model.should_include(*p)) {
|
||||
generate_relationships(dynamic_cast<class_ &>(*p), ostr);
|
||||
}
|
||||
}
|
||||
else if (dynamic_cast<enum_ *>(p.get())) {
|
||||
else if (dynamic_cast<enum_ *>(p.get()) != nullptr) {
|
||||
if (m_model.should_include(*p)) {
|
||||
generate_relationships(dynamic_cast<enum_ &>(*p), ostr);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ bool translation_unit_visitor::VisitEnumDecl(clang::EnumDecl *enm)
|
||||
|
||||
const auto *parent = enm->getParent();
|
||||
|
||||
if (parent && parent->isRecord()) {
|
||||
if ((parent != nullptr) && parent->isRecord()) {
|
||||
// Here we have 2 options, either:
|
||||
// - the parent is a regular C++ class/struct
|
||||
// - the parent is a class template declaration/specialization
|
||||
@@ -140,7 +140,7 @@ bool translation_unit_visitor::VisitEnumDecl(clang::EnumDecl *enm)
|
||||
// If not, check if the parent template declaration is in the model
|
||||
if (!id_opt) {
|
||||
if (static_cast<const clang::RecordDecl *>(parent)
|
||||
->getDescribedTemplate()) {
|
||||
->getDescribedTemplate() != nullptr) {
|
||||
local_id = static_cast<const clang::RecordDecl *>(parent)
|
||||
->getDescribedTemplate()
|
||||
->getID();
|
||||
@@ -209,7 +209,7 @@ bool translation_unit_visitor::VisitClassTemplateSpecializationDecl(
|
||||
cls->getLocation().printToString(source_manager()));
|
||||
|
||||
// TODO: Add support for classes defined in function/method bodies
|
||||
if (cls->isLocalClass())
|
||||
if (cls->isLocalClass() != nullptr)
|
||||
return true;
|
||||
|
||||
auto template_specialization_ptr = process_template_specialization(cls);
|
||||
@@ -353,7 +353,7 @@ bool translation_unit_visitor::VisitCXXRecordDecl(clang::CXXRecordDecl *cls)
|
||||
->getQualifiedNameAsString());
|
||||
}
|
||||
|
||||
if (cls->isTemplated() && cls->getDescribedTemplate()) {
|
||||
if (cls->isTemplated() && (cls->getDescribedTemplate() != nullptr)) {
|
||||
// If the described templated of this class is already in the model
|
||||
// skip it:
|
||||
if (get_ast_local_id(cls->getDescribedTemplate()->getID()))
|
||||
@@ -361,7 +361,7 @@ bool translation_unit_visitor::VisitCXXRecordDecl(clang::CXXRecordDecl *cls)
|
||||
}
|
||||
|
||||
// TODO: Add support for classes defined in function/method bodies
|
||||
if (cls->isLocalClass())
|
||||
if (cls->isLocalClass() != nullptr)
|
||||
return true;
|
||||
|
||||
auto c_ptr = create_class_declaration(cls);
|
||||
@@ -420,7 +420,7 @@ std::unique_ptr<class_> translation_unit_visitor::create_class_declaration(
|
||||
|
||||
const auto *parent = cls->getParent();
|
||||
|
||||
if (parent && parent->isRecord()) {
|
||||
if ((parent != nullptr) && parent->isRecord()) {
|
||||
// Here we have 2 options, either:
|
||||
// - the parent is a regular C++ class/struct
|
||||
// - the parent is a class template declaration/specialization
|
||||
@@ -438,7 +438,7 @@ std::unique_ptr<class_> translation_unit_visitor::create_class_declaration(
|
||||
->getDescribedTemplate()
|
||||
->getID();
|
||||
if (static_cast<const clang::RecordDecl *>(parent)
|
||||
->getDescribedTemplate())
|
||||
->getDescribedTemplate() != nullptr)
|
||||
id_opt = get_ast_local_id(local_id);
|
||||
}
|
||||
|
||||
@@ -523,7 +523,8 @@ bool translation_unit_visitor::process_template_parameters(
|
||||
|
||||
for (const auto *parameter :
|
||||
*template_declaration.getTemplateParameters()) {
|
||||
if (clang::dyn_cast_or_null<clang::TemplateTypeParmDecl>(parameter)) {
|
||||
if (clang::dyn_cast_or_null<clang::TemplateTypeParmDecl>(parameter) !=
|
||||
nullptr) {
|
||||
const auto *template_type_parameter =
|
||||
clang::dyn_cast_or_null<clang::TemplateTypeParmDecl>(parameter);
|
||||
template_parameter ct;
|
||||
@@ -536,7 +537,7 @@ bool translation_unit_visitor::process_template_parameters(
|
||||
c.add_template(std::move(ct));
|
||||
}
|
||||
else if (clang::dyn_cast_or_null<clang::NonTypeTemplateParmDecl>(
|
||||
parameter)) {
|
||||
parameter) != nullptr) {
|
||||
const auto *template_nontype_parameter =
|
||||
clang::dyn_cast_or_null<clang::NonTypeTemplateParmDecl>(
|
||||
parameter);
|
||||
@@ -550,7 +551,7 @@ bool translation_unit_visitor::process_template_parameters(
|
||||
c.add_template(std::move(ct));
|
||||
}
|
||||
else if (clang::dyn_cast_or_null<clang::TemplateTemplateParmDecl>(
|
||||
parameter)) {
|
||||
parameter) != nullptr) {
|
||||
const auto *template_template_parameter =
|
||||
clang::dyn_cast_or_null<clang::TemplateTemplateParmDecl>(
|
||||
parameter);
|
||||
@@ -579,9 +580,9 @@ void translation_unit_visitor::process_template_record_containment(
|
||||
|
||||
const auto *parent = record.getParent(); //->getOuterLexicalRecordContext();
|
||||
|
||||
if (parent &&
|
||||
static_cast<const clang::RecordDecl *>(parent)
|
||||
->getDescribedTemplate()) {
|
||||
if ((parent != nullptr) &&
|
||||
(static_cast<const clang::RecordDecl *>(parent)
|
||||
->getDescribedTemplate() != nullptr)) {
|
||||
auto id_opt =
|
||||
get_ast_local_id(static_cast<const clang::RecordDecl *>(parent)
|
||||
->getDescribedTemplate()
|
||||
@@ -687,7 +688,7 @@ void translation_unit_visitor::process_template_specialization_children(
|
||||
if (decl->getKind() == clang::Decl::Var) {
|
||||
const clang::VarDecl *variable_declaration{
|
||||
dynamic_cast<const clang::VarDecl *>(decl)};
|
||||
if (variable_declaration &&
|
||||
if ((variable_declaration != nullptr) &&
|
||||
variable_declaration->isStaticDataMember()) {
|
||||
process_static_field(*variable_declaration, c);
|
||||
}
|
||||
@@ -749,7 +750,7 @@ void translation_unit_visitor::process_class_children(
|
||||
if (decl->getKind() == clang::Decl::Var) {
|
||||
const clang::VarDecl *variable_declaration{
|
||||
dynamic_cast<const clang::VarDecl *>(decl)};
|
||||
if (variable_declaration &&
|
||||
if ((variable_declaration != nullptr) &&
|
||||
variable_declaration->isStaticDataMember()) {
|
||||
process_static_field(*variable_declaration, c);
|
||||
}
|
||||
@@ -787,7 +788,7 @@ void translation_unit_visitor::process_friend(
|
||||
nullptr) {
|
||||
// TODO: handle template friend
|
||||
}
|
||||
else if (friend_type->getAs<clang::RecordType>()) {
|
||||
else if (friend_type->getAs<clang::RecordType>() != nullptr) {
|
||||
const auto friend_type_name =
|
||||
friend_type->getAsRecordDecl()->getQualifiedNameAsString();
|
||||
if (diagram().should_include(friend_type_name)) {
|
||||
@@ -938,7 +939,7 @@ bool translation_unit_visitor::find_relationships(const clang::QualType &type,
|
||||
// pass
|
||||
}
|
||||
else if (template_argument.getAsType()
|
||||
->getAs<clang::FunctionProtoType>()) {
|
||||
->getAs<clang::FunctionProtoType>() != nullptr) {
|
||||
for (const auto ¶m_type :
|
||||
template_argument.getAsType()
|
||||
->getAs<clang::FunctionProtoType>()
|
||||
@@ -1184,7 +1185,8 @@ void translation_unit_visitor::process_template_specialization_argument(
|
||||
|
||||
// If this is a nested template type - add nested templates as
|
||||
// template arguments
|
||||
if (arg.getAsType()->getAs<clang::TemplateSpecializationType>()) {
|
||||
if (arg.getAsType()->getAs<clang::TemplateSpecializationType>() !=
|
||||
nullptr) {
|
||||
const auto *nested_template_type =
|
||||
arg.getAsType()->getAs<clang::TemplateSpecializationType>();
|
||||
|
||||
@@ -1210,7 +1212,8 @@ void translation_unit_visitor::process_template_specialization_argument(
|
||||
simplify_system_template(argument,
|
||||
argument.to_string(config().using_namespace(), false));
|
||||
}
|
||||
else if (arg.getAsType()->getAs<clang::TemplateTypeParmType>()) {
|
||||
else if (arg.getAsType()->getAs<clang::TemplateTypeParmType>() !=
|
||||
nullptr) {
|
||||
auto type_name =
|
||||
common::to_string(arg.getAsType(), cls->getASTContext());
|
||||
|
||||
@@ -1480,8 +1483,8 @@ std::unique_ptr<class_> translation_unit_visitor::build_template_instantiation(
|
||||
|
||||
auto *template_type_ptr = &template_type_decl;
|
||||
if (template_type_decl.isTypeAlias() &&
|
||||
template_type_decl.getAliasedType()
|
||||
->getAs<clang::TemplateSpecializationType>())
|
||||
(template_type_decl.getAliasedType()
|
||||
->getAs<clang::TemplateSpecializationType>() != nullptr))
|
||||
template_type_ptr = template_type_decl.getAliasedType()
|
||||
->getAs<clang::TemplateSpecializationType>();
|
||||
|
||||
@@ -1505,8 +1508,9 @@ std::unique_ptr<class_> translation_unit_visitor::build_template_instantiation(
|
||||
auto *class_template_decl{
|
||||
clang::dyn_cast<clang::ClassTemplateDecl>(template_decl)};
|
||||
|
||||
if (class_template_decl && class_template_decl->getTemplatedDecl() &&
|
||||
class_template_decl->getTemplatedDecl()->getParent() &&
|
||||
if ((class_template_decl != nullptr) &&
|
||||
(class_template_decl->getTemplatedDecl() != nullptr) &&
|
||||
(class_template_decl->getTemplatedDecl()->getParent() != nullptr) &&
|
||||
class_template_decl->getTemplatedDecl()->getParent()->isRecord()) {
|
||||
|
||||
namespace_ ns{
|
||||
@@ -1559,7 +1563,8 @@ std::unique_ptr<class_> translation_unit_visitor::build_template_instantiation(
|
||||
clang::dyn_cast_or_null<clang::CXXRecordDecl>(
|
||||
template_decl->getTemplatedDecl());
|
||||
|
||||
if (templated_class_decl && templated_class_decl->hasDefinition())
|
||||
if ((templated_class_decl != nullptr) &&
|
||||
templated_class_decl->hasDefinition())
|
||||
for (const auto &base : templated_class_decl->bases()) {
|
||||
const auto base_class_name = common::to_string(
|
||||
base.getType(), templated_class_decl->getASTContext(), false);
|
||||
@@ -1738,19 +1743,19 @@ void translation_unit_visitor::
|
||||
|
||||
// If this is a nested template type - add nested templates as
|
||||
// template arguments
|
||||
if (arg.getAsType()->getAs<clang::FunctionType>()) {
|
||||
if (arg.getAsType()->getAs<clang::FunctionType>() != nullptr) {
|
||||
|
||||
for (const auto ¶m_type :
|
||||
arg.getAsType()->getAs<clang::FunctionProtoType>()->param_types()) {
|
||||
|
||||
if (!param_type->getAs<clang::RecordType>())
|
||||
if (param_type->getAs<clang::RecordType>() == nullptr)
|
||||
continue;
|
||||
|
||||
auto *classTemplateSpecialization =
|
||||
llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(
|
||||
param_type->getAsRecordDecl());
|
||||
|
||||
if (classTemplateSpecialization) {
|
||||
if (classTemplateSpecialization != nullptr) {
|
||||
// Read arg info as needed.
|
||||
auto nested_template_instantiation =
|
||||
build_template_instantiation_from_class_template_specialization(
|
||||
@@ -1784,7 +1789,8 @@ void translation_unit_visitor::
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (arg.getAsType()->getAs<clang::TemplateSpecializationType>()) {
|
||||
else if (arg.getAsType()->getAs<clang::TemplateSpecializationType>() !=
|
||||
nullptr) {
|
||||
const auto *nested_template_type =
|
||||
arg.getAsType()->getAs<clang::TemplateSpecializationType>();
|
||||
|
||||
@@ -1836,7 +1842,7 @@ void translation_unit_visitor::
|
||||
diagram().add_class(std::move(nested_template_instantiation));
|
||||
}
|
||||
}
|
||||
else if (arg.getAsType()->getAs<clang::TemplateTypeParmType>()) {
|
||||
else if (arg.getAsType()->getAs<clang::TemplateTypeParmType>() != nullptr) {
|
||||
argument.is_template_parameter(true);
|
||||
argument.set_name(
|
||||
common::to_string(arg.getAsType(), template_decl->getASTContext()));
|
||||
@@ -1884,8 +1890,9 @@ void translation_unit_visitor::
|
||||
argument.set_name(
|
||||
common::to_string(arg.getAsType(), template_decl->getASTContext()));
|
||||
|
||||
if (arg.getAsType()->getAs<clang::RecordType>() &&
|
||||
arg.getAsType()->getAs<clang::RecordType>()->getAsRecordDecl()) {
|
||||
if ((arg.getAsType()->getAs<clang::RecordType>() != nullptr) &&
|
||||
(arg.getAsType()->getAs<clang::RecordType>()->getAsRecordDecl() !=
|
||||
nullptr)) {
|
||||
argument.set_id(common::to_id(arg));
|
||||
|
||||
if (diagram().should_include(full_template_specialization_name)) {
|
||||
@@ -1895,8 +1902,9 @@ void translation_unit_visitor::
|
||||
{relationship_t::kDependency, common::to_id(arg)});
|
||||
}
|
||||
}
|
||||
else if (arg.getAsType()->getAs<clang::EnumType>()) {
|
||||
if (arg.getAsType()->getAs<clang::EnumType>()->getAsTagDecl()) {
|
||||
else if (arg.getAsType()->getAs<clang::EnumType>() != nullptr) {
|
||||
if (arg.getAsType()->getAs<clang::EnumType>()->getAsTagDecl() !=
|
||||
nullptr) {
|
||||
template_instantiation.add_relationship(
|
||||
{relationship_t::kDependency, common::to_id(arg)});
|
||||
}
|
||||
@@ -2087,7 +2095,7 @@ void translation_unit_visitor::process_field(
|
||||
// Find relationship for the type if the type has not been added
|
||||
// as aggregation
|
||||
if (!template_instantiation_added_as_aggregation) {
|
||||
if (field_type->getAsCXXRecordDecl() &&
|
||||
if ((field_type->getAsCXXRecordDecl() != nullptr) &&
|
||||
field_type->getAsCXXRecordDecl()->getNameAsString().empty()) {
|
||||
// Relationships to fields whose type is an anonymous nested
|
||||
// struct have to be handled separately here
|
||||
|
||||
@@ -67,13 +67,13 @@ model::namespace_ get_tag_namespace(const clang::TagDecl &declaration)
|
||||
const auto *parent{declaration.getParent()};
|
||||
|
||||
// First walk up to the nearest namespace, e.g. from nested class or enum
|
||||
while (parent && !parent->isNamespace()) {
|
||||
while ((parent != nullptr) && !parent->isNamespace()) {
|
||||
parent = parent->getParent();
|
||||
}
|
||||
|
||||
// Now build up the namespace
|
||||
std::deque<std::string> namespace_tokens;
|
||||
while (parent && parent->isNamespace()) {
|
||||
while ((parent != nullptr) && parent->isNamespace()) {
|
||||
const auto *ns_decl = static_cast<const clang::NamespaceDecl *>(parent);
|
||||
if (!ns_decl->isInline() && !ns_decl->isAnonymousNamespace())
|
||||
namespace_tokens.push_front(ns_decl->getNameAsString());
|
||||
@@ -96,7 +96,8 @@ std::string get_tag_name(const clang::TagDecl &declaration)
|
||||
fmt::format("(anonymous_{})", std::to_string(declaration.getID()));
|
||||
}
|
||||
|
||||
if (declaration.getParent() && declaration.getParent()->isRecord()) {
|
||||
if ((declaration.getParent() != nullptr) &&
|
||||
declaration.getParent()->isRecord()) {
|
||||
// If the record is nested within another record (e.g. class or struct)
|
||||
// we have to maintain a containment namespace in order to ensure
|
||||
// unique names within the diagram
|
||||
@@ -190,7 +191,8 @@ std::string to_string(const clang::FunctionTemplateDecl *decl)
|
||||
std::vector<std::string> template_parameters;
|
||||
// Handle template function
|
||||
for (const auto *parameter : *decl->getTemplateParameters()) {
|
||||
if (clang::dyn_cast_or_null<clang::TemplateTypeParmDecl>(parameter)) {
|
||||
if (clang::dyn_cast_or_null<clang::TemplateTypeParmDecl>(parameter) !=
|
||||
nullptr) {
|
||||
const auto *template_type_parameter =
|
||||
clang::dyn_cast_or_null<clang::TemplateTypeParmDecl>(parameter);
|
||||
|
||||
@@ -282,11 +284,12 @@ template <> id_t to_id(const std::filesystem::path &file)
|
||||
template <> id_t to_id(const clang::TemplateArgument &template_argument)
|
||||
{
|
||||
if (template_argument.getKind() == clang::TemplateArgument::Type) {
|
||||
if (template_argument.getAsType()->getAs<clang::EnumType>())
|
||||
if (template_argument.getAsType()->getAs<clang::EnumType>() != nullptr)
|
||||
return to_id(*template_argument.getAsType()
|
||||
->getAs<clang::EnumType>()
|
||||
->getAsTagDecl());
|
||||
if (template_argument.getAsType()->getAs<clang::RecordType>())
|
||||
if (template_argument.getAsType()->getAs<clang::RecordType>() !=
|
||||
nullptr)
|
||||
return to_id(*template_argument.getAsType()
|
||||
->getAs<clang::RecordType>()
|
||||
->getAsRecordDecl());
|
||||
|
||||
@@ -135,31 +135,31 @@ std::vector<std::string> diagram::get_translation_units(
|
||||
|
||||
void diagram::initialize_type_aliases()
|
||||
{
|
||||
if (!type_aliases().count("std::basic_string<char>")) {
|
||||
if (type_aliases().count("std::basic_string<char>") == 0u) {
|
||||
type_aliases().insert({"std::basic_string<char>", "std::string"});
|
||||
}
|
||||
if (!type_aliases().count("std::basic_string<char,std::char_traits<"
|
||||
"char>,std::allocator<char>>")) {
|
||||
if (type_aliases().count("std::basic_string<char,std::char_traits<"
|
||||
"char>,std::allocator<char>>") == 0u) {
|
||||
type_aliases().insert({"std::basic_string<char,std::char_traits<"
|
||||
"char>,std::allocator<char>>",
|
||||
"std::string"});
|
||||
}
|
||||
if (!type_aliases().count("std::basic_string<wchar_t>")) {
|
||||
if (type_aliases().count("std::basic_string<wchar_t>") == 0u) {
|
||||
type_aliases().insert({"std::basic_string<wchar_t>", "std::wstring"});
|
||||
}
|
||||
if (!type_aliases().count("std::basic_string<char16_t>")) {
|
||||
if (type_aliases().count("std::basic_string<char16_t>") == 0u) {
|
||||
type_aliases().insert(
|
||||
{"std::basic_string<char16_t>", "std::u16string"});
|
||||
}
|
||||
if (!type_aliases().count("std::basic_string<char32_t>")) {
|
||||
if (type_aliases().count("std::basic_string<char32_t>") == 0u) {
|
||||
type_aliases().insert(
|
||||
{"std::basic_string<char32_t>", "std::u32string"});
|
||||
}
|
||||
if (!type_aliases().count("std::integral_constant<bool,true>")) {
|
||||
if (type_aliases().count("std::integral_constant<bool,true>") == 0u) {
|
||||
type_aliases().insert(
|
||||
{"std::integral_constant<bool,true>", "std::true_type"});
|
||||
}
|
||||
if (!type_aliases().count("std::integral_constant<bool,false>")) {
|
||||
if (type_aliases().count("std::integral_constant<bool,false>") == 0u) {
|
||||
type_aliases().insert(
|
||||
{"std::integral_constant<bool,false>", "std::false_type"});
|
||||
}
|
||||
@@ -189,24 +189,24 @@ void class_diagram::initialize_relationship_hints()
|
||||
{
|
||||
using common::model::relationship_t;
|
||||
|
||||
if (!relationship_hints().count("std::vector")) {
|
||||
if (relationship_hints().count("std::vector") == 0u) {
|
||||
relationship_hints().insert({"std::vector", {}});
|
||||
}
|
||||
if (!relationship_hints().count("std::unique_ptr")) {
|
||||
if (relationship_hints().count("std::unique_ptr") == 0u) {
|
||||
relationship_hints().insert({"std::unique_ptr", {}});
|
||||
}
|
||||
if (!relationship_hints().count("std::shared_ptr")) {
|
||||
if (relationship_hints().count("std::shared_ptr") == 0u) {
|
||||
relationship_hints().insert(
|
||||
{"std::shared_ptr", {relationship_t::kAssociation}});
|
||||
}
|
||||
if (!relationship_hints().count("std::weak_ptr")) {
|
||||
if (relationship_hints().count("std::weak_ptr") == 0u) {
|
||||
relationship_hints().insert(
|
||||
{"std::weak_ptr", {relationship_t::kAssociation}});
|
||||
}
|
||||
if (!relationship_hints().count("std::tuple")) {
|
||||
if (relationship_hints().count("std::tuple") == 0u) {
|
||||
relationship_hints().insert({"std::tuple", {}});
|
||||
}
|
||||
if (!relationship_hints().count("std::map")) {
|
||||
if (relationship_hints().count("std::map") == 0u) {
|
||||
relationship_hint_t hint{relationship_t::kNone};
|
||||
hint.argument_hints.insert({1, relationship_t::kAggregation});
|
||||
relationship_hints().insert({"std::tuple", std::move(hint)});
|
||||
|
||||
@@ -49,7 +49,7 @@ parse_unexposed_template_params(const std::string ¶ms,
|
||||
std::vector<template_parameter> res;
|
||||
|
||||
auto it = params.begin();
|
||||
while (std::isspace(*it))
|
||||
while (std::isspace(*it) != 0)
|
||||
++it;
|
||||
|
||||
std::string type{};
|
||||
|
||||
@@ -91,7 +91,7 @@ decorator_toks decorator::tokenize(const std::string &label, std::string_view c)
|
||||
|
||||
std::advance(it, res.param.size() + 1);
|
||||
}
|
||||
else if (std::isspace(*it)) {
|
||||
else if (std::isspace(*it) != 0) {
|
||||
std::advance(it, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ void generate_diagrams(const std::vector<std::string> &diagram_names,
|
||||
translation_units = valid_translation_units, verbose]() {
|
||||
try {
|
||||
generate_diagram(
|
||||
od, name, diagram, db, translation_units, verbose);
|
||||
od, name, diagram, db, translation_units, verbose != 0);
|
||||
}
|
||||
catch (std::runtime_error &e) {
|
||||
LOG_ERROR(e.what());
|
||||
|
||||
@@ -221,7 +221,7 @@ void translation_unit_visitor::process_class_children(
|
||||
if (decl->getKind() == clang::Decl::Var) {
|
||||
const clang::VarDecl *variable_declaration{
|
||||
dynamic_cast<const clang::VarDecl *>(decl)};
|
||||
if (variable_declaration &&
|
||||
if ((variable_declaration != nullptr) &&
|
||||
variable_declaration->isStaticDataMember()) {
|
||||
process_static_field(*variable_declaration, relationships);
|
||||
}
|
||||
@@ -374,7 +374,7 @@ bool translation_unit_visitor::find_relationships(const clang::QualType &type,
|
||||
// pass
|
||||
}
|
||||
else if (template_argument.getAsType()
|
||||
->getAs<clang::FunctionProtoType>()) {
|
||||
->getAs<clang::FunctionProtoType>() != nullptr) {
|
||||
for (const auto ¶m_type :
|
||||
template_argument.getAsType()
|
||||
->getAs<clang::FunctionProtoType>()
|
||||
|
||||
@@ -59,16 +59,16 @@ bool call_expression_context::valid() const
|
||||
|
||||
clang::ASTContext *call_expression_context::get_ast_context()
|
||||
{
|
||||
if (current_class_template_specialization_decl_)
|
||||
if (current_class_template_specialization_decl_ != nullptr)
|
||||
return ¤t_class_template_specialization_decl_->getASTContext();
|
||||
|
||||
if (current_class_template_decl_)
|
||||
if (current_class_template_decl_ != nullptr)
|
||||
return ¤t_class_template_decl_->getASTContext();
|
||||
|
||||
if (current_class_decl_)
|
||||
if (current_class_decl_ != nullptr)
|
||||
return ¤t_class_decl_->getASTContext();
|
||||
|
||||
if (current_function_template_decl_)
|
||||
if (current_function_template_decl_ != nullptr)
|
||||
return ¤t_function_template_decl_->getASTContext();
|
||||
|
||||
return ¤t_function_decl_->getASTContext();
|
||||
@@ -104,7 +104,7 @@ void call_expression_context::update(clang::FunctionDecl *function)
|
||||
|
||||
// Check if this function is a part of template function declaration,
|
||||
// If no - reset the current_function_template_decl_
|
||||
if (current_function_template_decl_ &&
|
||||
if ((current_function_template_decl_ != nullptr) &&
|
||||
current_function_template_decl_->getQualifiedNameAsString() !=
|
||||
function->getQualifiedNameAsString()) {
|
||||
current_function_template_decl_ = nullptr;
|
||||
@@ -318,13 +318,13 @@ void call_expression_context::leave_conditionaloperator()
|
||||
bool call_expression_context::is_expr_in_current_control_statement_condition(
|
||||
const clang::Stmt *stmt) const
|
||||
{
|
||||
if (current_ifstmt()) {
|
||||
if (current_ifstmt() != nullptr) {
|
||||
if (common::is_subexpr_of(current_ifstmt()->getCond(), stmt)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (current_elseifstmt()) {
|
||||
if (current_elseifstmt() != nullptr) {
|
||||
if (common::is_subexpr_of(current_elseifstmt()->getCond(), stmt)) {
|
||||
return true;
|
||||
}
|
||||
@@ -367,7 +367,7 @@ bool call_expression_context::is_expr_in_current_control_statement_condition(
|
||||
}
|
||||
}
|
||||
|
||||
if (current_conditionaloperator()) {
|
||||
if (current_conditionaloperator() != nullptr) {
|
||||
if (common::is_subexpr_of(
|
||||
current_conditionaloperator()->getCond(), stmt)) {
|
||||
return true;
|
||||
|
||||
@@ -74,7 +74,7 @@ bool translation_unit_visitor::VisitCXXRecordDecl(clang::CXXRecordDecl *cls)
|
||||
if (!should_include(cls))
|
||||
return true;
|
||||
|
||||
if (cls->isTemplated() && cls->getDescribedTemplate()) {
|
||||
if (cls->isTemplated() && (cls->getDescribedTemplate() != nullptr)) {
|
||||
// If the described templated of this class is already in the model
|
||||
// skip it:
|
||||
auto local_id = cls->getDescribedTemplate()->getID();
|
||||
@@ -83,7 +83,7 @@ bool translation_unit_visitor::VisitCXXRecordDecl(clang::CXXRecordDecl *cls)
|
||||
}
|
||||
|
||||
// TODO: Add support for classes defined in function/method bodies
|
||||
if (cls->isLocalClass())
|
||||
if (cls->isLocalClass() != nullptr)
|
||||
return true;
|
||||
|
||||
LOG_TRACE("Visiting class declaration at {}",
|
||||
@@ -192,7 +192,7 @@ bool translation_unit_visitor::VisitClassTemplateSpecializationDecl(
|
||||
cls->getLocation().printToString(source_manager()));
|
||||
|
||||
// TODO: Add support for classes defined in function/method bodies
|
||||
if (cls->isLocalClass())
|
||||
if (cls->isLocalClass() != nullptr)
|
||||
return true;
|
||||
|
||||
auto template_specialization_ptr = process_template_specialization(cls);
|
||||
@@ -233,7 +233,7 @@ bool translation_unit_visitor::VisitCXXMethodDecl(clang::CXXMethodDecl *m)
|
||||
return true;
|
||||
|
||||
if (!m->isThisDeclarationADefinition()) {
|
||||
if (m->getDefinition())
|
||||
if (m->getDefinition() != nullptr)
|
||||
return VisitCXXMethodDecl(
|
||||
static_cast<clang::CXXMethodDecl *>(m->getDefinition()));
|
||||
}
|
||||
@@ -256,7 +256,7 @@ bool translation_unit_visitor::VisitCXXMethodDecl(clang::CXXMethodDecl *m)
|
||||
|
||||
clang::Decl *parent_decl = m->getParent();
|
||||
|
||||
if (context().current_class_template_decl_)
|
||||
if (context().current_class_template_decl_ != nullptr)
|
||||
parent_decl = context().current_class_template_decl_;
|
||||
|
||||
LOG_DBG("Getting method's class with local id {}", parent_decl->getID());
|
||||
@@ -325,7 +325,7 @@ bool translation_unit_visitor::VisitFunctionDecl(clang::FunctionDecl *f)
|
||||
const auto function_name = f->getQualifiedNameAsString();
|
||||
|
||||
if (!f->isThisDeclarationADefinition()) {
|
||||
if (f->getDefinition())
|
||||
if (f->getDefinition() != nullptr)
|
||||
return VisitFunctionDecl(
|
||||
static_cast<clang::FunctionDecl *>(f->getDefinition()));
|
||||
}
|
||||
@@ -334,7 +334,7 @@ bool translation_unit_visitor::VisitFunctionDecl(clang::FunctionDecl *f)
|
||||
f->getLocation().printToString(source_manager()));
|
||||
|
||||
if (f->isTemplated()) {
|
||||
if (f->getDescribedTemplate()) {
|
||||
if (f->getDescribedTemplate() != nullptr) {
|
||||
// If the described templated of this function is already in the
|
||||
// model skip it:
|
||||
if (get_unique_id(f->getDescribedTemplate()->getID()))
|
||||
@@ -551,7 +551,7 @@ bool translation_unit_visitor::TraverseCompoundStmt(clang::CompoundStmt *stmt)
|
||||
if (current_elseifstmt->getElse() == stmt) {
|
||||
const auto current_caller_id = context().caller_id();
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
diagram()
|
||||
.get_activity(current_caller_id)
|
||||
.add_message({message_t::kElse, current_caller_id});
|
||||
@@ -562,7 +562,7 @@ bool translation_unit_visitor::TraverseCompoundStmt(clang::CompoundStmt *stmt)
|
||||
if (current_ifstmt->getElse() == stmt) {
|
||||
const auto current_caller_id = context().caller_id();
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
diagram()
|
||||
.get_activity(current_caller_id)
|
||||
.add_message({message_t::kElse, current_caller_id});
|
||||
@@ -598,7 +598,7 @@ bool translation_unit_visitor::TraverseIfStmt(clang::IfStmt *stmt)
|
||||
}
|
||||
}
|
||||
|
||||
if (current_caller_id && !stmt->isConstexpr()) {
|
||||
if ((current_caller_id != 0) && !stmt->isConstexpr()) {
|
||||
context().enter_ifstmt(stmt);
|
||||
if (elseif_block) {
|
||||
context().enter_elseifstmt(stmt);
|
||||
@@ -611,7 +611,7 @@ bool translation_unit_visitor::TraverseIfStmt(clang::IfStmt *stmt)
|
||||
|
||||
RecursiveASTVisitor<translation_unit_visitor>::TraverseIfStmt(stmt);
|
||||
|
||||
if (current_caller_id && !stmt->isConstexpr() && !elseif_block) {
|
||||
if ((current_caller_id != 0) && !stmt->isConstexpr() && !elseif_block) {
|
||||
diagram().end_if_stmt(current_caller_id, message_t::kIfEnd);
|
||||
}
|
||||
|
||||
@@ -626,13 +626,13 @@ bool translation_unit_visitor::TraverseWhileStmt(clang::WhileStmt *stmt)
|
||||
|
||||
const auto current_caller_id = context().caller_id();
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().enter_loopstmt(stmt);
|
||||
diagram().add_while_stmt(current_caller_id);
|
||||
}
|
||||
RecursiveASTVisitor<translation_unit_visitor>::TraverseWhileStmt(stmt);
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
diagram().end_while_stmt(current_caller_id);
|
||||
context().leave_loopstmt();
|
||||
}
|
||||
@@ -648,14 +648,14 @@ bool translation_unit_visitor::TraverseDoStmt(clang::DoStmt *stmt)
|
||||
|
||||
const auto current_caller_id = context().caller_id();
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().enter_loopstmt(stmt);
|
||||
diagram().add_do_stmt(current_caller_id);
|
||||
}
|
||||
|
||||
RecursiveASTVisitor<translation_unit_visitor>::TraverseDoStmt(stmt);
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().leave_loopstmt();
|
||||
diagram().end_do_stmt(current_caller_id);
|
||||
}
|
||||
@@ -671,14 +671,14 @@ bool translation_unit_visitor::TraverseForStmt(clang::ForStmt *stmt)
|
||||
|
||||
const auto current_caller_id = context().caller_id();
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().enter_loopstmt(stmt);
|
||||
diagram().add_for_stmt(current_caller_id);
|
||||
}
|
||||
|
||||
RecursiveASTVisitor<translation_unit_visitor>::TraverseForStmt(stmt);
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().leave_loopstmt();
|
||||
diagram().end_for_stmt(current_caller_id);
|
||||
}
|
||||
@@ -694,14 +694,14 @@ bool translation_unit_visitor::TraverseCXXTryStmt(clang::CXXTryStmt *stmt)
|
||||
|
||||
const auto current_caller_id = context().caller_id();
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().enter_trystmt(stmt);
|
||||
diagram().add_try_stmt(current_caller_id);
|
||||
}
|
||||
|
||||
RecursiveASTVisitor<translation_unit_visitor>::TraverseCXXTryStmt(stmt);
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().leave_trystmt();
|
||||
diagram().end_try_stmt(current_caller_id);
|
||||
}
|
||||
@@ -717,7 +717,7 @@ bool translation_unit_visitor::TraverseCXXCatchStmt(clang::CXXCatchStmt *stmt)
|
||||
|
||||
const auto current_caller_id = context().caller_id();
|
||||
|
||||
if (current_caller_id && context().current_trystmt()) {
|
||||
if ((current_caller_id != 0) && (context().current_trystmt() != nullptr)) {
|
||||
std::string caught_type;
|
||||
if (stmt->getCaughtType().isNull())
|
||||
caught_type = "...";
|
||||
@@ -742,7 +742,7 @@ bool translation_unit_visitor::TraverseCXXForRangeStmt(
|
||||
|
||||
const auto current_caller_id = context().caller_id();
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().enter_loopstmt(stmt);
|
||||
diagram().add_for_stmt(current_caller_id);
|
||||
}
|
||||
@@ -750,7 +750,7 @@ bool translation_unit_visitor::TraverseCXXForRangeStmt(
|
||||
RecursiveASTVisitor<translation_unit_visitor>::TraverseCXXForRangeStmt(
|
||||
stmt);
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().leave_loopstmt();
|
||||
diagram().end_for_stmt(current_caller_id);
|
||||
}
|
||||
@@ -762,14 +762,14 @@ bool translation_unit_visitor::TraverseSwitchStmt(clang::SwitchStmt *stmt)
|
||||
{
|
||||
const auto current_caller_id = context().caller_id();
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().enter_switchstmt(stmt);
|
||||
diagram().add_switch_stmt(current_caller_id);
|
||||
}
|
||||
|
||||
RecursiveASTVisitor<translation_unit_visitor>::TraverseSwitchStmt(stmt);
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().leave_switchstmt();
|
||||
diagram().end_switch_stmt(current_caller_id);
|
||||
}
|
||||
@@ -781,7 +781,7 @@ bool translation_unit_visitor::TraverseCaseStmt(clang::CaseStmt *stmt)
|
||||
{
|
||||
const auto current_caller_id = context().caller_id();
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
diagram().add_case_stmt(
|
||||
current_caller_id, common::to_string(stmt->getLHS()));
|
||||
}
|
||||
@@ -795,7 +795,7 @@ bool translation_unit_visitor::TraverseDefaultStmt(clang::DefaultStmt *stmt)
|
||||
{
|
||||
const auto current_caller_id = context().caller_id();
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
diagram().add_default_stmt(current_caller_id);
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ bool translation_unit_visitor::TraverseConditionalOperator(
|
||||
{
|
||||
const auto current_caller_id = context().caller_id();
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().enter_conditionaloperator(stmt);
|
||||
diagram().add_conditional_stmt(current_caller_id);
|
||||
}
|
||||
@@ -820,14 +820,14 @@ bool translation_unit_visitor::TraverseConditionalOperator(
|
||||
RecursiveASTVisitor<translation_unit_visitor>::TraverseStmt(
|
||||
stmt->getTrueExpr());
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
diagram().add_conditional_elsestmt(current_caller_id);
|
||||
}
|
||||
|
||||
RecursiveASTVisitor<translation_unit_visitor>::TraverseStmt(
|
||||
stmt->getFalseExpr());
|
||||
|
||||
if (current_caller_id) {
|
||||
if (current_caller_id != 0) {
|
||||
context().leave_conditionaloperator();
|
||||
diagram().end_conditional_stmt(current_caller_id);
|
||||
}
|
||||
@@ -902,12 +902,12 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
|
||||
callee_decl = expr->getDirectCallee();
|
||||
}
|
||||
|
||||
if (!callee_decl) {
|
||||
if (callee_decl == nullptr) {
|
||||
//
|
||||
// Call to a method of a class template
|
||||
//
|
||||
if (clang::dyn_cast_or_null<clang::CXXDependentScopeMemberExpr>(
|
||||
expr->getCallee())) {
|
||||
expr->getCallee()) != nullptr) {
|
||||
if (!process_class_template_method_call_expression(m, expr)) {
|
||||
return true;
|
||||
}
|
||||
@@ -917,7 +917,7 @@ bool translation_unit_visitor::VisitCallExpr(clang::CallExpr *expr)
|
||||
// functions
|
||||
//
|
||||
else if (clang::dyn_cast_or_null<clang::UnresolvedLookupExpr>(
|
||||
expr->getCallee())) {
|
||||
expr->getCallee()) != nullptr) {
|
||||
if (!process_unresolved_lookup_call_expression(m, expr))
|
||||
return true;
|
||||
}
|
||||
@@ -1000,9 +1000,10 @@ bool translation_unit_visitor::process_class_method_call_expression(
|
||||
|
||||
std::string method_name = method_decl->getQualifiedNameAsString();
|
||||
|
||||
auto *callee_decl = method_decl ? method_decl->getParent() : nullptr;
|
||||
auto *callee_decl =
|
||||
method_decl != nullptr ? method_decl->getParent() : nullptr;
|
||||
|
||||
if (!callee_decl)
|
||||
if (callee_decl == nullptr)
|
||||
return false;
|
||||
|
||||
if (!should_include(callee_decl) || !should_include(method_decl))
|
||||
@@ -1108,7 +1109,7 @@ bool translation_unit_visitor::process_function_call_expression(
|
||||
|
||||
const auto *callee_function = callee_decl->getAsFunction();
|
||||
|
||||
if (!callee_function)
|
||||
if (callee_function == nullptr)
|
||||
return false;
|
||||
|
||||
if (!should_include(callee_function))
|
||||
@@ -1147,9 +1148,10 @@ bool translation_unit_visitor::process_unresolved_lookup_call_expression(
|
||||
auto *unresolved_expr =
|
||||
clang::dyn_cast_or_null<clang::UnresolvedLookupExpr>(expr->getCallee());
|
||||
|
||||
if (unresolved_expr) {
|
||||
if (unresolved_expr != nullptr) {
|
||||
for (const auto *decl : unresolved_expr->decls()) {
|
||||
if (clang::dyn_cast_or_null<clang::FunctionTemplateDecl>(decl)) {
|
||||
if (clang::dyn_cast_or_null<clang::FunctionTemplateDecl>(decl) !=
|
||||
nullptr) {
|
||||
// Yes, it's a template
|
||||
auto *ftd =
|
||||
clang::dyn_cast_or_null<clang::FunctionTemplateDecl>(decl);
|
||||
@@ -1223,7 +1225,7 @@ translation_unit_visitor::create_class_declaration(clang::CXXRecordDecl *cls)
|
||||
|
||||
const auto *parent = cls->getParent();
|
||||
|
||||
if (parent && parent->isRecord()) {
|
||||
if ((parent != nullptr) && parent->isRecord()) {
|
||||
// Here we have 2 options, either:
|
||||
// - the parent is a regular C++ class/struct
|
||||
// - the parent is a class template declaration/specialization
|
||||
@@ -1237,13 +1239,13 @@ translation_unit_visitor::create_class_declaration(clang::CXXRecordDecl *cls)
|
||||
|
||||
// If not, check if the parent template declaration is in the model
|
||||
if (!id_opt &&
|
||||
static_cast<const clang::RecordDecl *>(parent)
|
||||
->getDescribedTemplate()) {
|
||||
(static_cast<const clang::RecordDecl *>(parent)
|
||||
->getDescribedTemplate() != nullptr)) {
|
||||
local_id = static_cast<const clang::RecordDecl *>(parent)
|
||||
->getDescribedTemplate()
|
||||
->getID();
|
||||
if (static_cast<const clang::RecordDecl *>(parent)
|
||||
->getDescribedTemplate())
|
||||
->getDescribedTemplate() != nullptr)
|
||||
id_opt = get_unique_id(local_id);
|
||||
}
|
||||
|
||||
@@ -1285,7 +1287,7 @@ translation_unit_visitor::create_class_declaration(clang::CXXRecordDecl *cls)
|
||||
}
|
||||
else if (cls->isLambda()) {
|
||||
c.is_lambda(true);
|
||||
if (cls->getParent()) {
|
||||
if (cls->getParent() != nullptr) {
|
||||
const auto type_name = make_lambda_name(cls);
|
||||
|
||||
c.set_name(type_name);
|
||||
@@ -1334,7 +1336,8 @@ bool translation_unit_visitor::process_template_parameters(
|
||||
|
||||
for (const auto *parameter :
|
||||
*template_declaration.getTemplateParameters()) {
|
||||
if (clang::dyn_cast_or_null<clang::TemplateTypeParmDecl>(parameter)) {
|
||||
if (clang::dyn_cast_or_null<clang::TemplateTypeParmDecl>(parameter) !=
|
||||
nullptr) {
|
||||
const auto *template_type_parameter =
|
||||
clang::dyn_cast_or_null<clang::TemplateTypeParmDecl>(parameter);
|
||||
template_parameter ct;
|
||||
@@ -1347,7 +1350,7 @@ bool translation_unit_visitor::process_template_parameters(
|
||||
c.add_template(std::move(ct));
|
||||
}
|
||||
else if (clang::dyn_cast_or_null<clang::NonTypeTemplateParmDecl>(
|
||||
parameter)) {
|
||||
parameter) != nullptr) {
|
||||
const auto *template_nontype_parameter =
|
||||
clang::dyn_cast_or_null<clang::NonTypeTemplateParmDecl>(
|
||||
parameter);
|
||||
@@ -1361,7 +1364,7 @@ bool translation_unit_visitor::process_template_parameters(
|
||||
c.add_template(std::move(ct));
|
||||
}
|
||||
else if (clang::dyn_cast_or_null<clang::TemplateTemplateParmDecl>(
|
||||
parameter)) {
|
||||
parameter) != nullptr) {
|
||||
const auto *template_template_parameter =
|
||||
clang::dyn_cast_or_null<clang::TemplateTemplateParmDecl>(
|
||||
parameter);
|
||||
@@ -1549,10 +1552,11 @@ void translation_unit_visitor::
|
||||
|
||||
// If this is a nested template type - add nested templates as
|
||||
// template arguments
|
||||
if (arg.getAsType()->getAs<clang::FunctionType>()) {
|
||||
if (arg.getAsType()->getAs<clang::FunctionType>() != nullptr) {
|
||||
// TODO
|
||||
}
|
||||
else if (arg.getAsType()->getAs<clang::TemplateSpecializationType>()) {
|
||||
else if (arg.getAsType()->getAs<clang::TemplateSpecializationType>() !=
|
||||
nullptr) {
|
||||
const auto *nested_template_type =
|
||||
arg.getAsType()->getAs<clang::TemplateSpecializationType>();
|
||||
|
||||
@@ -1571,7 +1575,7 @@ void translation_unit_visitor::
|
||||
simplify_system_template(
|
||||
argument, argument.to_string(config().using_namespace(), false));
|
||||
}
|
||||
else if (arg.getAsType()->getAs<clang::TemplateTypeParmType>()) {
|
||||
else if (arg.getAsType()->getAs<clang::TemplateTypeParmType>() != nullptr) {
|
||||
argument.is_template_parameter(true);
|
||||
argument.set_name(
|
||||
common::to_string(arg.getAsType(), template_decl->getASTContext()));
|
||||
@@ -1637,7 +1641,8 @@ void translation_unit_visitor::process_template_specialization_argument(
|
||||
|
||||
// If this is a nested template type - add nested templates as
|
||||
// template arguments
|
||||
if (arg.getAsType()->getAs<clang::TemplateSpecializationType>()) {
|
||||
if (arg.getAsType()->getAs<clang::TemplateSpecializationType>() !=
|
||||
nullptr) {
|
||||
const auto *nested_template_type =
|
||||
arg.getAsType()->getAs<clang::TemplateSpecializationType>();
|
||||
|
||||
@@ -1663,7 +1668,8 @@ void translation_unit_visitor::process_template_specialization_argument(
|
||||
simplify_system_template(argument,
|
||||
argument.to_string(config().using_namespace(), false));
|
||||
}
|
||||
else if (arg.getAsType()->getAs<clang::TemplateTypeParmType>()) {
|
||||
else if (arg.getAsType()->getAs<clang::TemplateTypeParmType>() !=
|
||||
nullptr) {
|
||||
auto type_name =
|
||||
common::to_string(arg.getAsType(), cls->getASTContext());
|
||||
|
||||
@@ -1694,7 +1700,7 @@ void translation_unit_visitor::process_template_specialization_argument(
|
||||
|
||||
argument.set_name(type_name);
|
||||
}
|
||||
else if (arg.getAsType()->getAsCXXRecordDecl() &&
|
||||
else if ((arg.getAsType()->getAsCXXRecordDecl() != nullptr) &&
|
||||
arg.getAsType()->getAsCXXRecordDecl()->isLambda()) {
|
||||
if (get_unique_id(arg.getAsType()->getAsCXXRecordDecl()->getID())
|
||||
.has_value()) {
|
||||
@@ -1816,8 +1822,8 @@ translation_unit_visitor::build_template_instantiation(
|
||||
|
||||
auto *template_type_ptr = &template_type_decl;
|
||||
if (template_type_decl.isTypeAlias() &&
|
||||
template_type_decl.getAliasedType()
|
||||
->getAs<clang::TemplateSpecializationType>())
|
||||
(template_type_decl.getAliasedType()
|
||||
->getAs<clang::TemplateSpecializationType>() != nullptr))
|
||||
template_type_ptr = template_type_decl.getAliasedType()
|
||||
->getAs<clang::TemplateSpecializationType>();
|
||||
|
||||
@@ -1841,8 +1847,9 @@ translation_unit_visitor::build_template_instantiation(
|
||||
auto *class_template_decl{
|
||||
clang::dyn_cast<clang::ClassTemplateDecl>(template_decl)};
|
||||
|
||||
if (class_template_decl && class_template_decl->getTemplatedDecl() &&
|
||||
class_template_decl->getTemplatedDecl()->getParent() &&
|
||||
if ((class_template_decl != nullptr) &&
|
||||
(class_template_decl->getTemplatedDecl() != nullptr) &&
|
||||
(class_template_decl->getTemplatedDecl()->getParent() != nullptr) &&
|
||||
class_template_decl->getTemplatedDecl()->getParent()->isRecord()) {
|
||||
|
||||
common::model::namespace_ ns{
|
||||
@@ -1895,7 +1902,8 @@ translation_unit_visitor::build_template_instantiation(
|
||||
clang::dyn_cast_or_null<clang::CXXRecordDecl>(
|
||||
template_decl->getTemplatedDecl());
|
||||
|
||||
if (templated_class_decl && templated_class_decl->hasDefinition())
|
||||
if ((templated_class_decl != nullptr) &&
|
||||
templated_class_decl->hasDefinition())
|
||||
for (const auto &base : templated_class_decl->bases()) {
|
||||
const auto base_class_name = common::to_string(
|
||||
base.getType(), templated_class_decl->getASTContext(), false);
|
||||
@@ -2124,7 +2132,7 @@ bool translation_unit_visitor::should_include(const clang::CallExpr *expr) const
|
||||
if (expr->isImplicitCXXThis())
|
||||
return false;
|
||||
|
||||
if (clang::dyn_cast_or_null<clang::ImplicitCastExpr>(expr))
|
||||
if (clang::dyn_cast_or_null<clang::ImplicitCastExpr>(expr) != nullptr)
|
||||
return false;
|
||||
|
||||
if (!context().valid())
|
||||
|
||||
Reference in New Issue
Block a user