Refactored build_template_instantiation method

This commit is contained in:
Bartek Kryza
2022-08-25 13:53:13 +02:00
parent dfd3fee444
commit 1cf3ceff7b
3 changed files with 320 additions and 428 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -147,6 +147,42 @@ private:
int arg_index, bool variadic_params,
const clanguml::class_diagram::model::template_parameter &ct) const;
void build_template_instantiation_process_template_arguments(
std::optional<clanguml::class_diagram::model::class_ *> &parent,
std::deque<std::tuple<std::string, int, bool>> &template_base_params,
// const clang::TemplateSpecializationType &template_type,
const clang::ArrayRef<clang::TemplateArgument> &template_args,
model::class_ &template_instantiation,
const std::string &full_template_specialization_name,
const clang::TemplateDecl *template_decl);
void build_template_instantiation_process_tag_argument(
model::class_ &template_instantiation,
const std::string &full_template_specialization_name,
const clang::TemplateDecl *template_decl,
const clang::TemplateArgument &arg,
model::template_parameter &argument);
void build_template_instantiation_process_expression_argument(
const clang::TemplateArgument &arg,
model::template_parameter &argument) const;
void build_template_instantiation_process_integral_argument(
const clang::TemplateArgument &arg,
model::template_parameter &argument) const;
void build_template_instantiation_process_type_argument(
std::optional<clanguml::class_diagram::model::class_ *> &parent,
const std::string &full_template_specialization_name,
const clang::TemplateDecl *template_decl,
const clang::TemplateArgument &arg,
model::class_ &template_instantiation,
model::template_parameter &argument);
void build_template_instantiation_process_template_argument(
const clang::TemplateArgument &arg,
model::template_parameter &argument) const;
void process_function_parameter_find_relationships_in_template(
clanguml::class_diagram::model::class_ &c,
const std::set<std::string> &template_parameter_names,

View File

@@ -62,4 +62,20 @@ template <> id_t to_id(const std::filesystem::path &file)
return to_id(file.lexically_normal().string());
}
template <> id_t to_id(const clang::TemplateArgument &template_argument)
{
if (template_argument.getKind() == clang::TemplateArgument::Type) {
if (template_argument.getAsType()->getAs<clang::EnumType>())
return to_id(*template_argument.getAsType()
->getAs<clang::EnumType>()
->getAsTagDecl());
else if (template_argument.getAsType()->getAs<clang::RecordType>())
return to_id(*template_argument.getAsType()
->getAs<clang::RecordType>()
->getAsRecordDecl());
}
throw std::runtime_error("Cannot generate id for template argument");
}
}