Files
clang-uml/docs/test_cases/t20008.md
2023-05-15 01:26:34 +02:00

279 lines
7.3 KiB
Markdown

# t20008 - Constexpr if sequence diagram test case
## Config
```yaml
compilation_database_dir: ..
output_directory: puml
diagrams:
t20008_sequence:
type: sequence
glob:
- ../../tests/t20008/t20008.cc
include:
namespaces:
- clanguml::t20008
using_namespace:
- clanguml::t20008
start_from:
- function: "clanguml::t20008::tmain()"
```
## Source code
File t20008.cc
```cpp
#include <string>
#include <type_traits>
namespace clanguml {
namespace t20008 {
template <typename T> struct A {
void a1(T arg) { }
void a2(T arg) { }
void a3(T arg) { }
};
template <typename T> struct B {
A<T> a;
void b(T arg)
{
if constexpr (std::is_integral_v<T>) {
a.a1(arg);
}
else if constexpr (std::is_pointer_v<T>) {
a.a2(arg);
}
else {
a.a3(arg);
}
}
};
void tmain()
{
using namespace std::string_literals;
B<int> bint;
B<const char *> bcharp;
B<std::string> bstring;
bint.b(1);
bcharp.b("1");
bstring.b("1"s);
}
}
}
```
## Generated UML diagrams
![t20008_sequence](./t20008_sequence.svg "Constexpr if sequence diagram test case")
## Generated JSON models
```json
{
"diagram_type": "sequence",
"metadata": {
"clang_uml_version": "0.3.5-13-g57aa174",
"llvm_version": "Ubuntu clang version 15.0.6",
"schema_version": 1
},
"name": "t20008_sequence",
"participants": [
{
"id": "1180776240543224244",
"name": "clanguml::t20008::tmain()",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 30
},
"type": "function"
},
{
"id": "1906510289157013670",
"name": "clanguml::t20008::B<int>",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 13
},
"type": "class"
},
{
"id": "1376149084762923197",
"name": "clanguml::t20008::A<int>",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 7
},
"type": "class"
},
{
"id": "867098551202196741",
"name": "clanguml::t20008::B<const char *>",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 13
},
"type": "class"
},
{
"id": "144833378017373200",
"name": "clanguml::t20008::A<const char *>",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 7
},
"type": "class"
},
{
"id": "927702553742507923",
"name": "clanguml::t20008::B<std::string>",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 13
},
"type": "class"
},
{
"id": "390605614583363778",
"name": "clanguml::t20008::A<std::string>",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 7
},
"type": "class"
}
],
"sequences": [
{
"messages": [
{
"from": {
"activity_id": "1180776240543224244",
"activity_name": "clanguml::t20008::tmain()",
"participant_id": "1180776240543224244",
"participant_name": "clanguml::t20008::tmain()"
},
"name": "b(int)",
"return_type": "void",
"scope": "normal",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 38
},
"to": {
"activity_id": "379850145437051189",
"activity_name": "clanguml::t20008::B<int>::b(int)",
"participant_id": "1906510289157013670"
},
"type": "message"
},
{
"from": {
"activity_id": "379850145437051189",
"activity_name": "clanguml::t20008::B<int>::b(int)",
"participant_id": "1906510289157013670"
},
"name": "a1(int)",
"return_type": "void",
"scope": "normal",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 19
},
"to": {
"activity_id": "2066363630174644719",
"activity_name": "clanguml::t20008::A<int>::a1(int)",
"participant_id": "1376149084762923197"
},
"type": "message"
},
{
"from": {
"activity_id": "1180776240543224244",
"activity_name": "clanguml::t20008::tmain()",
"participant_id": "1180776240543224244",
"participant_name": "clanguml::t20008::tmain()"
},
"name": "b(const char *)",
"return_type": "void",
"scope": "normal",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 39
},
"to": {
"activity_id": "1347162523481637780",
"activity_name": "clanguml::t20008::B<const char *>::b(const char *)",
"participant_id": "867098551202196741"
},
"type": "message"
},
{
"from": {
"activity_id": "1347162523481637780",
"activity_name": "clanguml::t20008::B<const char *>::b(const char *)",
"participant_id": "867098551202196741"
},
"name": "a2(const char *)",
"return_type": "void",
"scope": "normal",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 22
},
"to": {
"activity_id": "718650834962275580",
"activity_name": "clanguml::t20008::A<const char *>::a2(const char *)",
"participant_id": "144833378017373200"
},
"type": "message"
},
{
"from": {
"activity_id": "1180776240543224244",
"activity_name": "clanguml::t20008::tmain()",
"participant_id": "1180776240543224244",
"participant_name": "clanguml::t20008::tmain()"
},
"name": "b(std::string)",
"return_type": "void",
"scope": "normal",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 40
},
"to": {
"activity_id": "1286410946666951254",
"activity_name": "clanguml::t20008::B<std::string>::b(std::string)",
"participant_id": "927702553742507923"
},
"type": "message"
},
{
"from": {
"activity_id": "1286410946666951254",
"activity_name": "clanguml::t20008::B<std::string>::b(std::string)",
"participant_id": "927702553742507923"
},
"name": "a3(std::string)",
"return_type": "void",
"scope": "normal",
"source_location": {
"file": "../../tests/t20008/t20008.cc",
"line": 25
},
"to": {
"activity_id": "1404594247101138737",
"activity_name": "clanguml::t20008::A<std::string>::a3(std::string)",
"participant_id": "390605614583363778"
},
"type": "message"
}
],
"start_from": {
"id": 1180776240543224244,
"location": "clanguml::t20008::tmain()"
}
}
],
"using_namespace": "clanguml::t20008"
}
```