codeql icon indicating copy to clipboard operation
codeql copied to clipboard

[cpp] Check whether path between function A and function B exists

Open noobdoesre opened this issue 5 months ago • 2 comments
trafficstars

Hi! I'm trying to write a query that checks whether function A can call (directly or transitively) function B. I've implemented it with recursive predicate that uses Function.calls. It works, but is slow. I suspect DataFlow API can be handy but couldn't produce working query yet. I'm dealing with fairly simple cpp code that doesn't use virtual functions, doesn't use pointer arithmetic, so DataFlow might be a bit too excessive for my task. I wonder what is the most efficient way to solve this problem. Thanks!

noobdoesre avatar Jun 20 '25 12:06 noobdoesre

If you are computing this for all functions, it may indeed be expensive to compute. Is it possible to restrict the set of relevant source/sink functions in your case?

hvitved avatar Jun 20 '25 12:06 hvitved

Yes, I'm testing by literally checking whether there is a path from one unique function to another unique function. They are one function call apart (A -> X -> B). It takes recursive query around 20 seconds to finish

noobdoesre avatar Jun 20 '25 13:06 noobdoesre