# t20033 - Control statement text in sequence diagram test case ## Config ```yaml compilation_database_dir: .. output_directory: puml diagrams: t20033_sequence: type: sequence glob: - ../../tests/t20033/t20033.cc include: namespaces: - clanguml::t20033 using_namespace: - clanguml::t20033 generate_condition_statements: true start_from: - function: "clanguml::t20033::tmain()" ``` ## Source code File t20033.cc ```cpp #include #include #include namespace clanguml { namespace t20033 { struct A { int a1() { return 0; } int a2() { return 1; } int a3() { return 2; } int a4() { return 3; } }; int tmain() { A a; int result{}; // clang-format off if(false) { result = 0; } else if (reinterpret_cast(&a) % 100 == 0ULL) { result = a.a1(); } else if (reinterpret_cast(&a) % 64 == 0ULL) { result = a.a2(); } else if(a.a2() == 2 && a.a3() == 3) { result = a.a3(); } else { result = a.a4(); } // clang-format on if (int i = a.a2(); i != 2) { result += a.a3(); } for (int i = 0; i < a.a2(); i++) { result += i * a.a3(); } int retry_count = a.a3(); while (retry_count--) { result -= a.a2(); } do { result += a.a4(); } while (retry_count++ < a.a3()); result = a.a4() % 6 ? result * 2 : result; std::vector ints; for (auto i : ints) { result += a.a4(); } return result; } } } ``` ## Generated UML diagrams ![t20033_sequence](./t20033_sequence.svg "Control statement text in sequence diagram test case") ## Generated JSON models ```json { "diagram_type": "sequence", "metadata": { "clang_uml_version": "0.3.7-49-g3bd8f7f", "llvm_version": "Ubuntu clang version 15.0.6", "schema_version": 1 }, "name": "t20033_sequence", "participants": [ { "id": "2284981553733959328", "name": "clanguml::t20033::tmain()", "source_location": { "column": 5, "file": "../../tests/t20033/t20033.cc", "line": 14, "translation_unit": "../../tests/t20033/t20033.cc" }, "type": "function" }, { "id": "615995652843962691", "name": "clanguml::t20033::A", "source_location": { "column": 8, "file": "../../tests/t20033/t20033.cc", "line": 7, "translation_unit": "../../tests/t20033/t20033.cc" }, "type": "class" } ], "sequences": [ { "messages": [ { "activity_id": "2284981553733959328", "branches": [ { "type": "consequent" }, { "messages": [ { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a1()", "return_type": "int", "scope": "normal", "source_location": { "column": 18, "file": "../../tests/t20033/t20033.cc", "line": 24, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "558885502745634115", "activity_name": "clanguml::t20033::A::a1()", "participant_id": "615995652843962691" }, "type": "message" }, { "activity_id": "2284981553733959328", "branches": [ { "messages": [ { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a2()", "return_type": "int", "scope": "normal", "source_location": { "column": 18, "file": "../../tests/t20033/t20033.cc", "line": 27, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "748502947476611794", "activity_name": "clanguml::t20033::A::a2()", "participant_id": "615995652843962691" }, "type": "message" } ], "type": "consequent" }, { "messages": [ { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a2()", "return_type": "int", "scope": "condition", "source_location": { "column": 13, "file": "../../tests/t20033/t20033.cc", "line": 29, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "748502947476611794", "activity_name": "clanguml::t20033::A::a2()", "participant_id": "615995652843962691" }, "type": "message" }, { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a3()", "return_type": "int", "scope": "condition", "source_location": { "column": 13, "file": "../../tests/t20033/t20033.cc", "line": 30, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "55903385814245839", "activity_name": "clanguml::t20033::A::a3()", "participant_id": "615995652843962691" }, "type": "message" }, { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a3()", "return_type": "int", "scope": "normal", "source_location": { "column": 18, "file": "../../tests/t20033/t20033.cc", "line": 31, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "55903385814245839", "activity_name": "clanguml::t20033::A::a3()", "participant_id": "615995652843962691" }, "type": "message" } ], "type": "alternative" }, { "messages": [ { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a4()", "return_type": "int", "scope": "normal", "source_location": { "column": 18, "file": "../../tests/t20033/t20033.cc", "line": 34, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "1686426476339443579", "activity_name": "clanguml::t20033::A::a4()", "participant_id": "615995652843962691" }, "type": "message" } ], "type": "alternative" } ], "condition_text": "reinterpret_cast(&a) % 64 == 0ULL", "name": "if", "type": "alt" } ], "type": "alternative" } ], "condition_text": "false", "name": "if", "type": "alt" }, { "activity_id": "2284981553733959328", "branches": [ { "messages": [ { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a2()", "return_type": "int", "scope": "condition", "source_location": { "column": 17, "file": "../../tests/t20033/t20033.cc", "line": 38, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "748502947476611794", "activity_name": "clanguml::t20033::A::a2()", "participant_id": "615995652843962691" }, "type": "message" }, { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a3()", "return_type": "int", "scope": "normal", "source_location": { "column": 19, "file": "../../tests/t20033/t20033.cc", "line": 39, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "55903385814245839", "activity_name": "clanguml::t20033::A::a3()", "participant_id": "615995652843962691" }, "type": "message" } ], "type": "consequent" } ], "condition_text": "int i = a.a2(); i != 2", "name": "if", "type": "alt" }, { "activity_id": "2284981553733959328", "condition_text": "int i = 0; i < a.a2(); i++", "messages": [ { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a2()", "return_type": "int", "scope": "condition", "source_location": { "column": 25, "file": "../../tests/t20033/t20033.cc", "line": 42, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "748502947476611794", "activity_name": "clanguml::t20033::A::a2()", "participant_id": "615995652843962691" }, "type": "message" }, { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a3()", "return_type": "int", "scope": "normal", "source_location": { "column": 23, "file": "../../tests/t20033/t20033.cc", "line": 43, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "55903385814245839", "activity_name": "clanguml::t20033::A::a3()", "participant_id": "615995652843962691" }, "type": "message" } ], "name": "for", "type": "loop" }, { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a3()", "return_type": "int", "scope": "normal", "source_location": { "column": 23, "file": "../../tests/t20033/t20033.cc", "line": 46, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "55903385814245839", "activity_name": "clanguml::t20033::A::a3()", "participant_id": "615995652843962691" }, "type": "message" }, { "activity_id": "2284981553733959328", "condition_text": "retry_count--", "messages": [ { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a2()", "return_type": "int", "scope": "normal", "source_location": { "column": 19, "file": "../../tests/t20033/t20033.cc", "line": 48, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "748502947476611794", "activity_name": "clanguml::t20033::A::a2()", "participant_id": "615995652843962691" }, "type": "message" } ], "name": "while", "type": "loop" }, { "activity_id": "2284981553733959328", "condition_text": "retry_count++ < a.a3()", "messages": [ { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a4()", "return_type": "int", "scope": "normal", "source_location": { "column": 19, "file": "../../tests/t20033/t20033.cc", "line": 52, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "1686426476339443579", "activity_name": "clanguml::t20033::A::a4()", "participant_id": "615995652843962691" }, "type": "message" }, { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a3()", "return_type": "int", "scope": "condition", "source_location": { "column": 30, "file": "../../tests/t20033/t20033.cc", "line": 53, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "55903385814245839", "activity_name": "clanguml::t20033::A::a3()", "participant_id": "615995652843962691" }, "type": "message" } ], "name": "do", "type": "loop" }, { "activity_id": "2284981553733959328", "branches": [ { "messages": [ { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a4()", "return_type": "int", "scope": "condition", "source_location": { "column": 14, "file": "../../tests/t20033/t20033.cc", "line": 55, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "1686426476339443579", "activity_name": "clanguml::t20033::A::a4()", "participant_id": "615995652843962691" }, "type": "message" } ], "type": "consequent" }, { "type": "alternative" } ], "condition_text": "a.a4() % 6", "name": "conditional", "type": "alt" }, { "activity_id": "2284981553733959328", "condition_text": "ints", "messages": [ { "from": { "activity_id": "2284981553733959328", "activity_name": "clanguml::t20033::tmain()", "participant_id": "2284981553733959328", "participant_name": "clanguml::t20033::tmain()" }, "name": "a4()", "return_type": "int", "scope": "normal", "source_location": { "column": 19, "file": "../../tests/t20033/t20033.cc", "line": 59, "translation_unit": "../../tests/t20033/t20033.cc" }, "to": { "activity_id": "1686426476339443579", "activity_name": "clanguml::t20033::A::a4()", "participant_id": "615995652843962691" }, "type": "message" } ], "name": "for", "type": "loop" } ], "start_from": { "id": 2284981553733959328, "location": "clanguml::t20033::tmain()" } } ], "using_namespace": "clanguml::t20033" } ```