Applied clang-tidy nullptr access warnings
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
|
||||
namespace clanguml::package_diagram::visitor {
|
||||
|
||||
using clanguml::class_diagram::model::type_alias;
|
||||
using clanguml::common::model::access_t;
|
||||
using clanguml::common::model::namespace_;
|
||||
using clanguml::common::model::package;
|
||||
@@ -198,15 +197,19 @@ void translation_unit_visitor::process_class_children(
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate over class template methods
|
||||
for (auto const *decl_iterator :
|
||||
clang::dyn_cast_or_null<clang::DeclContext>(&cls)->decls()) {
|
||||
auto const *method_template =
|
||||
llvm::dyn_cast_or_null<clang::FunctionTemplateDecl>(decl_iterator);
|
||||
if (method_template == nullptr)
|
||||
continue;
|
||||
if (const auto *decl_context =
|
||||
clang::dyn_cast_or_null<clang::DeclContext>(&cls);
|
||||
decl_context != nullptr) {
|
||||
// Iterate over class template methods
|
||||
for (auto const *decl_iterator : decl_context->decls()) {
|
||||
auto const *method_template =
|
||||
llvm::dyn_cast_or_null<clang::FunctionTemplateDecl>(
|
||||
decl_iterator);
|
||||
if (method_template == nullptr)
|
||||
continue;
|
||||
|
||||
process_template_method(*method_template, relationships);
|
||||
process_template_method(*method_template, relationships);
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate over regular class fields
|
||||
@@ -333,18 +336,14 @@ bool translation_unit_visitor::find_relationships(const clang::QualType &type,
|
||||
relationships, relationship_t::kAggregation);
|
||||
}
|
||||
else if (type->isEnumeralType()) {
|
||||
relationships.emplace_back(
|
||||
common::to_id(*type->getAs<clang::EnumType>()), relationship_hint);
|
||||
if (const auto *enum_type = type->getAs<clang::EnumType>();
|
||||
enum_type != nullptr) {
|
||||
relationships.emplace_back(
|
||||
common::to_id(*enum_type), relationship_hint);
|
||||
}
|
||||
}
|
||||
else if (const auto *template_specialization_type =
|
||||
type->getAs<clang::TemplateSpecializationType>()) {
|
||||
if (template_specialization_type != nullptr) {
|
||||
if (template_specialization_type->isTypeAlias())
|
||||
template_specialization_type =
|
||||
template_specialization_type->getAliasedType()
|
||||
->getAs<clang::TemplateSpecializationType>();
|
||||
}
|
||||
|
||||
if (template_specialization_type != nullptr) {
|
||||
for (const auto &template_argument :
|
||||
*template_specialization_type) {
|
||||
@@ -373,12 +372,12 @@ bool translation_unit_visitor::find_relationships(const clang::QualType &type,
|
||||
clang::TemplateArgument::ArgKind::TemplateExpansion) {
|
||||
// pass
|
||||
}
|
||||
else if (template_argument.getAsType()
|
||||
->getAs<clang::FunctionProtoType>() != nullptr) {
|
||||
else if (const auto *function_type =
|
||||
template_argument.getAsType()
|
||||
->getAs<clang::FunctionProtoType>();
|
||||
function_type != nullptr) {
|
||||
for (const auto ¶m_type :
|
||||
template_argument.getAsType()
|
||||
->getAs<clang::FunctionProtoType>()
|
||||
->param_types()) {
|
||||
function_type->param_types()) {
|
||||
result = find_relationships(param_type, relationships,
|
||||
relationship_t::kDependency);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user