bkryza / clang-uml

Customizable automatic UML diagram generator for C++ based on Clang.
Apache License 2.0
592 stars 40 forks source link

Braces in default arguments break mermaid diagrams #312

Closed sthlm58 closed 1 month ago

sthlm58 commented 1 month ago

If you generate a mermaid diagram from the following code

class Foo {
public:
    Foo(void* parent = {}) {}
};

int main() {}

You get the following mermaid:

classDiagram
    class C_0017490737515057045975["Foo"]
    class C_0017490737515057045975 {
        +Foo(void * parent = {}) : void
    }

That is invalid with:

Diagram syntax error

Error: Error: Parse error on line 4:
...Foo(void * parent = {}) : void }
-----------------------^
Expecting 'STRUCT_STOP', 'MEMBER', got 'OPEN_IN_STRUCT'

I'm not sure if those { and } characters can be escaped...

bkryza commented 1 month ago

@sthlm58 Thanks for reporting this. It should now be fixed in master branch. I've added a test for this - see the default_int_braces method...