True iff a CALLS edge exists from a node named src_name to a node named * tgt_name. Used to assert cross-file call resolution survives a reindex. */
| 1243 | /* True iff a CALLS edge exists from a node named src_name to a node named |
| 1244 | * tgt_name. Used to assert cross-file call resolution survives a reindex. */ |
| 1245 | static bool cross_file_edge_exists(cbm_store_t *s, const char *project, const char *src_name, |
| 1246 | const char *tgt_name, const char *edge_type) { |
| 1247 | cbm_node_t *srcs = NULL; |
| 1248 | cbm_node_t *tgts = NULL; |
| 1249 | int sc = 0; |
| 1250 | int tc = 0; |
| 1251 | cbm_store_find_nodes_by_name(s, project, src_name, &srcs, &sc); |
| 1252 | cbm_store_find_nodes_by_name(s, project, tgt_name, &tgts, &tc); |
| 1253 | bool found = false; |
| 1254 | for (int i = 0; i < sc && !found; i++) { |
| 1255 | cbm_edge_t *edges = NULL; |
| 1256 | int ec = 0; |
| 1257 | cbm_store_find_edges_by_source_type(s, srcs[i].id, edge_type, &edges, &ec); |
| 1258 | for (int j = 0; j < ec && !found; j++) { |
| 1259 | for (int k = 0; k < tc; k++) { |
| 1260 | if (edges[j].target_id == tgts[k].id) { |
| 1261 | found = true; |
| 1262 | break; |
| 1263 | } |
| 1264 | } |
| 1265 | } |
| 1266 | if (edges) { |
| 1267 | cbm_store_free_edges(edges, ec); |
| 1268 | } |
| 1269 | } |
| 1270 | if (srcs) { |
| 1271 | cbm_store_free_nodes(srcs, sc); |
| 1272 | } |
| 1273 | if (tgts) { |
| 1274 | cbm_store_free_nodes(tgts, tc); |
| 1275 | } |
| 1276 | return found; |
| 1277 | } |
| 1278 | |
| 1279 | static bool cross_file_call_exists(cbm_store_t *s, const char *project, const char *src_name, |
| 1280 | const char *tgt_name) { |
no test coverage detected