Take the following example:
class Int {
public:
Int(int n = 0): num(n) {}
Int(const Int& rhs): num(rhs.num) {}
Int& operator=(const Int& rhs) { num = rhs.num; }
operator int() { return num; }
private:
int num;
};
Int h(Int n) {
return n;
}
Int f(Int n) {
Int i;
i = h(n);
return i;
}
Int g(Int n) {
Int i = h(n);
return i;
}The call graph for this C++ compilation unit will omit the edge from f to h, but not from g to h. This is obviously an error. The reason is that when visiting the statements to build the call graph all call expressions are handled as leafs. In the example above f calls operator=, which is a call expression, but it also has a child call expression, a call to function h. However, this latter edge is not visited because operator= is handled as leaf and its child call expression is not visited.