Fixed handling of nested anonymous arrays of structs
This commit is contained in:
@@ -1795,6 +1795,10 @@ void translation_unit_visitor::process_field(
|
||||
relationship_hint = relationship_t::kAssociation;
|
||||
field_type = field_type.getNonReferenceType();
|
||||
}
|
||||
else if (field_type->isArrayType()) {
|
||||
relationship_hint = relationship_t::kAggregation;
|
||||
field_type = field_type->getAsArrayTypeUnsafe()->getElementType();
|
||||
}
|
||||
else if (field_type->isRValueReferenceType()) {
|
||||
field_type = field_type.getNonReferenceType();
|
||||
}
|
||||
|
||||
@@ -116,6 +116,12 @@ std::string get_tag_name(const clang::TagDecl &declaration)
|
||||
std::string to_string(const clang::QualType &type, const clang::ASTContext &ctx,
|
||||
bool try_canonical)
|
||||
{
|
||||
if (type->isArrayType()) {
|
||||
return fmt::format("{}[]",
|
||||
to_string(type->getAsArrayTypeUnsafe()->getElementType(), ctx,
|
||||
try_canonical));
|
||||
}
|
||||
|
||||
clang::PrintingPolicy print_policy(ctx.getLangOpts());
|
||||
print_policy.SuppressScope = 0;
|
||||
print_policy.PrintCanonicalTypes = 0;
|
||||
@@ -150,8 +156,8 @@ std::string to_string(const clang::QualType &type, const clang::ASTContext &ctx,
|
||||
result = "(anonymous)";
|
||||
else if (util::contains(result, "unnamed struct") ||
|
||||
util::contains(result, "unnamed union")) {
|
||||
auto declarationTag = type->getAsTagDecl();
|
||||
if (declarationTag == NULL) {
|
||||
const auto *declarationTag = type->getAsTagDecl();
|
||||
if (declarationTag == nullptr) {
|
||||
result = "(unnamed undeclared)";
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
namespace clanguml {
|
||||
namespace t00037 {
|
||||
|
||||
constexpr auto LENGTH{10ULL};
|
||||
|
||||
class ST {
|
||||
public:
|
||||
struct {
|
||||
@@ -10,6 +12,11 @@ public:
|
||||
double z;
|
||||
} dimensions;
|
||||
|
||||
struct {
|
||||
int len;
|
||||
int flags;
|
||||
} __attribute__((packed)) bars[LENGTH];
|
||||
|
||||
private:
|
||||
struct {
|
||||
double c{1.0};
|
||||
|
||||
@@ -30,9 +30,11 @@ TEST_CASE("t00037")
|
||||
REQUIRE(IsClass(src, "A"));
|
||||
REQUIRE(IsClass(src, "ST::(units)"));
|
||||
REQUIRE(IsClass(src, "ST::(dimensions)"));
|
||||
REQUIRE(IsClass(src, "ST::(bars)"));
|
||||
|
||||
REQUIRE(
|
||||
IsAggregation<Public>(src, "ST", "ST::(dimensions)", "dimensions"));
|
||||
REQUIRE(IsAggregation<Private>(src, "ST", "ST::(units)", "units"));
|
||||
REQUIRE(IsAggregation<Public>(src, "ST", "ST::(bars)", "bars"));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user