Files
clang-uml/docs/test_cases/t20004.md
2023-08-31 23:43:57 +02:00

12 KiB

t20004 - Function template instantiation sequence diagram test case

Config

compilation_database_dir: ..
output_directory: puml
diagrams:
  t20004_sequence:
    type: sequence
    glob:
      - ../../tests/t20004/t20004.cc
    include:
      namespaces:
        - clanguml::t20004
    using_namespace:
      - clanguml::t20004
    from:
      - function: "clanguml::t20004::main()"

Source code

File t20004.cc

#include <string>

namespace clanguml {
namespace t20004 {

template <typename T> T m4(T p);

template <> [[maybe_unused]] int m4<int>(int p) { return p + 2; }

template <> [[maybe_unused]] unsigned long m4<unsigned long>(unsigned long p)
{
    return 1000 * p;
}

template <typename T> T m3(T p) { return m4<T>(p); }

template <typename T> T m2(T p) { return m3<T>(p); }

template <> [[maybe_unused]] std::string m2<std::string>(std::string p)
{
    return std::string{"m2"} + p;
}

template <typename T> T m1(T p) { return m2<T>(p); }

template <> [[maybe_unused]] float m1<float>(float p) { return 2 * p; }

template <> [[maybe_unused]] unsigned long m1<unsigned long>(unsigned long p)
{
    return m4<unsigned long>(p);
}

template <> [[maybe_unused]] std::string m1<std::string>(std::string p)
{
    return m2<std::string>(p);
}

int main()
{
    m1<float>(2.2);

    m1<unsigned long>(100);

    m1<std::string>("main");

    return m1<int>(0);
}
}
}

Generated UML diagrams

t20004_sequence

Generated JSON models

{
  "diagram_type": "sequence",
  "metadata": {
    "clang_uml_version": "0.3.8-32-ge830195",
    "llvm_version": "Ubuntu clang version 15.0.7",
    "schema_version": 1
  },
  "name": "t20004_sequence",
  "participants": [
    {
      "id": "2299662004367884401",
      "name": "clanguml::t20004::main()",
      "source_location": {
        "column": 5,
        "file": "../../tests/t20004/t20004.cc",
        "line": 38,
        "translation_unit": "../../tests/t20004/t20004.cc"
      },
      "type": "function"
    },
    {
      "id": "138925040763435897",
      "name": "clanguml::t20004::m1<float>(float)",
      "source_location": {
        "column": 36,
        "file": "../../tests/t20004/t20004.cc",
        "line": 26,
        "translation_unit": "../../tests/t20004/t20004.cc"
      },
      "type": "function_template"
    },
    {
      "id": "1239083518717603720",
      "name": "clanguml::t20004::m1<unsigned long>(unsigned long)",
      "source_location": {
        "column": 44,
        "file": "../../tests/t20004/t20004.cc",
        "line": 28,
        "translation_unit": "../../tests/t20004/t20004.cc"
      },
      "type": "function_template"
    },
    {
      "id": "376599675205498367",
      "name": "clanguml::t20004::m4<unsigned long>(unsigned long)",
      "source_location": {
        "column": 44,
        "file": "../../tests/t20004/t20004.cc",
        "line": 10,
        "translation_unit": "../../tests/t20004/t20004.cc"
      },
      "type": "function_template"
    },
    {
      "id": "1845817984839618223",
      "name": "clanguml::t20004::m1<std::string>(std::string)",
      "source_location": {
        "column": 42,
        "file": "../../tests/t20004/t20004.cc",
        "line": 33,
        "translation_unit": "../../tests/t20004/t20004.cc"
      },
      "type": "function_template"
    },
    {
      "id": "1735054254122948614",
      "name": "clanguml::t20004::m2<std::string>(std::string)",
      "source_location": {
        "column": 42,
        "file": "../../tests/t20004/t20004.cc",
        "line": 19,
        "translation_unit": "../../tests/t20004/t20004.cc"
      },
      "type": "function_template"
    },
    {
      "id": "121663532044911922",
      "name": "clanguml::t20004::m1<int>(int)",
      "source_location": {
        "column": 25,
        "file": "../../tests/t20004/t20004.cc",
        "line": 24,
        "translation_unit": "../../tests/t20004/t20004.cc"
      },
      "type": "function_template"
    },
    {
      "id": "1475362124497386656",
      "name": "clanguml::t20004::m2<int>(int)",
      "source_location": {
        "column": 25,
        "file": "../../tests/t20004/t20004.cc",
        "line": 17,
        "translation_unit": "../../tests/t20004/t20004.cc"
      },
      "type": "function_template"
    },
    {
      "id": "734999226157549914",
      "name": "clanguml::t20004::m3<int>(int)",
      "source_location": {
        "column": 25,
        "file": "../../tests/t20004/t20004.cc",
        "line": 15,
        "translation_unit": "../../tests/t20004/t20004.cc"
      },
      "type": "function_template"
    },
    {
      "id": "1006390865908497562",
      "name": "clanguml::t20004::m4<int>(int)",
      "source_location": {
        "column": 34,
        "file": "../../tests/t20004/t20004.cc",
        "line": 8,
        "translation_unit": "../../tests/t20004/t20004.cc"
      },
      "type": "function_template"
    }
  ],
  "sequences": [
    {
      "messages": [
        {
          "from": {
            "activity_id": "2299662004367884401",
            "activity_name": "clanguml::t20004::main()",
            "participant_id": "2299662004367884401",
            "participant_name": "clanguml::t20004::main()"
          },
          "name": "",
          "return_type": "",
          "scope": "normal",
          "source_location": {
            "column": 5,
            "file": "../../tests/t20004/t20004.cc",
            "line": 40,
            "translation_unit": "../../tests/t20004/t20004.cc"
          },
          "to": {
            "activity_id": "138925040763435897",
            "activity_name": "clanguml::t20004::m1<float>(float)",
            "participant_id": "138925040763435897"
          },
          "type": "message"
        },
        {
          "from": {
            "activity_id": "2299662004367884401",
            "activity_name": "clanguml::t20004::main()",
            "participant_id": "2299662004367884401",
            "participant_name": "clanguml::t20004::main()"
          },
          "name": "",
          "return_type": "",
          "scope": "normal",
          "source_location": {
            "column": 5,
            "file": "../../tests/t20004/t20004.cc",
            "line": 42,
            "translation_unit": "../../tests/t20004/t20004.cc"
          },
          "to": {
            "activity_id": "1239083518717603720",
            "activity_name": "clanguml::t20004::m1<unsigned long>(unsigned long)",
            "participant_id": "1239083518717603720"
          },
          "type": "message"
        },
        {
          "from": {
            "activity_id": "1239083518717603720",
            "activity_name": "clanguml::t20004::m1<unsigned long>(unsigned long)",
            "participant_id": "1239083518717603720",
            "participant_name": "clanguml::t20004::m1<unsigned long>(unsigned long)"
          },
          "name": "",
          "return_type": "",
          "scope": "normal",
          "source_location": {
            "column": 12,
            "file": "../../tests/t20004/t20004.cc",
            "line": 30,
            "translation_unit": "../../tests/t20004/t20004.cc"
          },
          "to": {
            "activity_id": "376599675205498367",
            "activity_name": "clanguml::t20004::m4<unsigned long>(unsigned long)",
            "participant_id": "376599675205498367"
          },
          "type": "message"
        },
        {
          "from": {
            "activity_id": "2299662004367884401",
            "activity_name": "clanguml::t20004::main()",
            "participant_id": "2299662004367884401",
            "participant_name": "clanguml::t20004::main()"
          },
          "name": "",
          "return_type": "",
          "scope": "normal",
          "source_location": {
            "column": 5,
            "file": "../../tests/t20004/t20004.cc",
            "line": 44,
            "translation_unit": "../../tests/t20004/t20004.cc"
          },
          "to": {
            "activity_id": "1845817984839618223",
            "activity_name": "clanguml::t20004::m1<std::string>(std::string)",
            "participant_id": "1845817984839618223"
          },
          "type": "message"
        },
        {
          "from": {
            "activity_id": "1845817984839618223",
            "activity_name": "clanguml::t20004::m1<std::string>(std::string)",
            "participant_id": "1845817984839618223",
            "participant_name": "clanguml::t20004::m1<std::string>(std::string)"
          },
          "name": "",
          "return_type": "",
          "scope": "normal",
          "source_location": {
            "column": 12,
            "file": "../../tests/t20004/t20004.cc",
            "line": 35,
            "translation_unit": "../../tests/t20004/t20004.cc"
          },
          "to": {
            "activity_id": "1735054254122948614",
            "activity_name": "clanguml::t20004::m2<std::string>(std::string)",
            "participant_id": "1735054254122948614"
          },
          "type": "message"
        },
        {
          "from": {
            "activity_id": "2299662004367884401",
            "activity_name": "clanguml::t20004::main()",
            "participant_id": "2299662004367884401",
            "participant_name": "clanguml::t20004::main()"
          },
          "name": "",
          "return_type": "",
          "scope": "normal",
          "source_location": {
            "column": 12,
            "file": "../../tests/t20004/t20004.cc",
            "line": 46,
            "translation_unit": "../../tests/t20004/t20004.cc"
          },
          "to": {
            "activity_id": "121663532044911922",
            "activity_name": "clanguml::t20004::m1<int>(int)",
            "participant_id": "121663532044911922"
          },
          "type": "message"
        },
        {
          "from": {
            "activity_id": "121663532044911922",
            "activity_name": "clanguml::t20004::m1<int>(int)",
            "participant_id": "121663532044911922",
            "participant_name": "clanguml::t20004::m1<int>(int)"
          },
          "name": "",
          "return_type": "",
          "scope": "normal",
          "source_location": {
            "column": 42,
            "file": "../../tests/t20004/t20004.cc",
            "line": 24,
            "translation_unit": "../../tests/t20004/t20004.cc"
          },
          "to": {
            "activity_id": "1475362124497386656",
            "activity_name": "clanguml::t20004::m2<int>(int)",
            "participant_id": "1475362124497386656"
          },
          "type": "message"
        },
        {
          "from": {
            "activity_id": "1475362124497386656",
            "activity_name": "clanguml::t20004::m2<int>(int)",
            "participant_id": "1475362124497386656",
            "participant_name": "clanguml::t20004::m2<int>(int)"
          },
          "name": "",
          "return_type": "",
          "scope": "normal",
          "source_location": {
            "column": 42,
            "file": "../../tests/t20004/t20004.cc",
            "line": 17,
            "translation_unit": "../../tests/t20004/t20004.cc"
          },
          "to": {
            "activity_id": "734999226157549914",
            "activity_name": "clanguml::t20004::m3<int>(int)",
            "participant_id": "734999226157549914"
          },
          "type": "message"
        },
        {
          "from": {
            "activity_id": "734999226157549914",
            "activity_name": "clanguml::t20004::m3<int>(int)",
            "participant_id": "734999226157549914",
            "participant_name": "clanguml::t20004::m3<int>(int)"
          },
          "name": "",
          "return_type": "",
          "scope": "normal",
          "source_location": {
            "column": 42,
            "file": "../../tests/t20004/t20004.cc",
            "line": 15,
            "translation_unit": "../../tests/t20004/t20004.cc"
          },
          "to": {
            "activity_id": "1006390865908497562",
            "activity_name": "clanguml::t20004::m4<int>(int)",
            "participant_id": "1006390865908497562"
          },
          "type": "message"
        }
      ],
      "start_from": {
        "id": 2299662004367884401,
        "location": "clanguml::t20004::main()"
      }
    }
  ],
  "using_namespace": "clanguml::t20004"
}