#1260: count calls with an exact callee whose enclosing function qn ends * with ". ". has_call() is a substring match, which cannot tell * "Pkg.A.Run" emitted from want_a apart from the same callee in want_b. */
| 3685 | * with ".<func>". has_call() is a substring match, which cannot tell |
| 3686 | * "Pkg.A.Run" emitted from want_a apart from the same callee in want_b. */ |
| 3687 | static int count_calls_in_func(CBMFileResult *r, const char *callee, const char *func) { |
| 3688 | int n = 0; |
| 3689 | size_t flen = strlen(func); |
| 3690 | for (int i = 0; i < r->calls.count; i++) { |
| 3691 | const CBMCall *c = &r->calls.items[i]; |
| 3692 | if (!c->callee_name || strcmp(c->callee_name, callee) != 0 || !c->enclosing_func_qn) { |
| 3693 | continue; |
| 3694 | } |
| 3695 | size_t qlen = strlen(c->enclosing_func_qn); |
| 3696 | if (qlen > flen && c->enclosing_func_qn[qlen - flen - 1] == '.' && |
| 3697 | strcmp(c->enclosing_func_qn + qlen - flen, func) == 0) { |
| 3698 | n++; |
| 3699 | } |
| 3700 | } |
| 3701 | return n; |
| 3702 | } |
| 3703 | |
| 3704 | /* #1260: calls in `func` whose callee is "Run" or ends in ".Run", whatever |
| 3705 | * the qualifier. One iris.cls("X").Run() site must emit exactly one. */ |