[cfe-users] Generating a call graph diagram

Daniel Mosesson dmosess1 at binghamton.edu
Tue Jan 21 23:13:23 PST 2014


I am looking for a way to use clang to generate a graph of what functions
call each other in some kind of standard format (like dot).

There are primarily two capabilities that I am looking for:
1) Only  include types/functions that are in a particular namespace or
namespaces
2) Consolidate all calls that are made to different instantiations of the
same template (so that tuple constructions show up as simply tuple, and not
tuple<int>,tuple<int,int>, ect)

Is this possible in clang?

I know that I can use
$ clang++ -S -emit-llvm main1.cpp -o - | opt -analyze -std-link-opts
-dot-callgraph
$ cat callgraph.dot | c++filt | 
  sed 's,>,\\>,g; s,-\\>,->,g; s,<,\\<,g' | 
  gawk '/external node/{id=$1} $1 != id' | 
  dot -Tpng -ocallgraph.png  

to get a diagram that shows a function graph, but as far as I can tell, this
is capable only of doing one cpp file, and there is no way to get the two
capabilities that I am looking for above.

Is there a standard way to do this?

Thank you
Daniel Mosesson




More information about the cfe-users mailing list