clang_isDynamicCall always returns true for CallExpr which call virtual methods

Hi,

Just resending. If I am asking this question on the wrong mailing list, please le me know.

Thanks,

Matt

I guess that clang_isDynamicCall is not concerned with function calls that can be de-virtualised through optimisation (albeit fairly trivial optimisation).

I’m interested to know how you could, in general, find out when a method will be called polymorphically but would guess that it’s very hard as cross-translation unit optimisation (WPO) would have an effect. Clang’s AST won’t have access ot the info needed to determine this (as far as I know).

Please keep me posted on progress!

Jon

I don’t think this has anything to do with optimization. If the type of the member expression base is completely known, it isn’t a dynamic call.

It seems that function (clang_Cursor_isDynamicCall is the one I found?) ends up calling MemberExpr->performsVirtualDispatch, which only considers AppleKext and full qualification.

I also note that the uses of performsVirtualDispatch calls getDevirutalizedMethod (https://clang.llvm.org/doxygen/DeclCXX_8cpp_source.html#l02107).

I presume “isDynamicCall” (or some similar function) should be checking whether it can be devirtualized like this before deciding it is a dynamic call.