import cpp from FunctionCall fc where fc.getTarget().getName().matches("cancel%") select fc.getEnclosingFunction(), fc //fc.getEnclosingFunction() 获取包含该调用(cancel开头)的函数
predicate functionUsesMacro(Function f) { exists(MacroInvocation mi | mi.getMacroName() = "BUFFER_SIZE" and mi.getEnclosingFunction() = f ) }
predicate callsChain(Function callee, Function caller) { // Base case: caller calls the callee directly exists(FunctionCall fc | fc.getTarget() = callee and fc.getEnclosingFunction() = caller ) or // Recursive case: continue tracing further up the call chain exists(Function intermediate | callsChain(callee, intermediate) and exists(FunctionCall fc2 | fc2.getTarget() = intermediate and fc2.getEnclosingFunction() = caller ) ) }
from Function start, Function caller where functionUsesMacro(start)and ( caller = start or callsChain(start, caller) ) select caller, "Function in the chain."