[LLVMdev] [LLVM-Clang CFG] - generating CFG of a C program and llvm iterators

Rajendra rks at cse.iitb.ac.in
Fri Sep 28 04:46:03 PDT 2012


Hi,

I want to generate Control Flow Graph (in memory CFG object) of any
given C program and then iterate over this CFG (all function, basic
blocks and instructions) using llvm iterators.

I can see text output of CFG on screen, using following command:
`clang -cc1 -Idummyh -analyze -analyzer-checker=debug.DumpCFG 
hello/hello.c'
where dummyh has en empty stdio.h to remove this error:
`fatal error: 'stdio.h' file not found'

I see CFG.h and CFG.cpp that clang uses and have seen some docs on
ModulePass, FunctionPass, BasicBlockPass, etc. But I have not figured
out how to put together things to generate CFG and then write 
iterators.

All help is much appreciated.

Thank you.

Rajendra



More information about the llvm-dev mailing list