multilang-depends / depends

Depends is a fast, comprehensive code dependency analysis tool
MIT License
195 stars 54 forks source link

Virtual methods of C++ #3

Closed JosenJP closed 5 years ago

JosenJP commented 5 years ago

Is virtual method of C++ handled in latest version 0.9.0? case like below: class A:B virtual method Func() A l_pA1 = new B; A l_pA2 = l_pA1;

l_pA2->Func();

gangz commented 5 years ago

Depends is a syntactical relations analayzer. It does not focus on the runtime behavior. In above example, it will generate the following relations: 1, A inherit B 2, (some) create B (some) means the container which contains A* 1_PA1=new B 3, (some) use/set A 4, A calls Func

as explained above, based on the goal of depends, virtual method is no actual impact on the relation analysis.

JosenJP commented 5 years ago

Thank you for the explanation. So the point 4. A will calls A::Func, not B::Func, right? Suppose Func is a virtual method of A and B override it.

gangz commented 5 years ago

it is what I means, but I try to explain it more accurately: (Let's assume the instance of B is passed to function foo()) void foo(A* l_pA2){ l_pA2->Func(); } The result of depends is: function 'foo' calls A::Func(). No any relation with B generated. From design view, it means that foo only depends on A, it has no awareness of B, although in runtime, the actual called function is B::Func().

JosenJP commented 5 years ago

Really appreciate the detail explanation. Thank you very much.