0

Since I need to generate source-level CFG, I used CFG::buildCFG from libclang and can get the following example output:

 [B0 (EXIT)]
   Preds (2): B1 B2


 [B1]
   1: n->l->x = n->x
   2: traverse(n->l)
   3: traverse(n->r)
   4: return;
   Preds (1): B3
   Succs (1): B0


 [B2]
   1: return;
   Preds (1): B3
   Succs (1): B0


 [B3]
   T: if <null expr>
   Preds (1): B4
   Succs (2): B2 B1


 [B4 (ENTRY)]
   Succs (1): B3

But I cannot use opt to generate dot file for visible CFG.

So, how can I convert the aforementioned output to visible CFG (i.e., dot file)?

zwdong
  • 1
  • Why not generate the llvm ir or bitcode for the file and use that instead?? – droptop Nov 17 '20 at 20:09
  • Because source-level CFG could provide more semantic information for code analysis. In fact, I want to make a mapping between IR and source code, but I didn't find any options for showing the line number of source code in the IR CFG. – zwdong Nov 17 '20 at 22:23
  • checkout https://stackoverflow.com/q/54162940/8925535 – droptop Nov 18 '20 at 18:27

0 Answers0