I found this example that looks like it outputs what I want for C++. How can it be done for the Objective-C code in an Xcode project?
I see mentions of Doxygen being able to create a call graph, but I can't find an example.
(I want to get to know clang better, but it's hard to get started...)
Absolutely. There are a couple of tricks that you need to understand, but it's not too bad.
First, you need a compatible version of
opt
, since it doesn't come with the LLVM Apple ships. I got mine from macports:Then you need to compile your file. Working out the parameters can sometimes be a bit of a pain. The easiest way is to let Xcode build it, then go to the logs and cut and paste out the giant build line. I used to be able to hand-hack these, but I've gotten too lazy....
Take out the last
-o
parameter (conveniently at the end of the compile line), and substitute:Then, as in the other example:
Keep in mind that there are a few functions that get called a lot in ObjC that you almost never care about. In particular, almost anything that starts with
objc_
. Luckily the DOT format is a very simple text file, and it's pretty easy to write post-processing scripts to strip out what you don't want.There's also a
-print-callgraph
parameter that will out put this information in a slightly different format if you want to do further processing.