The llvm clang compiler can generate bytecode output files.
Then the opt program can generate different dot graph data of it. (It is opt-7 on debian Linux)

The manual of the opt program is here at https://llvm.org/docs/CommandGuide/opt.html
and at https://llvm.org/docs/Passes.html#dot-callgraph-print-call-graph-to-dot-file

This are the dot graph output options available;

-dot-callgraph: Print Call Graph to “dot” file

This pass, only available in opt, prints the call graph into a .dot graph. This graph can then be processed with the “dot” tool to convert it to postscript or some other suitable format.

-dot-cfg: Print CFG of function to “dot” file

This pass, only available in opt, prints the control flow graph into a .dot graph. This graph can then be processed with the dot tool to convert it to postscript or some other suitable format.

-dot-cfg-only: Print CFG of function to “dot” file (with no function bodies)

This pass, only available in opt, prints the control flow graph into a .dot graph, omitting the function bodies. This graph can then be processed with the dot tool to convert it to postscript or some other suitable format.

-dot-dom: Print dominance tree of function to “dot” file

This pass, only available in opt, prints the dominator tree into a .dot graph. This graph can then be processed with the dot tool to convert it to postscript or some other suitable format.

-dot-dom-only: Print dominance tree of function to “dot” file (with no function bodies)

This pass, only available in opt, prints the dominator tree into a .dot graph, omitting the function bodies. This graph can then be processed with the dot tool to convert it to postscript or some other suitable format.

-dot-postdom: Print postdominance tree of function to “dot” file

This pass, only available in opt, prints the post dominator tree into a .dot graph. This graph can then be processed with the dot tool to convert it to postscript or some other suitable format.

-dot-postdom-only: Print postdominance tree of function to “dot” file (with no function bodies)

This pass, only available in opt, prints the post dominator tree into a .dot graph, omitting the function bodies. This graph can then be processed with the dot tool to convert it to postscript or some other suitable format.

And these dot files can be used with gml4gtk without problems.

This is example llvm dot data with gml4gtk
llvm


And this is the generated data:


/* llvm opt generated data */
digraph "CFG for 'dp_clredges_r' function" {
    label="CFG for 'dp_clredges_r' function";

    Node0x14dc6f0 [shape=record,label="{%0|{<s0>T|<s1>F}}"];
    Node0x14dc6f0:s0 -> Node0x14dc9a0;
    Node0x14dc6f0:s1 -> Node0x14dc9f0;
    Node0x14dc9a0 [shape=record,label="{%4}"];
    Node0x14dc9a0 -> Node0x14dcc20;
    Node0x14dc9f0 [shape=record,label="{%5}"];
    Node0x14dc9f0 -> Node0x14dca40;
    Node0x14dca40 [shape=record,label="{%9|{<s0>T|<s1>F}}"];
    Node0x14dca40:s0 -> Node0x14dca90;
    Node0x14dca40:s1 -> Node0x14dcae0;
    Node0x14dca90 [shape=record,label="{%12}"];
    Node0x14dca90 -> Node0x14dca40;
    Node0x14dcae0 [shape=record,label="{%19}"];
    Node0x14dcae0 -> Node0x14dcb30;
    Node0x14dcb30 [shape=record,label="{%23|{<s0>T|<s1>F}}"];
    Node0x14dcb30:s0 -> Node0x14dcb80;
    Node0x14dcb30:s1 -> Node0x14dcbd0;
    Node0x14dcb80 [shape=record,label="{%26}"];
    Node0x14dcb80 -> Node0x14dcb30;
    Node0x14dcbd0 [shape=record,label="{%33}"];
    Node0x14dcbd0 -> Node0x14dcc20;
    Node0x14dcc20 [shape=record,label="{%38}"];
}

The scan-build command is used to check the source of gml4gtk and issues are fixed.

The journ project takes compiler data a step more putting compiler data
in searchable database for use with code checking, see  https://docs.joern.io/home

The llvm code can also used with normal C instead of c++ and example code is here in:
getting-started-with-the-newer-llvm-c-api-master.zip
nickel-master.zip

castxml can generate xml data from c++ https://github.com/CastXML/CastXML

also from gcc https://gccxml.github.io/HTML/Index.html

or plugin https://www.codesynthesis.com/~boris/blog/2010/05/03/parsing-cxx-with-gcc-plugin-part-1/

or cil https://people.eecs.berkeley.edu/~necula/cil/

or pyparser https://github.com/eliben/pycparser

That data can be used to generate graph data

or

clang-check my_c_program.c -ast-dump -- | sed -e 's/^[\[[0-9;]*m//g'

This generates an annotated C or C++ abstract syntax tree. Every identifier node has information indicating what type of identifier it is, and a cross-tree reference to the declaration site. This tool gives much more information about a C program than simply its syntax tree; it provides much information about the static semantics of the program as well. A real winner!

or gcc map files

https://pypi.org/project/fpvgcc/


programl can generate graph data and has a web interface https://github.com/ChrisCummins/ProGraML

Here is a article how to understand the clang llvm ir output
https://un-devs.github.io/low-level-exploration/journey-to-understanding-llvm-ir/#

Here is also  blog about llvm internals at
https://blog.yossarian.net/2021/07/19/LLVM-internals-part-1-bitcode-format
https://blog.yossarian.net/2021/08/10/LLVM-internals-part-2-parsing-the-bitstream

examples of high level concepts in programming langs (e.g. if/else, object methods, etc) and shows you how you might generate LLVM IR to support that feature

https://mapping-high-level-constructs-to-llvm-ir.readthedocs.io/en/latest/README.html



The tinycc compiler is GNU GPL Free and includes assembler and linker
to generate Linux or windows binaries and has windows api headers an windows versions at
With libtcc, you can use TCC as a backend for dynamic code generation
https://savannah.nongnu.org/projects/tinycc

mutation testing is another way to scan for bugs using llvm, for c, c++ at
https://mull.readthedocs.io/en/latest/GettingStarted.html

this is a list of similar tools at
https://awesomeopensource.com/projects/mutation-testing

Google has a summary on safer c++ progrmming which is technially imposible
https://docs.google.com/document/d/e/2PACX-1vRZr-HJcYmf2Y76DhewaiJOhRNpjGHCxliAQTBhFxzv1QTae9o8mhBmDl32CRIuaWZLt5kVeH9e9jXv/pub

compile simpel javascript to llvm assembly
https://github.com/wizardpisces/js-ziju

Otrher wsome compilers at
https://github.com/wizardpisces/awesome-compilers

c and c++ source code improvements ideas from intel
https://software.intel.com/content/www/us/en/develop/articles/the-ultimate-question-of-programming-refactoring-and-everything.html

undefined in c++ summary
https://github.com/shafik/cpp_undefined_behavior_enumerated

Polygeist MLIR Polyhedral Compiler for C/C++
https://polygeist.mit.edu/

there is GCC and clang and glibc and that may cause extra issues at
https://www.collabora.com/news-and-blog/blog/2021/09/30/a-tale-of-two-toolchains-and-glibc/