Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

test(c-lsp): regression for #220 (C++ CALLS attributed to function)

Martin Vogel48a9b2c2a9dc
diff --git a/tests/test_c_lsp.c b/tests/test_c_lsp.c
index 4c9c06885..48c368fb5 100644
--- a/tests/test_c_lsp.c
+++ b/tests/test_c_lsp.c
@@ -583,6 +583,22 @@ TEST(clsp_nocrash_template_function_multi_param_nested_call) {
PASS();
}
+/* Issue #220: C++ CALLS edges were attributed to the Module (file) node
+ * instead of the enclosing Function/Method, breaking function-level
+ * trace_path. The resolved call's caller_qn must be the enclosing function. */
+TEST(clsp_calls_attributed_to_function_issue220) {
+ CBMFileResult *r = extract_cpp("void helper() {}\n"
+ "void doWork() {\n"
+ " helper();\n"
+ "}\n");
+ ASSERT_NOT_NULL(r);
+ int idx = find_resolved(r, "doWork", "helper");
+ ASSERT_GTE(idx, 0);
+ ASSERT_NOT_NULL(strstr(r->resolved_calls.items[idx].caller_qn, "doWork"));
+ cbm_free_result(r);
+ PASS();
+}
+
/* Issue #355: indexing segfaulted while extracting a heavily-macro'd xxhash
* C header (`dhw/xx_hash.h`). The reporter's exact file isn't available, so
* this drives the vendored xxhash.h (~7.5k lines, same macro-dense family)
@@ -15196,6 +15212,7 @@ SUITE(c_lsp) {
RUN_TEST(clsp_nocrash_template_expression);
RUN_TEST(clsp_nocrash_template_extra_call_args);
RUN_TEST(clsp_nocrash_template_function_multi_param_nested_call);
+ RUN_TEST(clsp_calls_attributed_to_function_issue220);
RUN_TEST(clsp_nocrash_issue355_xxhash_header);
RUN_TEST(clsp_nocrash_issue312_default_template_auto_param);
RUN_TEST(clsp_nocrash_lambda);