(&mut self, node: Node<'t>)
| 2044 | } |
| 2045 | |
| 2046 | fn visit_for_calls_and_structure(&mut self, node: Node<'t>) { |
| 2047 | stack_guard!(); |
| 2048 | let kind = node.kind(); |
| 2049 | // A function-like macro defined inside a body is still a macro (#1838). |
| 2050 | if kind == "preproc_function_def" { |
| 2051 | self.visit_node(node); |
| 2052 | return; |
| 2053 | } |
| 2054 | self.maybe_capture_fn_refs(node); |
| 2055 | |
| 2056 | if kind == "call_expression" { |
| 2057 | self.extract_call(node); |
| 2058 | } else if kind == "new_expression" { |
| 2059 | self.extract_instantiation(node); |
| 2060 | } |
| 2061 | |
| 2062 | // C++ stack construction `Calculator calc(0)` / `Widget w{1,2}` (#1035), |
| 2063 | // plus one constructor ref `ns::T::T/arity` per constructed object (#1839). |
| 2064 | if kind == "declaration" && self.variant == Variant::Cpp { |
| 2065 | let (instantiates, arities) = self.cpp_stack_constructions(node); |
| 2066 | if instantiates { |
| 2067 | self.extract_instantiation(node); |
| 2068 | } |
| 2069 | if !arities.is_empty() && !self.stack.is_empty() { |
| 2070 | if let Some(type_node) = node.child_by_field_name("type") { |
| 2071 | let from = self.top_row(); |
| 2072 | let class_name = strip_cpp_template_args(self.text(type_node)); |
| 2073 | if let Some(name) = class_name.split("::").filter(|s| !s.is_empty()).last() { |
| 2074 | let calls = edge_kind_index("calls").unwrap(); |
| 2075 | for arity in arities { |
| 2076 | self.push_ref_at(from, &format!("{class_name}::{name}/{arity}"), calls, node); |
| 2077 | } |
| 2078 | } |
| 2079 | } |
| 2080 | } |
| 2081 | } |
| 2082 | |
| 2083 | // C++ local fn-pointer bindings: declarations and branch reassignments. |
| 2084 | if self.variant == Variant::Cpp && !self.stack.is_empty() { |
| 2085 | if kind == "declaration" { |
| 2086 | for i in 0..node.named_child_count() { |
| 2087 | let Some(child) = node.named_child(i) else { continue }; |
| 2088 | if child.kind() != "init_declarator" { |
| 2089 | continue; |
| 2090 | } |
| 2091 | let Some(decl) = child.child_by_field_name("declarator") else { continue }; |
| 2092 | if decl.kind() != "identifier" { |
| 2093 | continue; |
| 2094 | } |
| 2095 | let local = self.text(decl).to_string(); |
| 2096 | self.record_cpp_fn_ptr_binding(&local, child.child_by_field_name("value")); |
| 2097 | } |
| 2098 | } else if kind == "assignment_expression" { |
| 2099 | if let Some(left) = node.child_by_field_name("left") { |
| 2100 | if left.kind() == "identifier" { |
| 2101 | let local = self.text(left).to_string(); |
| 2102 | self.record_cpp_fn_ptr_binding(&local, node.child_by_field_name("right")); |
| 2103 | } |
no test coverage detected