与函数指针匹配的查询是什么,例如在以下代码中:
int foo(struct A *a, int b) { return a->x->y(b); }
y 是要匹配的函数指针。
y
最后,这是调用函数指针的答案。主要的困难是使用查询检测函数指针的类型。所以我加了 ignoringParens(functionType()) 遍历匹配器来解决这个问题。一个简单的用法 functionType() 不会起作用。
ignoringParens(functionType())
functionType()
match callExpr(hasDescendant(memberExpr(hasType(pointerType(pointee(ignoringParens(functionType()))))).bind("member")))