Serve outgoing call hierarchy
callHierarchy/outgoingCalls groups calls attributed to the prepared function's innermost enclosing definition by callee, with registered core tests for grouping, innermost attribution, unresolved-callee omission and bounds. Real stdio evidence shows the observer reports only the declarator span, so body calls cannot be attributed without guessing; the matrix records that limitation.
This commit is contained in:
1 parent
cec4e7d717
commit
a098e45dc9
9 files changed
+178
-2
No files matched your search
@@ -88,3 +88,39 @@ VOID_TEST(CallHierarchy, callers_and_ranges_are_bounded) {
|
||||
ranges += entry.from_ranges.size();
|
||||
expect(ranges == 1);
|
||||
}
|
||||
|
||||
VOID_TEST(CallHierarchy, outgoing_reports_calls_inside_the_caller) {
|
||||
const auto inner = definition("inner", "/p/a.cpp", range(1));
|
||||
const std::vector<Definition> known{definition("outer", "/p/a.cpp", {{0, 0}, {20, 0}}), inner};
|
||||
const std::vector<Call> calls{call("inner", inner, "/p/a.cpp", range(6)),
|
||||
call("inner", inner, "/p/a.cpp", range(7))};
|
||||
const auto result = outgoing(calls, known, known.front());
|
||||
require(result.size() == 1);
|
||||
expect(result.front().to == inner);
|
||||
require(result.front().from_ranges.size() == 2);
|
||||
expect(result.front().from_ranges[0] == range(6));
|
||||
}
|
||||
|
||||
VOID_TEST(CallHierarchy, outgoing_attributes_nested_calls_to_the_innermost_definition) {
|
||||
const auto inner = definition("inner", "/p/a.cpp", range(1));
|
||||
const auto nested = definition("nested", "/p/a.cpp", {{5, 0}, {9, 0}});
|
||||
const std::vector<Definition> known{definition("outer", "/p/a.cpp", {{0, 0}, {20, 0}}), nested,
|
||||
inner};
|
||||
const std::vector<Call> calls{call("inner", inner, "/p/a.cpp", range(6)),
|
||||
call("inner", inner, "/p/a.cpp", range(15))};
|
||||
const auto outer_result = outgoing(calls, known, known.front());
|
||||
require(outer_result.size() == 1);
|
||||
expect(outer_result.front().from_ranges == std::vector<Range>{range(15)});
|
||||
const auto nested_result = outgoing(calls, known, nested);
|
||||
require(nested_result.size() == 1);
|
||||
expect(nested_result.front().from_ranges == std::vector<Range>{range(6)});
|
||||
}
|
||||
|
||||
VOID_TEST(CallHierarchy, outgoing_skips_unresolved_callees_and_bounds_groups) {
|
||||
const auto inner = definition("inner", "/p/a.cpp", range(1));
|
||||
const std::vector<Definition> known{definition("outer", "/p/a.cpp", {{0, 0}, {20, 0}})};
|
||||
const std::vector<Call> calls{{"missing", std::nullopt, "/p/a.cpp", range(6)},
|
||||
call("inner", inner, "/p/a.cpp", range(7))};
|
||||
require(outgoing(calls, known, known.front()).size() == 1);
|
||||
expect(outgoing(calls, known, known.front(), Limits{.callers = 0}).empty());
|
||||
}
|
||||
Reference in new issue
Block a user