Fixed handling of function template parameters
This commit is contained in:
@@ -928,7 +928,15 @@ std::optional<template_parameter> template_builder::try_as_function_prototype(
|
||||
clang::QualType &type, class_ &template_instantiation,
|
||||
size_t argument_index)
|
||||
{
|
||||
const auto *function_type = type->getAs<clang::FunctionProtoType>();
|
||||
auto *function_type = type->getAs<clang::FunctionProtoType>();
|
||||
|
||||
if (function_type == nullptr && type->isFunctionPointerType()) {
|
||||
function_type =
|
||||
type->getPointeeType()->getAs<clang::FunctionProtoType>();
|
||||
if (function_type == nullptr)
|
||||
return {};
|
||||
}
|
||||
|
||||
if (function_type == nullptr)
|
||||
return {};
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ TEST_CASE("t00014", "[test-case][class]")
|
||||
|
||||
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||
|
||||
REQUIRE_THAT(puml, !Contains("type-parameter-"));
|
||||
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "T,P"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "T,std::string"));
|
||||
REQUIRE_THAT(
|
||||
|
||||
@@ -35,6 +35,8 @@ TEST_CASE("t00062", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||
|
||||
REQUIRE_THAT(puml, !Contains("type-parameter-"));
|
||||
|
||||
// Check if all classes exist
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "T"));
|
||||
REQUIRE_THAT(puml, IsClassTemplate("A", "U &"));
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
#include <cstddef>
|
||||
|
||||
namespace clanguml {
|
||||
namespace t00064 {
|
||||
|
||||
template <typename... Ts> struct type_list { };
|
||||
|
||||
template <typename Ret, typename Arg, typename... Ts>
|
||||
struct type_list<Ret (*)(Arg &&arg), Ts...> { };
|
||||
|
||||
template <typename T> struct head;
|
||||
template <typename Head, typename... Tail>
|
||||
struct head<type_list<Head, Tail...>> {
|
||||
@@ -13,7 +18,10 @@ template <typename T> using head_t = typename head<T>::type;
|
||||
|
||||
template <typename, typename> class type_group_pair;
|
||||
template <typename... First, typename... Second>
|
||||
class type_group_pair<type_list<First...>, type_list<Second...>> { };
|
||||
class type_group_pair<type_list<First...>, type_list<Second...>> {
|
||||
template <typename Type>
|
||||
static constexpr size_t size = sizeof...(First) + sizeof...(Second);
|
||||
};
|
||||
|
||||
struct A { };
|
||||
struct B { };
|
||||
|
||||
@@ -35,41 +35,12 @@ TEST_CASE("t00064", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||
|
||||
REQUIRE_THAT(puml, !Contains("type-parameter-"));
|
||||
|
||||
// Check if all classes exist
|
||||
REQUIRE_THAT(
|
||||
puml, IsClassTemplate("type_group_pair", "typename,typename"));
|
||||
|
||||
// Check if class templates exist
|
||||
// REQUIRE_THAT(puml, IsClassTemplate("A", "T,P,CMP,int N"));
|
||||
|
||||
// Check concepts
|
||||
// REQUIRE_THAT(puml, IsConcept(_A("AConcept<T>")));
|
||||
// REQUIRE_THAT(puml,
|
||||
// IsConceptRequirement(
|
||||
// _A("AConcept<T,P>"), "sizeof (T) > sizeof (P)"));
|
||||
|
||||
// Check if all enums exist
|
||||
// REQUIRE_THAT(puml, IsEnum(_A("Lights")));
|
||||
|
||||
// Check if all inner classes exist
|
||||
// REQUIRE_THAT(puml, IsInnerClass(_A("A"), _A("AA")));
|
||||
|
||||
// Check if all inheritance relationships exist
|
||||
// REQUIRE_THAT(puml, IsBaseClass(_A("Base"), _A("Child")));
|
||||
|
||||
// Check if all methods exist
|
||||
// REQUIRE_THAT(puml, (IsMethod<Public, Const>("foo")));
|
||||
|
||||
// Check if all fields exist
|
||||
// REQUIRE_THAT(puml, (IsField<Private>("private_member", "int")));
|
||||
|
||||
// Check if all relationships exist
|
||||
// REQUIRE_THAT(puml, IsAssociation(_A("D"), _A("A"), "-as"));
|
||||
// REQUIRE_THAT(puml, IsDependency(_A("R"), _A("B")));
|
||||
// REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("D"), "-ag"));
|
||||
// REQUIRE_THAT(puml, IsComposition(_A("R"), _A("D"), "-ac"));
|
||||
// REQUIRE_THAT(puml, IsInstantiation(_A("ABCD::F<T>"), _A("F<int>")));
|
||||
|
||||
save_puml(
|
||||
config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user