利用C ++代码自动生成流程图 [英] Automatically generate flowcharts out of C++ code
问题描述
我需要自动使用C ++代码构造流程图,最好是每个源文件一个流程图。
是否有可用于创建流程图的工具(最好是C ++ / Python,并且开源或高度可配置-因此我可能会更改外观) ?
I need to automatically construct flowcharts out of C++ code, ideally one flowchart per source file. Is there any tool (preferably C++/Python and either open-sourced or highly configurable - so I may change the look) that I can use to create flowcharts?
推荐答案
clang / llvm
可以生成 graphviz点文件。
示例:
clang -S -emit-llvm -o hello.ll hello.cpp
opt hello.ll -dot-cfg -o hello.dot
这将输出几个 .dot
文件,每个文件在 hello.cpp
中定义。
您还可以生成优势图,发布优势图等(请参见此处)。
This will output several .dot
files, one for each function defined in hello.cpp
.
You can also generate dominance graph, post dominance graph and more (see here).
拥有 .dot $ c $后c>文件,您可以使用
dot
将其转换为 .png
文件。
.dot
文件本身仅包含图形的结构,因此 dot
的输出应为高度可配置的(但我不太熟悉)。
After you have your .dot
files you can use dot
to convert it to a .png
file.
The .dot
file itself contains only the structure of the graph, so the output of dot
should be highly configurable (but I am not really familiar with it).
这篇关于利用C ++代码自动生成流程图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!