Automatically create flowcharts from C ++ code

I need to automatically create flowcharts from C ++ code, ideally a single flowchart for the source file. Is there any tool (preferably C ++ / Python with both open source or highly configurable ), so I can change the look) that I can use to create flowcharts?

http://www.faqs.org/patents/img/20110088010_08.png

+5
source share
3 answers

clang/llvm can generate graphic dot files .

Example:

 clang -S -emit-llvm -o hello.ll hello.cpp opt hello.ll -dot-cfg -o hello.dot 

This will produce multiple .dot files, one for each function defined in hello.cpp . You can also generate a dominance graph, a post-dominance graph, etc. (See here ).

Once you have the .dot files, you can use dot to convert it to a .png file. The .dot file itself contains only the graph structure, so the dot output should be very customizable (but I am not very familiar with it).

+3
source

Use the Enterprise Architect tool.

http://www.sparxsystems.com/enterprise_architect_user_guide/9.2/execution_analyzer/generating_sequence_diagram.html

You can generate a sequence diagram when debugging code.

Demo: Online Demo

Note. - It also works with C ++ code. Just use your own debugger.

+2
source

If you are not opposed to plain text output, cflow will do the job. This is in the repositories of at least Debian, and possibly most Linux distributions.

0
source

Source: https://habr.com/ru/post/1208405/


All Articles