Giter Club home page Giter Club logo

clang-uml's Introduction

C++ UML diagram generator based on Clang

Build status Coverage Version Version Doxygen

clang-uml is an automatic C++ to UML class, sequence, package and include diagram generator, driven by YAML configuration files. The main idea behind the project is to easily maintain up-to-date diagrams within a code-base or document legacy code. The configuration file or files for clang-uml define the types and contents of each generated diagram. The diagrams can be generated in PlantUML, MermaidJS and JSON formats.

clang-uml currently supports C++ up to version 17 with partial support for C++ 20.

Full documentation can be found at clang-uml.github.io.

To see what clang-uml can do, checkout the diagrams generated for unit test cases here or examples in clang-uml-examples repository.

Features

Main features supported so far include:

  • Class diagram generation
    • Class properties and methods including access scope - example
    • Class inheritance - example
    • Other class relationships including associations, aggregations, dependencies and friendship - example
    • Template instantiation relationships - example
    • Template specialization and instantiation based on deduced context - example
    • Relationship inference from C++ containers and smart pointers - example
    • Diagram content filtering based on namespaces, elements and relationships - example
    • Optional package generation from namespaces (only PlantUML) - example
    • Optional package generation from subdirectories (only PlantUML) - example
    • Optional package generation from C++20 modules (only PlantUML) - example
    • Interactive links to online code or docs for classes, methods and class fields in SVG diagrams - example
    • Support for plain C99/C11 code (struct, units and their relationships) - example
    • C++20 concept constraints - example
    • C++20 coroutines - example
    • Diagram content filtering based on C++20 modules - example
  • Sequence diagram generation
    • Generation of sequence diagram from specific method or function - example
    • Generation of loop and conditional statements - example
    • Generation of switch statements - example
    • Generation of try/catch blocks - example
    • Handling of template code including constexpr conditionals - example
    • Handling of lambda expressions - example
    • Interactive links to online code to classes and call expressions - example
    • Support for CUDA Kernel and CUDA Device function calls - example
  • Package diagram generation
    • Generation of package diagram based on C++ namespaces - example
    • Generation of package diagram based on subdirectories - example
    • Generation of package diagram based on C++20 modules - example
    • Dependencies between packages based on symbols used in the code - example
    • Interactive links to online code to packages - example
  • Include graph diagram generation
    • Show include graph for selected files - example

More comprehensive documentation can be at clang-uml.github.io.

Installation

Installation instructions for Linux, macos and Windows can be found here.

Usage

Generating compile commands database

clang-uml requires an up-to-date compile_commands.json file, containing the list of commands used for compiling the source code. Nowadays, this file can be generated rather easily using multiple methods:

Invocation

By default, clang-uml will assume that the configuration file .clang-uml and compilation database compile_commands.json files are in the current directory, so if they are in the top level directory of a project, simply run:

clang-uml

The output path for diagrams, as well as alternative location of compilation database can be specified in .clang-uml configuration file.

For other options checkout help:

clang-uml --help

Configuration file format and examples

Configuration files are written in YAML, and provide a list of diagrams which should be generated by clang-uml. Basic example is as follows:

compilation_database_dir: .
output_directory: diagrams
diagrams:
  myproject_class:
    type: class
    glob:
      - src/*.cc
    using_namespace: myproject
    include:
      namespaces:
        - myproject
    exclude:
      namespaces:
        - myproject::detail
    plantuml:
      after:
        - 'note left of {{ alias("MyProjectMain") }}: Main class of myproject library.'

See here for detailed configuration file reference guide.

Examples

To see what clang-uml can do, checkout the test cases documentation here.

In order to see diagrams for the clang-uml itself, based on its own config run the following:

make clanguml_diagrams

and checkout the SVG diagrams in docs/diagrams folder.

Class diagrams

Example

The following C++ code:

template <typename T, typename P> struct A {
    T t;
    P p;
};

struct B {
    std::string value;
};

template <typename T> using AString = A<T, std::string>;
template <typename T> using AStringPtr = A<T, std::unique_ptr<std::string>>;

template <typename T>
using PairPairBA = std::pair<std::pair<B, A<long, T>>, long>;

template <class T> using VectorPtr = std::unique_ptr<std::vector<T>>;
template <class T> using APtr = std::unique_ptr<A<double, T>>;
template <class T> using ASharedPtr = std::shared_ptr<A<double, T>>;

template <class T, class U>
using AAPtr = std::unique_ptr<std::pair<A<double, T>, A<long, U>>>;

template <typename T> using SimpleCallback = std::function<void(T, int)>;
template <typename... T> using GenericCallback = std::function<void(T..., int)>;
using VoidCallback = GenericCallback<void *>;

using BVector = std::vector<B>;
using BVector2 = BVector;

using AIntString = AString<int>;
using ACharString = AString<char>;

using AStringString = AString<std::string>;
using BStringString = AStringString;

template <typename T> class R {
    using AWCharString = AString<wchar_t>;

    PairPairBA<bool> bapair;

    APtr<bool> abool;
    AAPtr<bool, float> aboolfloat;
    ASharedPtr<float> afloat;
    A<bool, std::string> boolstring;
    AStringPtr<float> floatstring;
    AIntString intstring;
    AStringString stringstring;
    BStringString bstringstring;
    AAPtr<T, float> atfloat;

protected:
    BVector bs;

public:
    BVector2 bs2;
    SimpleCallback<ACharString> cb;
    GenericCallback<AWCharString> gcb;
    VoidCallback vcb;
    VectorPtr<B> vps;
};

results in the following diagram (via PlantUML):

class_diagram_example

Open the raw image here, and checkout the hover tooltips and hyperlinks to classes and methods.

Sequence diagrams

Example

The following C++ code:

#include <atomic>
#include <functional>
#include <iostream>
#include <memory>
#include <string>

namespace clanguml {
namespace t20029 {
std::string encode_b64(std::string &&content) { return std::move(content); }

template <typename T> class Encoder : public T {
public:
    bool send(std::string &&msg)
    {
        return T::send(std::move(
            // Encode the message using Base64 encoding and pass it to the next
            // layer
            encode(std::move(msg))));
    }

protected:
    std::string encode(std::string &&msg) { return encode_b64(std::move(msg)); }
};

template <typename T> class Retrier : public T {
public:
    bool send(std::string &&msg)
    {
        std::string buffer{std::move(msg)};

        int retryCount = 5;

        // Repeat until send() succeeds or retry count is exceeded
        while (retryCount--) {
            if (T::send(buffer))
                return true;
        }

        return false;
    }
};

class ConnectionPool {
public:
    void connect()
    {
        if (!is_connected_.load())
            connect_impl();
    }

    bool send(const std::string &msg) { return true; }

private:
    void connect_impl() { is_connected_ = true; }

    std::atomic<bool> is_connected_;
};

int tmain()
{
    auto pool = std::make_shared<Encoder<Retrier<ConnectionPool>>>();

    // Establish connection to the remote server synchronously
    pool->connect();

    // Repeat for each line in the input stream
    for (std::string line; std::getline(std::cin, line);) {
        if (!pool->send(std::move(line)))
            break;
    }

    return 0;
}
}
}

results in the following diagram (via PlantUML):

sequence_diagram_example

Package diagrams

Example

The following C++ code:

namespace clanguml {
namespace t30003 {

namespace ns1 {
namespace ns2_v1_0_0 {
class A {
};
}

namespace [[deprecated]] ns2_v0_9_0 {
class A {
};
}

namespace {
class Anon final {
};
}
}

namespace [[deprecated]] ns3 {

namespace ns1::ns2 {
class Anon : public t30003::ns1::ns2_v1_0_0::A {
};
}

class B : public ns1::ns2::Anon {
};
}
}
}

results in the following diagram (via PlantUML):

package_diagram_example

Include diagrams

In case you're looking for a simpler tool to visualize and analyze include graphs checkout my other tool - clang-include-graph

Example

The following C++ code structure:

tests/t40001
├── include
│   ├── lib1
│   │   └── lib1.h
│   └── t40001_include1.h
└── src
    └── t40001.cc

results in the following diagram (via PlantUML) based on include directives in the code:

package_diagram_example

Default mappings

UML PlantUML MermaidJS
Inheritance extension extension
Association association association
Dependency dependency dependency
Aggregation aggregation aggregation
Composition composition composition
Template specialization/instantiation specialization specialization
Nesting (inner class/enum) nesting nesting
Include (local) association association
Include (system) dependency dependency

Diagram content filtering

For typical code bases, generating a single diagram from entire code or even a single namespace can be too big to be useful, e.g. as part of documentation. clang-uml allows specifying content to be included and excluded from each diagram using simple YAML configuration:

include:
  # Include only elements from these namespaces
  namespaces:
    - clanguml::common
    - clanguml::config
  # Include all subclasses of ClassA (including ClassA)
  subclasses:
    - clanguml::common::ClassA
  # and specializations of template Class<T> (including Class<T>)
  specializations:
    - clanguml::common::ClassT<T>
  # and all classes depending on Class D
  dependants:
    - clanguml::common::ClassD
  # and all dependencies of ClassE
  dependencies:
    - clanguml::common::ClassE
  # and classes in direct relation to ClassB (including ClassB)
  context:
    - clanguml::common::ClassB
  # Include only inheritance relationships
  relationships:
    - inheritance
exclude:
  # Exclude all elements from detail namespace
  namespaces:
    - clanguml::common::detail
  # and also exclude ClassF
  elements:
    - clanguml::common::ClassF

More details on this can be found in the diagram filters documentation section.

Test cases

The build-in test cases used for unit testing of the clang-uml, can be browsed here.

Acknowledgements

This project relies on the following great tools:

  • Clang LibTooling - a C++ library for creating tools based on Clang
  • PlantUML - language and diagram for generating UML diagrams
  • MermaidJS - JavaScript based diagramming and charting tool
  • Catch2 - C++ unit test framework
  • glob - Unix style path expansion for C++
  • indicators - Activity indicators for modern C++
  • CLI11 - command line parser for C++
  • inja - a template engine for modern C++
  • backward-cpp - stack trace pretty printer for C++
  • yaml-cpp - YAML parser library for C++
  • spdlog - Fast C++ logging library
  • Doxygen - C++ documentation generator
  • Doxygen Awesome - Doxygen CSS style
  • miroir - YAML schema validation library for C++

Contributing

If you would like to contribute to the project, please check out contributing guidelines.

LICENSE

Copyright 2021-present Bartek Kryza <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

clang-uml's People

Contributors

bkryza avatar bram avatar buffyanamin avatar dgoffredo avatar hatch01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clang-uml's Issues

Error when run clang-uml

make clanguml_diagrams

Error while processing /Users/suxb201/gits/clang-uml/src/package_diagram/model/diagram.cc.
In file included from /Users/suxb201/gits/clang-uml/src/package_diagram/visitor/translation_unit_visitor.cc:19:
In file included from /Users/suxb201/gits/clang-uml/src/package_diagram/visitor/translation_unit_visitor.h:20:
In file included from /Users/suxb201/gits/clang-uml/src/common/visitor/translation_unit_visitor.h:20:
In file included from /Users/suxb201/gits/clang-uml/src/common/visitor/comment/comment_visitor.h:20:
In file included from /usr/local/opt/llvm@14/include/clang/AST/Comment.h:16:
In file included from /usr/local/opt/llvm@14/include/clang/AST/CommentCommandTraits.h:18:
In file included from /usr/local/opt/llvm@14/include/clang/Basic/CommentOptions.h:17:
In file included from /usr/local/opt/llvm@14/bin/../include/c++/v1/string:522:
In file included from /usr/local/opt/llvm@14/bin/../include/c++/v1/__debug:14:
In file included from /usr/local/opt/llvm@14/bin/../include/c++/v1/iosfwd:98:
In file included from /usr/local/opt/llvm@14/bin/../include/c++/v1/__mbstate_t.h:29:
In file included from /usr/local/opt/llvm@14/bin/../include/c++/v1/wchar.h:123:
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/wchar.h:89:10: fatal error: 'stdarg.h' file not found
#include <stdarg.h>
         ^~~~~~~~~~
1 error generated.
Error while processing /Users/suxb201/gits/clang-uml/src/package_diagram/visitor/translation_unit_visitor.cc.

clang --version

Homebrew clang version 14.0.6
Target: x86_64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm@14/bin

Building error fix needed .

:clang-uml $ make release
cmake -S . -B release
-DGIT_VERSION=0.3.0-2-g476a787
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_CXX_FLAGS=""
-DCMAKE_EXE_LINKER_FLAGS=""
-DLLVM_VERSION=
-- Checking for LLVM and Clang...
-- Found LLVM 15.0.6
-- Using LLVMConfig.cmake in: /usr/local/Cellar/llvm/15.0.6/lib/cmake/llvm
-- LLVM library dir: /usr/local/Cellar/llvm/15.0.6/lib
-- Checking for yaml-cpp...
-- Using CMAKE_CXX_FLAGS: -Werror -Wall -Wextra -std=c++17 -Wno-unused-parameter -Wno-unused-private-field
t00002/.clang-uml
t00003/.clang-uml
t00004/.clang-uml
t00005/.clang-uml
t00006/.clang-uml
t00007/.clang-uml
t00008/.clang-uml
t00009/.clang-uml
t00010/.clang-uml
t00011/.clang-uml
t00012/.clang-uml
t00013/.clang-uml
t00014/.clang-uml
t00015/.clang-uml
t00016/.clang-uml
t00017/.clang-uml
t00018/.clang-uml
t00019/.clang-uml
t00020/.clang-uml
t00021/.clang-uml
t00022/.clang-uml
t00023/.clang-uml
t00024/.clang-uml
t00025/.clang-uml
t00026/.clang-uml
t00027/.clang-uml
t00028/.clang-uml
t00029/.clang-uml
t00030/.clang-uml
t00031/.clang-uml
t00032/.clang-uml
t00033/.clang-uml
t00034/.clang-uml
t00035/.clang-uml
t00036/.clang-uml
t00037/.clang-uml
t00038/.clang-uml
t00039/.clang-uml
t00040/.clang-uml
t00041/.clang-uml
t00042/.clang-uml
t00043/.clang-uml
t00044/.clang-uml
t00045/.clang-uml
t00046/.clang-uml
t00047/.clang-uml
t00048/.clang-uml
t00049/.clang-uml
t00050/.clang-uml
t20001/.clang-uml
t20002/.clang-uml
t20003/.clang-uml
t20004/.clang-uml
t20005/.clang-uml
t20006/.clang-uml
t20007/.clang-uml
t20008/.clang-uml
t20009/.clang-uml
t20010/.clang-uml
t20011/.clang-uml
t20012/.clang-uml
t20013/.clang-uml
t20014/.clang-uml
t20015/.clang-uml
t20016/.clang-uml
t20017/.clang-uml
t20018/.clang-uml
t20019/.clang-uml
t20020/.clang-uml
t20021/.clang-uml
t20022/.clang-uml
t20023/.clang-uml
t20024/.clang-uml
t20025/.clang-uml
t20026/.clang-uml
t20027/.clang-uml
t20028/.clang-uml
t20029/.clang-uml
t30001/.clang-uml
t30002/.clang-uml
t30003/.clang-uml
t30004/.clang-uml
t30005/.clang-uml
t30006/.clang-uml
t30007/.clang-uml
t30008/.clang-uml
t40001/.clang-uml
t40002/.clang-uml
t40003/.clang-uml
t90000/.clang-uml
test_config_data/filters.yml
test_config_data/includes.yml
test_config_data/includes1.yml
test_config_data/includes2.yml
test_config_data/inherited.yml
test_config_data/layout.yml
test_config_data/simple.yml
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/***/Documents/GitHub/clang-uml/release
make -C release -j4
[ 29%] Built target clang-umllib
[ 29%] Building CXX object tests/CMakeFiles/test_model.dir/test_model.cc.o
[ 30%] Building CXX object tests/CMakeFiles/test_util.dir/test_util.cc.o
[ 31%] Building CXX object tests/CMakeFiles/test_decorator_parser.dir/test_decorator_parser.cc.o
[ 32%] Built target clang-uml
[ 33%] Building CXX object tests/CMakeFiles/test_config.dir/test_config.cc.o
error: unknown warning option '-Wno-aggressive-loop-optimizations' [-Werror,-Wunknown-warning-option]
make[3]: *** [tests/CMakeFiles/test_decorator_parser.dir/test_decorator_parser.cc.o] Error 1
make[2]: *** [tests/CMakeFiles/test_decorator_parser.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
error: unknown warning option '-Wno-aggressive-loop-optimizations' [-Werror,-Wunknown-warning-option]
make[3]: *** [tests/CMakeFiles/test_model.dir/test_model.cc.o] Error 1
make[2]: *** [tests/CMakeFiles/test_model.dir/all] Error 2
error: unknown warning option '-Wno-aggressive-loop-optimizations' [-Werror,-Wunknown-warning-option]
make[3]: *** [tests/CMakeFiles/test_util.dir/test_util.cc.o] Error 1
make[2]: *** [tests/CMakeFiles/test_util.dir/all] Error 2
error: unknown warning option '-Wno-aggressive-loop-optimizations' [-Werror,-Wunknown-warning-option]
make[3]: *** [tests/CMakeFiles/test_config.dir/test_config.cc.o] Error 1
make[2]: *** [tests/CMakeFiles/test_config.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [release] Error 2

Enable adding notes to class methods and members

PlantUML allows to attach notes to both methods and class members, which should be possible both through \uml comment directives as well as through configuration file in the plantuml section...

Add support for C++20 concepts

Since Clang/LLVM provides API for traversing C++20 concepts:

bool TraverseTypeConstraint(const TypeConstraint *C);
bool TraverseConceptRequirement(concepts::Requirement *R);
bool TraverseConceptTypeRequirement(concepts::TypeRequirement *R);
bool TraverseConceptExprRequirement(concepts::ExprRequirement *R);
bool TraverseConceptNestedRequirement(concepts::NestedRequirement *R);

it should be fairly straightforward to add concepts to the UML diagrams generated by clang-uml.

The question is how to best render concepts in UML, one option would be to render special class templates with stereotype <<concept>> and whose body contains all the required expressions, e.g.:

@startuml
class "Serializable<T>" as C_0
class C_0 <<concept>> {
(std::ostream& ostr, T x)
----
* {x.serialize()} noexcept;
* ostr << x;
}

class "Protocol<Serializable Msg...>" as C_1

class C_1 {
- m_messageSet : std::tuple<Msg...>
}

C_1 ..> C_0 
@enduml

Blocking build

The build of master branch from a fresh ubuntu install blocks the machine, while building variable_parser.cpp.o
I have no other message than the one below.

cmake -S . -B release
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_BUILD_TYPE=Release
-DLLVM_CONFIG_PATH=
-- Checking for fmt...
-- Checking for spdlog...
-- Checking for yaml-cpp...
-- Checking for libclang...
-- llvm-config executable found: /usr/bin/llvm-config-12
-- Using CMAKE_CXX_FLAGS: -std=c++17 -I/usr/lib/llvm-12/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-- Installing type_safe via submodule
-- Installing debug_assert via submodule
-- Installing tiny-process-library via submodule
-- Found llvm-config at /usr/bin/llvm-config-12
-- Using LLVM version 12.0.1
-- Found libclang header files at /usr/lib/llvm-12/include
-- Found libclang library at /usr/lib/llvm-12/lib/libclang.so
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- FOUND GCC STDDEF INCLUDE /usr/lib/gcc/x86_64-linux-gnu/11/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/nicolas/clang-uml/release
make -C release -j
make[1] : on entre dans le répertoire « /home/nicolas/clang-uml/release »
make[2] : on entre dans le répertoire « /home/nicolas/clang-uml/release »
make[3] : on entre dans le répertoire « /home/nicolas/clang-uml/release »
make[3] : on entre dans le répertoire « /home/nicolas/clang-uml/release »
make[3] : on quitte le répertoire « /home/nicolas/clang-uml/release »
make[3] : on quitte le répertoire « /home/nicolas/clang-uml/release »
[ 1%] Built target _cppast_tiny_process
make[3] : on entre dans le répertoire « /home/nicolas/clang-uml/release »
[ 2%] Building CXX object CMakeFiles/clang-umllib.dir/src/class_diagram/model/class.cc.o
make[3] : on entre dans le répertoire « /home/nicolas/clang-uml/release »
[ 3%] Building CXX object CMakeFiles/clang-umllib.dir/src/class_diagram/generators/plantuml/class_diagram_generator.cc.o
[ 4%] Building CXX object CMakeFiles/clang-umllib.dir/src/class_diagram/model/class_member.cc.o
[ 4%] Building CXX object CMakeFiles/clang-umllib.dir/src/class_diagram/model/class_method.cc.o
[ 4%] Building CXX object CMakeFiles/clang-umllib.dir/src/class_diagram/model/diagram.cc.o
[ 4%] Building CXX object CMakeFiles/clang-umllib.dir/src/class_diagram/model/class_element.cc.o
[ 5%] Building CXX object CMakeFiles/clang-umllib.dir/src/class_diagram/model/class_template.cc.o
make[3] : on quitte le répertoire « /home/nicolas/clang-uml/release »
[ 6%] Building CXX object CMakeFiles/clang-umllib.dir/src/class_diagram/model/enum.cc.o
[ 6%] Building CXX object CMakeFiles/clang-umllib.dir/src/class_diagram/model/method_parameter.cc.o
[ 6%] Building CXX object CMakeFiles/clang-umllib.dir/src/class_diagram/visitor/translation_unit_context.cc.o
make[3] : on entre dans le répertoire « /home/nicolas/clang-uml/release »
[ 7%] Building CXX object CMakeFiles/clang-umllib.dir/src/class_diagram/visitor/element_visitor_context.cc.o
[ 8%] Building CXX object CMakeFiles/clang-umllib.dir/src/class_diagram/visitor/translation_unit_visitor.cc.o
[ 8%] Building CXX object CMakeFiles/clang-umllib.dir/src/common/generators/plantuml/generator.cc.o
[ 8%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_alias_template.cpp.o
[ 9%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/code_generator.cpp.o
[ 10%] Building CXX object CMakeFiles/clang-umllib.dir/src/common/model/decorated_element.cc.o
[ 11%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_attribute.cpp.o
[ 11%] Building CXX object CMakeFiles/clang-umllib.dir/src/common/model/diagram_element.cc.o
[ 12%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_class_template.cpp.o
[ 13%] Building CXX object CMakeFiles/clang-umllib.dir/src/common/model/diagram.cc.o
[ 13%] Building CXX object CMakeFiles/clang-umllib.dir/src/common/model/element.cc.o
[ 14%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_entity.cpp.o
[ 15%] Building CXX object CMakeFiles/clang-umllib.dir/src/common/model/diagram_filter.cc.o
[ 15%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_class.cpp.o
[ 15%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_entity_index.cpp.o
[ 15%] Building CXX object CMakeFiles/clang-umllib.dir/src/common/model/package.cc.o
[ 15%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_enum.cpp.o
[ 16%] Building CXX object CMakeFiles/clang-umllib.dir/src/common/model/namespace.cc.o
[ 17%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_expression.cpp.o
[ 18%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_file.cpp.o
[ 19%] Building CXX object CMakeFiles/clang-umllib.dir/src/common/model/relationship.cc.o
[ 19%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_function.cpp.o
[ 19%] Building CXX object CMakeFiles/clang-umllib.dir/src/config/config.cc.o
[ 19%] Building CXX object CMakeFiles/clang-umllib.dir/src/common/model/source_file.cc.o
[ 19%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_forward_declarable.cpp.o
[ 20%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_friend.cpp.o
[ 21%] Building CXX object CMakeFiles/clang-umllib.dir/src/cx/util.cc.o
[ 21%] Building CXX object CMakeFiles/clang-umllib.dir/src/decorators/decorators.cc.o
[ 22%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_language_linkage.cpp.o
[ 23%] Building CXX object CMakeFiles/clang-umllib.dir/src/include_diagram/generators/plantuml/include_diagram_generator.cc.o
[ 24%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_function_template.cpp.o
[ 25%] Building CXX object CMakeFiles/clang-umllib.dir/src/include_diagram/model/diagram.cc.o
[ 25%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_member_function.cpp.o
[ 26%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_member_variable.cpp.o
[ 27%] Building CXX object CMakeFiles/clang-umllib.dir/src/include_diagram/visitor/element_visitor_context.cc.o
[ 27%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_namespace.cpp.o
[ 28%] Building CXX object CMakeFiles/clang-umllib.dir/src/include_diagram/visitor/translation_unit_visitor.cc.o
[ 28%] Building CXX object CMakeFiles/clang-umllib.dir/src/include_diagram/visitor/translation_unit_context.cc.o
[ 28%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_template_parameter.cpp.o
[ 29%] Building CXX object CMakeFiles/clang-umllib.dir/src/package_diagram/generators/plantuml/package_diagram_generator.cc.o
[ 30%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_static_assert.cpp.o
[ 31%] Building CXX object CMakeFiles/clang-umllib.dir/src/package_diagram/model/diagram.cc.o
[ 32%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_preprocessor.cpp.o
[ 32%] Building CXX object CMakeFiles/clang-umllib.dir/src/package_diagram/visitor/translation_unit_context.cc.o
[ 32%] Building CXX object CMakeFiles/clang-umllib.dir/src/package_diagram/visitor/element_visitor_context.cc.o
[ 32%] Building CXX object CMakeFiles/clang-umllib.dir/src/package_diagram/visitor/translation_unit_visitor.cc.o
[ 33%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_token.cpp.o
[ 34%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_type_alias.cpp.o
[ 34%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_type.cpp.o
[ 35%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_variable.cpp.o
[ 35%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/cpp_variable_template.cpp.o
[ 36%] Building CXX object CMakeFiles/clang-umllib.dir/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc.o
[ 37%] Building CXX object CMakeFiles/clang-umllib.dir/src/sequence_diagram/model/diagram.cc.o
[ 37%] Building CXX object CMakeFiles/clang-umllib.dir/src/sequence_diagram/visitor/translation_unit_context.cc.o
[ 38%] Building CXX object CMakeFiles/clang-umllib.dir/src/sequence_diagram/visitor/translation_unit_visitor.cc.o
[ 39%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/diagnostic_logger.cpp.o
[ 39%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/visitor.cpp.o
[ 40%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/cxtokenizer.cpp.o
[ 41%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/class_parser.cpp.o
[ 42%] Building CXX object CMakeFiles/clang-umllib.dir/src/util/util.cc.o
[ 42%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/debug_helper.cpp.o
[ 42%] Building CXX object CMakeFiles/clang-umllib.dir/src/util/thread_pool_executor.cc.o
[ 42%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/expression_parser.cpp.o
[ 43%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/friend_parser.cpp.o
[ 43%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/function_parser.cpp.o
[ 44%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/enum_parser.cpp.o
[ 45%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/libclang_parser.cpp.o
[ 46%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/language_linkage_parser.cpp.o
[ 47%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/parse_functions.cpp.o
[ 47%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/namespace_parser.cpp.o
[ 47%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/preprocessor.cpp.o
[ 48%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/type_parser.cpp.o
[ 49%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/template_parser.cpp.o
[ 49%] Building CXX object thirdparty/cppast/src/CMakeFiles/cppast.dir/libclang/variable_parser.cpp.o

Plans to support C++20?

This is a really useful tool and we would like to use it on some of our codebases, but many of them are based on C++20. Are there plans to support this in the future?

Several enhancement suggestions

Hi Bartek,

I've been really impressed with this repository, great work! I think this can be really useful and timesaving.

I have used it on an existing codebase, and ran into a few improvements that might make things even better:

  • When providing both the -c,--config and the -d,--compile-database options, the value for the latter is ignored, i.e. the value from the config file is always used, and if it's not specified in the config file, the value '.' is used. Perhaps this can be improved by always overriding the compile-database when it is provided on the command line.
  • The glob path seems currently to be relative to the current working dir, I would expect it to be relative to the .clang-uml config file (but this may actually be by design).
  • I'm currently adding .clang-uml files per project subfolder. All these .clang-uml files are very similar, in that they try to achieve a class diagram for all classes in the namespace corresponding to that subfolder, with the context limited to all classes within. This is somewhat tedious, as it requires repeating the names of the classes, etc. Would it be an option to add a possibiity to generate diagrams per subfolder, with the option to specify more general options (such as limit the context to classes found within that subfolder, or generate a class diagram per class with context set to that class and limited to that namespace). I haven't figured out yet what the other options need to be, but I can probably elaborate at a later stage.

Thanks,
Kind regards,

Bram Veldhoen

Skip redundant dependency relationships

Currently, dependency relationships are always rendered, even if a more specific relationships already exists between the 2 classes (e.g. containment or extension), which can be due to for instance a dependency to a method parameter.

There should be an option in the class diagram config (with default true value), which will remove such dependencies from the diagram, e.g.:

skip_redundant_dependencies: true

Can't find relationships between files

test.h:

namespace test1 {

template <typename T>
class TestBase {
public:
  TestBase() = delete;
  ~TestBase() = default;
  TestBase(int a_, float b_, T c_) : a(a_), b(b_), c(c_) {};
  int a;
  float b;
  T c;
};

}

test.cc:

#include <test.h>

namespace test1 {

template class TestBase<double *>;

class TestDerive : public TestBase<double *> {
public:
  TestDerive(int a_, float b_, double *c_);
};

TestDerive::TestDerive(int a_, float b_, double *c_) : TestBase<double *>(a_, b_, c_) {
  a += 1;
  b -= 1;
}

}

result test.puml:

@startuml
class "test1::TestBase<double*>" as C_0000000002
class C_0000000002 {
}
class "test1::TestDerive" as C_0000000011
class C_0000000011 {
{static} +TestDerive(int a_, float b_, double* c_) : void
}
class "test1::TestBase<T>" as C_0000000016
class C_0000000016 {
{static} +TestBase() : void
{static} +~TestBase() : void
{static} +TestBase(int a_, float b_, T c_) : void
+a : int
+b : float
+c : T
}
C_0000000002 <|-- C_0000000011
@enduml

rendered pic:
image

Header file stddef.h not found

Hi, I have a simple test case that fails, giving the following output:

[info] [tid 114423] [main.cc:104] Loaded clang-uml config from .clang-uml
[info] [tid 114423] [main.cc:106] Loading compilation database from . directory
[info] [tid 114434] [generator.h:373] Generating diagram test.puml
In file included from /workspaces/test/source.cpp:1:
In file included from /workspaces/test/header.h:4:
/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found
#include <stddef.h>
         ^~~~~~~~~~
1 error generated.
Error while processing /workspaces/test/source.cpp.
[error] [tid 114434] [main.cc:189] Diagram test generation failed

Test case:

test@cba5038ac203:/workspaces/test$ cat header.h 
#include <stdio.h>
test@cba5038ac203:/workspaces/test$ cat source.cpp 
#include "header.h"
test@cba5038ac203:/workspaces/test$ cat compile_commands.json 
[
    {
        "directory": "/workspaces/test/",
        "command": "/usr/bin/g++ -o source.cpp.o -c /workspaces/test/source.cpp",
        "file": "/workspaces/test/source.cpp"
    }
]
test@cba5038ac203:/workspaces/test$ cat .clang-uml
compilation_database_dir: .
output_directory: ./uml-diagrams
diagrams:
  test:
    type: class
    glob:
      - source.cpp
    using_namespace:
      - myproject
    include:
      namespaces:
        - myproject
    plantuml:
      after:
        - 'note left of {{ alias("MyProjectMain") }}: Main class of myproject library.'

I'm using the latest package at ppa:bkryza/clang-uml:

clang-uml 0.2.2
Copyright (C) 2021-2022 Bartek Kryza <[email protected]>
Built with LLVM version: 14.0.0
Using LLVM version: Ubuntu clang version 14.0.0-1ubuntu1

Distro is Ubuntu 22.04.1 and I have Clang 12 installed if that's relevant.

Refactor generation of types aliases and alias templates

Currently, type aliases are generated as separate class nodes (but not always), which is confusing. Furthermore, for alias templates not all instantiations are generated. For instance:

template <class T> using AVectorPtr = std::unique_ptr<A<double,T>>;

AVectorPtr<bool> a;

should generate:

A<double,bool>

as a separate class template node.

Add row and column layout hints

Sometimes it's useful to group elements in the diagram in rows or columns. This can be easily implemented by adding row and column layout hints. In PlantUML they can be rendered using left or down hidden links.

Config could look like:

layout:
  A: 
    - row: [AA, AAA] # A, AA and AAA should be in the same row
  B:
    - row: [BBB, BBB]
  C:
    - column: [CCC, CCC] # C, CC and CCC should be in the same column

Warnings (as errors) when building clang-uml with clang 14

These errors fails the build:

[ 67%] Building CXX object tests/CMakeFiles/test_cases.dir/t00007/t00007.cc.o
/mnt/c/Users/mattar/source/repos/geodatamod/clang-uml-master/tests/t00003/t00003.cc:52:9: error: private field 'a' is not used [-Werror,-Wunused-private-field]
    int a, b, c;
        ^
/mnt/c/Users/mattar/source/repos/geodatamod/clang-uml-master/tests/t00003/t00003.cc:52:12: error: private field 'b' is not used [-Werror,-Wunused-private-field]
    int a, b, c;
           ^
/mnt/c/Users/mattar/source/repos/geodatamod/clang-uml-master/tests/t00003/t00003.cc:52:15: error: private field 'c' is not used [-Werror,-Wunused-private-field]
    int a, b, c;
              ^
3 errors generated.
make[3]: *** [tests/CMakeFiles/test_cases.dir/build.make:104: tests/CMakeFiles/test_cases.dir/t00003/t00003.cc.o] Error 1

Add customizable Jinja `context` configuration option

For configuration files with large number of diagrams which rely on Jinja templates, it would be useful to add context option to the inheritable config option set, which would enable for instance the following use case:

...
context:
  author: bkryza
  copyright: Copyright (C) 2023
  my_condition_1: true
...
diagrams:
  my_class_diagram:
    type: class
    ...
    plantuml:
      after:
        - >
          note left of {{ alias("ClassA") }}
             {{ author }} {{ copyright }}
          end note
        - >
          {% if my_condition_1 %}
          note left of {{ alias("ClassB") }}
             {{ author }} {{ copyright }}
          end note
          {% endif %}

There should be also a command line option to override/add any context variable, e.g.:

clang-uml -n my_class_diagram --context "my_condition_1: false"

Fix t20003 and t20005 on MSVC

Currently sequence diagram test cases involving non-specialized templates fail due to the fact that VisitCallExpr() is not called in translation_unit_visitor for some reason...

Fix lambda naming in class diagrams

Currently in class diagrams when a class has template instantiated with a lambda, the type name is taken from Clang as-is, and contains a full path to the source file where the lambda is defined.

Optimally, this case should be handled by the make_lambda_name method from sequence diagram visitor and changed to relative with respect to configurations relative_to property...

Add customizable element sorting in the model

Currently the order in which the elements are generated in the PlantUML file is unspecified, depending typically on the order in which they are visited.

This leads to suboptimal diagram layouts, for instance where the nodes with no outgoing relationships are at the bottom of the diagram.

The sorting could be added as a strategy to the diagram model, and configurable in the config file.

Add config file schema validation

Currently configuration files are not validated for correcteness, for instance a typo such as:

  exclude:
    namespace:
       - std 

instead of:

  exclude:
    namespaces:
       - std 

will not produce any error but simply not apply the exclusion filter...

Add option to print all possible `start_from` values for a given diagram

At the moment it is very inconvenient to determine the exact start_from value to determine method or function which should be the entry point to a sequence diagram. In all but trivial cases, it is necessary to first generate the diagram with full log verbosity and then find the method signature (as rendered by clang-uml).

There should be a cli option enabling printing of all valid start_from function and method signatures (i.e. those which matched all filters) on the output...

The invocation could look like:

clang-uml -n my_sequence_diagram --print-start-from

...
clanguml::sequence_diagram::visitor::translation_unit_visitor::VisitCXXRecordDecl(clang::CXXRecordDecl *)
...

The output preferably should contain only the function signatures, one per line to enable easy filtering using grep.

Improve rendering of template methods in class diagrams

Currently template methods type parameters are not denoted in any way that they are template parameters, this should be somehow noted, at least by prefixing template methods with e.g. template <Func,Args...> call(Func &&,Args... &&)

clang-uml does not handle types in the root namespace correctly

Example:

I have a class MyPos in the root namespace, and a class MyPos3D (and MyPos2D) that inherits (publicly) from MyPos. However, clang-uml skips the inheritance because it does not understand that ::MyPos is identical to MyPos in this case.

If I enclose the class definitions in namespace test, it does work as expected (it would require synthetically modifying hundreds of source files, however).

please tell me if you need more verbose logs

[debug] [tid 12621] [translation_unit_visitor.cc:415] Setting user data for class MyPos, 0x7f188d660260
[debug] [tid 12621] [diagram.cc:117] Adding class: ::MyPos, MyPos
[debug] [tid 12621] [nested_trait.h:63] Adding nested element MyPos at path ''
[debug] [tid 12621] [nested_trait.h:83] Getting nested element at path: MyPos
[debug] [tid 12621] [translation_unit_visitor.cc:138] ========== Visiting 'MyPos' - class

...

[debug] [tid 12621] [translation_unit_visitor.cc:619] Found base class ::MyPos for class MyPos3D
[debug] [tid 12621] [translation_unit_visitor.cc:415] Setting user data for class MyPos3D, 0x7f188c303da0
[debug] [tid 12621] [diagram.cc:117] Adding class: ::MyPos3D, MyPos3D
[debug] [tid 12621] [diagram.cc:149] Class MyPos3D (MyPos3D) already in the model

...

[debug] [tid 12621] [diagram.cc:199] Looking for alias for ::MyPos
[debug] [tid 12621] [class_diagram_generator.cc:326] === Skipping inheritance relation from ::MyPos to MyPos3D due to: Missing alias for ::MyPos

Receiving error "No parent element found at: (anonymous)"

While creating a class diagram, the above error is logged to the output. No puml file is generated.

See the last few lines of the verbose log output below:

[debug] [tid 621384] [nested_trait.h:61] Adding nested element Supported at path '(anonymous)'
[debug] [tid 621384] [nested_trait.h:81] Nested element (anonymous) not found in element
[2023-01-08 20:05:53.518] [info] No parent element found at: (anonymous)
[error] [tid 621384] [main.cc:405] No parent element found for (anonymous)

The logs elsewhere in the logfile did not provide any clues. Do you have an indication where I might start looking, or how I could change the config file in order to make this succeed?

Thanks!

clang-uml fails to parse code for an arm target

Hello,

I'm having a large embedded project build upon mbed (https://os.mbed.com/).
I wish I could use clang-uml to reverse some (if not all) parts of it to better understand it.

The project uses the dedicated mbed build system and gcc as its compiler. With the help of bear I've successfully made a compile_commands.json which seems fine (the clangd extension for vscode use it successfully, as well as codechecker (https://github.com/Ericsson/codechecker) that uses clang static-analyzer and Clang Tidy)).

When I try to run clang-uml over my project it exits very early with this error (many times)

.././mbed-os/targets/TARGET_STM/TARGET_STM32L4/STM32Cube_FW/STM32L4xx_HAL_Driver/stm32l4xx_ll_adc.h:6386:31: error: cast from pointer to smaller type 'uint32_t' (aka 'unsigned int') loses information
  const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS));
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.././mbed-os/targets/TARGET_STM/TARGET_STM32L4/STM32Cube_FW/STM32L4xx_HAL_Driver/stm32l4xx_ll_adc.h:378:34: note: expanded from macro '__ADC_PTR_REG_OFFSET'
  ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2UL))))
                                 ^~~~~~~~~~~~~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
Erreur de segmentation (core dumped)

As the code is cross-compiled this should not be an issue.
As other clang based tools do not report this problem, I suppose that at some point clang-uml lost an information that make it fail.

Would you please help me? (either fix or disable the check would be ok)

Compilation failed: clang-c/CXCompilationDatabase.h: No such file or directory

When I go and compile the program, I get the following error:
uml/src/class_diagram/visitor/translation_unit_context.cc:21:
/home/yeusepe/Documents/AutoC++/clang-uml/src/cx/util.h:22:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
22 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:238: CMakeFiles/clang-umllib.dir/src/class_diagram/visitor/translation_unit_context.cc.o] Error 1
make[3]: *** Waiting for unfinished jobs....
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/cx/util.cc:19:
/home/yeusepe/Documents/AutoC++/clang-uml/src/cx/util.h:22:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
22 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:446: CMakeFiles/clang-umllib.dir/src/cx/util.cc.o] Error 1
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/model/diagram_filter.h:26,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/model/diagram_filter.cc:19:
/home/yeusepe/Documents/AutoC++/clang-uml/src/cx/util.h:22:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
22 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:316: CMakeFiles/clang-umllib.dir/src/common/model/diagram_filter.cc.o] Error 1
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/class_diagram/visitor/translation_unit_visitor.cc:19:
/home/yeusepe/Documents/AutoC++/clang-uml/src/class_diagram/visitor/translation_unit_visitor.h:24:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
24 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/model/diagram_filter.h:26,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/generators/plantuml/generator.h:20,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/include_diagram/generators/plantuml/include_diagram_generator.h:20,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/include_diagram/generators/plantuml/include_diagram_generator.cc:19:
/home/yeusepe/Documents/AutoC++/clang-uml/src/cx/util.h:22:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
22 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:251: CMakeFiles/clang-umllib.dir/src/class_diagram/visitor/translation_unit_visitor.cc.o] Error 1
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:472: CMakeFiles/clang-umllib.dir/src/include_diagram/generators/plantuml/include_diagram_generator.cc.o] Error 1
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/model/diagram_filter.h:26,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/generators/plantuml/generator.h:20,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/generators/plantuml/generator.cc:18:
/home/yeusepe/Documents/AutoC++/clang-uml/src/cx/util.h:22:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
22 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:264: CMakeFiles/clang-umllib.dir/src/common/generators/plantuml/generator.cc.o] Error 1
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/class_diagram/generators/plantuml/class_diagram_generator.h:23,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/class_diagram/generators/plantuml/class_diagram_generator.cc:19:
/home/yeusepe/Documents/AutoC++/clang-uml/src/class_diagram/visitor/translation_unit_visitor.h:24:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
24 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:82: CMakeFiles/clang-umllib.dir/src/class_diagram/generators/plantuml/class_diagram_generator.cc.o] Error 1
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/model/diagram_filter.h:26,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/generators/plantuml/generator.h:20,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/package_diagram/generators/plantuml/package_diagram_generator.h:20,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/package_diagram/generators/plantuml/package_diagram_generator.cc:19:
/home/yeusepe/Documents/AutoC++/clang-uml/src/cx/util.h:22:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
22 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:537: CMakeFiles/clang-umllib.dir/src/package_diagram/generators/plantuml/package_diagram_generator.cc.o] Error 1
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/model/diagram_filter.h:26,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/model/diagram.cc:21:
/home/yeusepe/Documents/AutoC++/clang-uml/src/cx/util.h:22:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
22 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:290: CMakeFiles/clang-umllib.dir/src/common/model/diagram.cc.o] Error 1
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/include_diagram/visitor/translation_unit_context.cc:21:
/home/yeusepe/Documents/AutoC++/clang-uml/src/cx/util.h:22:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
22 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
/home/yeusepe/Documents/AutoC++/clang-uml/src/sequence_diagram/visitor/translation_unit_context.cc:21:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
21 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:511: CMakeFiles/clang-umllib.dir/src/include_diagram/visitor/translation_unit_context.cc.o] Error 1
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:654: CMakeFiles/clang-umllib.dir/src/sequence_diagram/visitor/translation_unit_context.cc.o] Error 1
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/model/diagram_filter.h:26,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/common/generators/plantuml/generator.h:20,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.h:20,
from /home/yeusepe/Documents/AutoC++/clang-uml/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc:19:
/home/yeusepe/Documents/AutoC++/clang-uml/src/cx/util.h:22:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
22 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:602: CMakeFiles/clang-umllib.dir/src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc.o] Error 1
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/sequence_diagram/visitor/translation_unit_visitor.cc:22:
/home/yeusepe/Documents/AutoC++/clang-uml/src/cx/util.h:22:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
22 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:667: CMakeFiles/clang-umllib.dir/src/sequence_diagram/visitor/translation_unit_visitor.cc.o] Error 1
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/package_diagram/visitor/translation_unit_visitor.cc:19:
/home/yeusepe/Documents/AutoC++/clang-uml/src/package_diagram/visitor/translation_unit_visitor.h:24:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
24 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:589: CMakeFiles/clang-umllib.dir/src/package_diagram/visitor/translation_unit_visitor.cc.o] Error 1
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/package_diagram/visitor/translation_unit_context.cc:21:
/home/yeusepe/Documents/AutoC++/clang-uml/src/cx/util.h:22:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
22 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:576: CMakeFiles/clang-umllib.dir/src/package_diagram/visitor/translation_unit_context.cc.o] Error 1
In file included from /home/yeusepe/Documents/AutoC++/clang-uml/src/include_diagram/visitor/translation_unit_visitor.cc:19:
/home/yeusepe/Documents/AutoC++/clang-uml/src/include_diagram/visitor/translation_unit_visitor.h:26:10: fatal error: clang-c/CXCompilationDatabase.h: No such file or directory
26 | #include <clang-c/CXCompilationDatabase.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/clang-umllib.dir/build.make:524: CMakeFiles/clang-umllib.dir/src/include_diagram/visitor/translation_unit_visitor.cc.o] Error 1
make[3]: Leaving directory '/home/yeusepe/Documents/AutoC++/clang-uml/release'
make[2]: *** [CMakeFiles/Makefile2:238: CMakeFiles/clang-umllib.dir/all] Error 2
make[2]: Leaving directory '/home/yeusepe/Documents/AutoC++/clang-uml/release'
make[1]: *** [Makefile:160: all] Error 2
make[1]: Leaving directory '/home/yeusepe/Documents/AutoC++/clang-uml/release'
make: *** [Makefile:50: release] Error 2

Fix handling of multiline notes generated from comments

Currently multiline notes extracted from code comments are not rendered properly and cause PlantUML errors. Notes generated from code comments should have the form, e.g.:

note left of C_0000156632990802225029
Some
                long
                              comment.
end note

also the A(ns1::ns2::class1) should accept full paths, in order to ensure unambiguous element access.

Add inja function to get elements comment

Add inja function allowing to extract comment from class or template and use it somewhere in the diagram (e.g. to create a note next to a class):

    plantuml:
      after:
        - 'note left of {{ alias("MyProjectMain") }}: {{ comment("MyProjectMain") }}.'

Consider adding XMI output support

An interesting option would be direct generation of UML diagrams in XML XMI format, for interoperability with several GUI UML tools.

PlantUML currently has a beta feature for generating XMI files from it's own format (only for class diagrams), however we could have more control here when generating XMI directly from clang-uml...

Refactor from libclang to clang libtooling

The current code visitors are based on libclang, which seems to have several limitations:

  • parser breaks on more complex code
  • not possible to traverse call expression chain with template functions and methods
  • incomplete information on template type arguments
  • no support for C++ features beyond C++17

Add support for 'together' layout of classes

Extend layout configuration parameter with support for together PlantUML directive, which allows enumeration of elements which should be rendered close to each other with respect to other diagram elements...

Segmentation fault when run on some sources

Built the version from master as of today. When run on rlottie's repository with this .clang-uml I get a segmentation fault and no puml file is generated.

compilation_database_dir: . 
output_directory: puml 
diagrams: 
  rlottie_class: 
    type: class 
    glob: 
      - ../rlottie/inc/*.h 
      - ../rlottie/src/lottie/*.h 
      - ../rlottie/src/vector/*.cpp 
      - ../rlottie/src/vector/*.h 
    using_namespace: 
      - rlottie 
    include: 
      namespaces: 
        - rlottie 
        - rlottie::internal
#    exclude:
#       namespaces:
#         - std
    plantuml:
      before:
        - 'title clang-uml class diagram model'

The cmake build line is: mkdir build && cd build && cmake ../rlottie/ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

Fix alt blocks in multiple if/else blocks

Currently the translation_unit_visitor for sequence diagram generates nested alt block for each if/else statement in if block. Optimally there should only be a single alt block with a separate lane for each condition.

Example of this can be seen in the main_sequence diagram in clang-uml's diagrams...

Add support for separators in class diagrams

Currently methods and fields in classes are rendered in diagrams in no particular order.

Preferably they should be ordered based on their access, sorted by name and also:

  • Constructors first
  • operator overloads
  • other methods

Public, protected and private methods should be separated using dotted separators:

@startuml
class Foo1 {
  Foo()
  Foo(Foo&&)
  ..
  operator=()
  operator+=()
  ..
  do_sth()
}
@enduml

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.