Closed pogobanane closed 3 months ago
@pogobanane Thanks for the PR. I've managed to reproduce the problem however the cause of the issue is slightly different. Anonymous structs and unions are supported and covered by a separated test case: https://clang-uml.github.io/md_docs_2test__cases_2t00037.html, but what I forgot to test for are arrays of anonymous structs :-)
If you'd like to take a go at fixing it, please do the following:
ST
class.ST::(bars)
and for an aggregation relationship from ST
to ST::(bars)
to_string
method you've modified in your PR add the following code:
if (type->isArrayType()) {
return fmt::format("{}[]",
to_string(type->getAsArrayTypeUnsafe()->getElementType(), ctx,
try_canonical));
}
NULL
to nullptr
.If you don't have time to do this let me know - I'll fix it today.
Thanks again!
@bkryza I won't have enough time the next few days to complete your suggestions. I'm lacking context knowledge which is why i barely understand your proposed changes.
@pogobanane No problem. I've merged your PR so that you at least get credit for reporting the issue. I've also added the relevant fixes in the master
branch so now if you run in it on your code you should get that anonymous struct as well as a relationship to it in the diagram.
Works now. Thanks!
Nitpicky, and i dont really mind, but i noticed the following:
Since isArrayType
now matches all arrays (not only unnamed ones), it slightly changes the to_string behaviour of fixed length arrays:
- +txFrame : char[9000]
+ +txFrame : char[]
@pogobanane Thanks for spotting this. I've just committed fix for this to master
as well as few other related fixes. I've also extended the test case for this: https://github.com/bkryza/clang-uml/blob/master/docs/test_cases/t00037.md
type->getAsTagDecl() may return null resulting in a segfault. E.g. in the following example:
I found this segfault while working on this code https://github.com/vmuxIO/vmuxIO/commit/d1d44aa84158a6bc2955e62f597b6794b66f221f (
just uml
). This patch solves that segfault.I have no prior experience with clang, but i hope my solution is still valid.