# t20021 - Loop statements sequence diagram test case ## Config ```yaml compilation_database_dir: .. output_directory: puml diagrams: t20021_sequence: type: sequence glob: - ../../tests/t20021/t20021.cc include: namespaces: - clanguml::t20021 using_namespace: - clanguml::t20021 from: - function: "clanguml::t20021::tmain()" ``` ## Source code File t20021.cc ```cpp #include namespace clanguml { namespace t20021 { struct A { int a1() { return 0; } int a2() { return 1; } int a3() { return 2; } }; struct B { void log() { } int b1() const { return 3; } int b2() const { return 4; } }; struct C { int c1() { return 1; } int c2() { return 2; } int c3() { return 3; } int c4() { return c5(); } int c5() { return 5; } std::vector &contents() { return contents_; } std::vector contents_; }; int tmain() { A a; std::vector b; C c; int i = 10; while (i -= c.c4()) { int j = a.a3(); do { for (int l = a.a2(); l > c.c1(); l -= c.c2()) a.a1(); } while (j -= c.c3()); } int result = 0; for (const auto &bi : b) { result += bi.b2(); } for (const auto &ci : c.contents()) { result += ci; } return b.front().b2() + result; } } } ``` ## Generated UML diagrams ![t20021_sequence](./t20021_sequence.svg "Loop statements sequence diagram test case") ## Generated JSON models ```json { "diagram_type": "sequence", "metadata": { "clang_uml_version": "0.3.8-32-ge830195", "llvm_version": "Ubuntu clang version 15.0.7", "schema_version": 1 }, "name": "t20021_sequence", "participants": [ { "id": "1682631020380557915", "name": "clanguml::t20021::tmain()", "source_location": { "column": 5, "file": "../../tests/t20021/t20021.cc", "line": 30, "translation_unit": "../../tests/t20021/t20021.cc" }, "type": "function" }, { "id": "451128000259357438", "name": "clanguml::t20021::C", "source_location": { "column": 8, "file": "../../tests/t20021/t20021.cc", "line": 18, "translation_unit": "../../tests/t20021/t20021.cc" }, "type": "class" }, { "id": "1280483607329510730", "name": "clanguml::t20021::A", "source_location": { "column": 8, "file": "../../tests/t20021/t20021.cc", "line": 5, "translation_unit": "../../tests/t20021/t20021.cc" }, "type": "class" }, { "id": "1849696080443395393", "name": "clanguml::t20021::B", "source_location": { "column": 8, "file": "../../tests/t20021/t20021.cc", "line": 11, "translation_unit": "../../tests/t20021/t20021.cc" }, "type": "class" } ], "sequences": [ { "messages": [ { "activity_id": "1682631020380557915", "messages": [ { "from": { "activity_id": "1682631020380557915", "activity_name": "clanguml::t20021::tmain()", "participant_id": "1682631020380557915", "participant_name": "clanguml::t20021::tmain()" }, "name": "c4()", "return_type": "int", "scope": "condition", "source_location": { "column": 17, "file": "../../tests/t20021/t20021.cc", "line": 37, "translation_unit": "../../tests/t20021/t20021.cc" }, "to": { "activity_id": "124927877622321176", "activity_name": "clanguml::t20021::C::c4()", "participant_id": "451128000259357438" }, "type": "message" }, { "from": { "activity_id": "124927877622321176", "activity_name": "clanguml::t20021::C::c4()", "participant_id": "451128000259357438" }, "name": "c5()", "return_type": "int", "scope": "normal", "source_location": { "column": 23, "file": "../../tests/t20021/t20021.cc", "line": 22, "translation_unit": "../../tests/t20021/t20021.cc" }, "to": { "activity_id": "1325720714179808628", "activity_name": "clanguml::t20021::C::c5()", "participant_id": "451128000259357438" }, "type": "message" }, { "from": { "activity_id": "1682631020380557915", "activity_name": "clanguml::t20021::tmain()", "participant_id": "1682631020380557915", "participant_name": "clanguml::t20021::tmain()" }, "name": "a3()", "return_type": "int", "scope": "normal", "source_location": { "column": 17, "file": "../../tests/t20021/t20021.cc", "line": 38, "translation_unit": "../../tests/t20021/t20021.cc" }, "to": { "activity_id": "1867955233624891190", "activity_name": "clanguml::t20021::A::a3()", "participant_id": "1280483607329510730" }, "type": "message" }, { "activity_id": "1682631020380557915", "messages": [ { "activity_id": "1682631020380557915", "messages": [ { "from": { "activity_id": "1682631020380557915", "activity_name": "clanguml::t20021::tmain()", "participant_id": "1682631020380557915", "participant_name": "clanguml::t20021::tmain()" }, "name": "a2()", "return_type": "int", "scope": "condition", "source_location": { "column": 26, "file": "../../tests/t20021/t20021.cc", "line": 40, "translation_unit": "../../tests/t20021/t20021.cc" }, "to": { "activity_id": "1139294797758415018", "activity_name": "clanguml::t20021::A::a2()", "participant_id": "1280483607329510730" }, "type": "message" }, { "from": { "activity_id": "1682631020380557915", "activity_name": "clanguml::t20021::tmain()", "participant_id": "1682631020380557915", "participant_name": "clanguml::t20021::tmain()" }, "name": "c1()", "return_type": "int", "scope": "condition", "source_location": { "column": 38, "file": "../../tests/t20021/t20021.cc", "line": 40, "translation_unit": "../../tests/t20021/t20021.cc" }, "to": { "activity_id": "2143764740072323303", "activity_name": "clanguml::t20021::C::c1()", "participant_id": "451128000259357438" }, "type": "message" }, { "from": { "activity_id": "1682631020380557915", "activity_name": "clanguml::t20021::tmain()", "participant_id": "1682631020380557915", "participant_name": "clanguml::t20021::tmain()" }, "name": "c2()", "return_type": "int", "scope": "condition", "source_location": { "column": 51, "file": "../../tests/t20021/t20021.cc", "line": 40, "translation_unit": "../../tests/t20021/t20021.cc" }, "to": { "activity_id": "1707693479408501017", "activity_name": "clanguml::t20021::C::c2()", "participant_id": "451128000259357438" }, "type": "message" }, { "from": { "activity_id": "1682631020380557915", "activity_name": "clanguml::t20021::tmain()", "participant_id": "1682631020380557915", "participant_name": "clanguml::t20021::tmain()" }, "name": "a1()", "return_type": "int", "scope": "normal", "source_location": { "column": 17, "file": "../../tests/t20021/t20021.cc", "line": 41, "translation_unit": "../../tests/t20021/t20021.cc" }, "to": { "activity_id": "1659488549696810992", "activity_name": "clanguml::t20021::A::a1()", "participant_id": "1280483607329510730" }, "type": "message" } ], "name": "for", "type": "loop" }, { "from": { "activity_id": "1682631020380557915", "activity_name": "clanguml::t20021::tmain()", "participant_id": "1682631020380557915", "participant_name": "clanguml::t20021::tmain()" }, "name": "c3()", "return_type": "int", "scope": "condition", "source_location": { "column": 23, "file": "../../tests/t20021/t20021.cc", "line": 42, "translation_unit": "../../tests/t20021/t20021.cc" }, "to": { "activity_id": "1302892753246800390", "activity_name": "clanguml::t20021::C::c3()", "participant_id": "451128000259357438" }, "type": "message" } ], "name": "do", "type": "loop" } ], "name": "while", "type": "loop" }, { "activity_id": "1682631020380557915", "messages": [ { "from": { "activity_id": "1682631020380557915", "activity_name": "clanguml::t20021::tmain()", "participant_id": "1682631020380557915", "participant_name": "clanguml::t20021::tmain()" }, "name": "b2() const", "return_type": "int", "scope": "normal", "source_location": { "column": 19, "file": "../../tests/t20021/t20021.cc", "line": 47, "translation_unit": "../../tests/t20021/t20021.cc" }, "to": { "activity_id": "1561040999276563077", "activity_name": "clanguml::t20021::B::b2() const", "participant_id": "1849696080443395393" }, "type": "message" } ], "name": "for", "type": "loop" }, { "activity_id": "1682631020380557915", "messages": [ { "from": { "activity_id": "1682631020380557915", "activity_name": "clanguml::t20021::tmain()", "participant_id": "1682631020380557915", "participant_name": "clanguml::t20021::tmain()" }, "name": "contents()", "return_type": "std::vector &", "scope": "condition", "source_location": { "column": 27, "file": "../../tests/t20021/t20021.cc", "line": 50, "translation_unit": "../../tests/t20021/t20021.cc" }, "to": { "activity_id": "814405216385697964", "activity_name": "clanguml::t20021::C::contents()", "participant_id": "451128000259357438" }, "type": "message" } ], "name": "for", "type": "loop" }, { "from": { "activity_id": "1682631020380557915", "activity_name": "clanguml::t20021::tmain()", "participant_id": "1682631020380557915", "participant_name": "clanguml::t20021::tmain()" }, "name": "b2() const", "return_type": "int", "scope": "normal", "source_location": { "column": 12, "file": "../../tests/t20021/t20021.cc", "line": 54, "translation_unit": "../../tests/t20021/t20021.cc" }, "to": { "activity_id": "1561040999276563077", "activity_name": "clanguml::t20021::B::b2() const", "participant_id": "1849696080443395393" }, "type": "message" } ], "start_from": { "id": 1682631020380557915, "location": "clanguml::t20021::tmain()" } } ], "using_namespace": "clanguml::t20021" } ```