Line data Source code
1 : // Copyright (C) 2021-2026 Free Software Foundation, Inc.
2 :
3 : // This file is part of GCC.
4 :
5 : // GCC is free software; you can redistribute it and/or modify it under
6 : // the terms of the GNU General Public License as published by the Free
7 : // Software Foundation; either version 3, or (at your option) any later
8 : // version.
9 :
10 : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 : // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 : // for more details.
14 :
15 : // You should have received a copy of the GNU General Public License
16 : // along with GCC; see the file COPYING3. If not see
17 : // <http://www.gnu.org/licenses/>.
18 :
19 : #include "rust-expr.h"
20 : #include "rust-hir-full-decls.h"
21 : #include "rust-hir-visitor.h"
22 : #include "rust-hir-full.h"
23 : #include "rust-system.h"
24 :
25 : namespace Rust {
26 : namespace HIR {
27 :
28 : void
29 5873 : DefaultHIRVisitor::walk (Lifetime &)
30 5873 : {}
31 :
32 : void
33 160 : DefaultHIRVisitor::walk (LifetimeParam &lifetime_param)
34 : {
35 160 : visit_outer_attrs (lifetime_param);
36 160 : lifetime_param.get_lifetime ().accept_vis (*this);
37 160 : for (Lifetime &lifetime_bound : lifetime_param.get_lifetime_bounds ())
38 0 : lifetime_bound.accept_vis (*this);
39 160 : }
40 :
41 : void
42 2335 : DefaultHIRVisitor::visit_generic_args (GenericArgs &generic_args)
43 : {
44 2354 : for (auto &lifetime : generic_args.get_lifetime_args ())
45 19 : lifetime.accept_vis (*this);
46 4754 : for (auto &type : generic_args.get_type_args ())
47 2419 : type->accept_vis (*this);
48 2400 : for (auto &binding : generic_args.get_binding_args ())
49 65 : binding.get_type ().accept_vis (*this);
50 2371 : for (auto &const_arg : generic_args.get_const_args ())
51 36 : const_arg.get_expression ()->accept_vis (*this);
52 2335 : }
53 :
54 : void
55 30 : DefaultHIRVisitor::walk (PathInExpression &path_in_expr)
56 : {
57 30 : visit_outer_attrs (path_in_expr);
58 30 : if (!path_in_expr.is_lang_item ())
59 60 : for (auto &segment : path_in_expr.get_segments ())
60 30 : visit_path_expr_segment (segment);
61 30 : }
62 :
63 : void
64 45971 : DefaultHIRVisitor::walk (TypePathSegment &)
65 45971 : {}
66 :
67 : void
68 27 : DefaultHIRVisitor::walk (TypePathSegmentFunction &segment_function)
69 : {
70 27 : TypePathFunction &function_path = segment_function.get_function_path ();
71 27 : if (function_path.has_inputs ())
72 56 : for (auto ¶m : function_path.get_params ())
73 29 : param->accept_vis (*this);
74 27 : if (function_path.has_return_type ())
75 27 : function_path.get_return_type ().accept_vis (*this);
76 27 : }
77 :
78 : void
79 2335 : DefaultHIRVisitor::walk (TypePathSegmentGeneric &segment_generic)
80 : {
81 2335 : if (segment_generic.has_generic_args ())
82 2335 : visit_generic_args (segment_generic.get_generic_args ());
83 2335 : }
84 :
85 : void
86 46330 : DefaultHIRVisitor::walk (TypePath &type_path)
87 : {
88 94464 : for (auto &segment : type_path.get_segments ())
89 48134 : segment->accept_vis (*this);
90 46330 : }
91 :
92 : void
93 271 : DefaultHIRVisitor::visit_qualified_path_type (QualifiedPathType &path)
94 : {
95 271 : path.get_type ().accept_vis (*this);
96 271 : if (path.has_as_clause ())
97 239 : path.get_trait ().accept_vis (*this);
98 271 : }
99 :
100 : // TODO: Implement visit_path_expr_segment
101 : void
102 1481 : DefaultHIRVisitor::visit_path_expr_segment (PathExprSegment &segment)
103 : {
104 1481 : if (segment.has_generic_args ())
105 0 : visit_generic_args (segment.get_generic_args ());
106 1481 : }
107 :
108 : void
109 72 : DefaultHIRVisitor::walk (QualifiedPathInExpression &path_in_expr)
110 : {
111 72 : visit_outer_attrs (path_in_expr);
112 72 : visit_qualified_path_type (path_in_expr.get_path_type ());
113 144 : for (auto &segment : path_in_expr.get_segments ())
114 72 : visit_path_expr_segment (segment);
115 72 : }
116 :
117 : void
118 199 : DefaultHIRVisitor::walk (QualifiedPathInType &path_in_type)
119 : {
120 199 : visit_qualified_path_type (path_in_type.get_path_type ());
121 199 : path_in_type.get_associated_segment ().accept_vis (*this);
122 199 : for (auto &segment : path_in_type.get_segments ())
123 0 : segment->accept_vis (*this);
124 199 : }
125 :
126 : void
127 36 : DefaultHIRVisitor::walk (LiteralExpr &expr)
128 : {
129 36 : visit_outer_attrs (expr);
130 36 : }
131 :
132 : void
133 1220 : DefaultHIRVisitor::walk (BorrowExpr &expr)
134 : {
135 1220 : visit_outer_attrs (expr);
136 1220 : expr.get_expr ().accept_vis (*this);
137 1220 : }
138 :
139 : void
140 0 : DefaultHIRVisitor::walk (DereferenceExpr &expr)
141 : {
142 0 : visit_outer_attrs (expr);
143 0 : expr.get_expr ().accept_vis (*this);
144 0 : }
145 :
146 : void
147 0 : DefaultHIRVisitor::walk (ErrorPropagationExpr &expr)
148 : {
149 0 : visit_outer_attrs (expr);
150 0 : expr.get_expr ().accept_vis (*this);
151 0 : }
152 :
153 : void
154 480 : DefaultHIRVisitor::walk (NegationExpr &expr)
155 : {
156 480 : visit_outer_attrs (expr);
157 480 : expr.get_expr ().accept_vis (*this);
158 480 : }
159 :
160 : void
161 2181 : DefaultHIRVisitor::walk (ArithmeticOrLogicalExpr &expr)
162 : {
163 2181 : visit_outer_attrs (expr);
164 2181 : expr.get_lhs ().accept_vis (*this);
165 2181 : expr.get_rhs ().accept_vis (*this);
166 2181 : }
167 :
168 : void
169 3387 : DefaultHIRVisitor::walk (ComparisonExpr &expr)
170 : {
171 3387 : visit_outer_attrs (expr);
172 3387 : expr.get_lhs ().accept_vis (*this);
173 3387 : expr.get_rhs ().accept_vis (*this);
174 3387 : }
175 :
176 : void
177 353 : DefaultHIRVisitor::walk (LazyBooleanExpr &expr)
178 : {
179 353 : visit_outer_attrs (expr);
180 353 : expr.get_lhs ().accept_vis (*this);
181 353 : expr.get_rhs ().accept_vis (*this);
182 353 : }
183 :
184 : void
185 2010 : DefaultHIRVisitor::walk (TypeCastExpr &expr)
186 : {
187 2010 : visit_outer_attrs (expr);
188 2010 : expr.get_expr ().accept_vis (*this);
189 2010 : expr.get_type_to_convert_to ().accept_vis (*this);
190 2010 : }
191 :
192 : void
193 0 : DefaultHIRVisitor::walk (AssignmentExpr &expr)
194 : {
195 0 : visit_outer_attrs (expr);
196 0 : expr.get_lhs ().accept_vis (*this);
197 0 : expr.get_rhs ().accept_vis (*this);
198 0 : }
199 :
200 : void
201 655 : DefaultHIRVisitor::walk (CompoundAssignmentExpr &expr)
202 : {
203 655 : visit_outer_attrs (expr);
204 655 : expr.get_lhs ().accept_vis (*this);
205 655 : expr.get_rhs ().accept_vis (*this);
206 655 : }
207 :
208 : void
209 185 : DefaultHIRVisitor::walk (GroupedExpr &expr)
210 : {
211 185 : visit_outer_attrs (expr);
212 185 : visit_inner_attrs (expr);
213 185 : expr.get_expr_in_parens ().accept_vis (*this);
214 185 : }
215 :
216 : void
217 38 : DefaultHIRVisitor::walk (ArrayElemsValues &elems)
218 : {
219 248 : for (auto &elem : elems.get_values ())
220 210 : elem->accept_vis (*this);
221 38 : }
222 :
223 : void
224 37 : DefaultHIRVisitor::walk (ArrayElemsCopied &elems)
225 : {
226 37 : elems.get_elem_to_copy ().accept_vis (*this);
227 37 : elems.get_num_copies_expr ().accept_vis (*this);
228 37 : }
229 :
230 : void
231 75 : DefaultHIRVisitor::walk (ArrayExpr &expr)
232 : {
233 75 : visit_outer_attrs (expr);
234 75 : visit_inner_attrs (expr);
235 75 : expr.get_internal_elements ().accept_vis (*this);
236 75 : }
237 :
238 : void
239 0 : DefaultHIRVisitor::walk (ArrayIndexExpr &expr)
240 : {
241 0 : visit_outer_attrs (expr);
242 0 : expr.get_array_expr ().accept_vis (*this);
243 0 : expr.get_index_expr ().accept_vis (*this);
244 0 : }
245 :
246 : void
247 2 : DefaultHIRVisitor::walk (TupleExpr &expr)
248 : {
249 2 : visit_outer_attrs (expr);
250 2 : visit_inner_attrs (expr);
251 6 : for (auto &elem : expr.get_tuple_elems ())
252 4 : elem->accept_vis (*this);
253 2 : }
254 :
255 : void
256 0 : DefaultHIRVisitor::walk (TupleIndexExpr &expr)
257 : {
258 0 : visit_outer_attrs (expr);
259 0 : expr.get_tuple_expr ().accept_vis (*this);
260 0 : }
261 :
262 : void
263 13 : DefaultHIRVisitor::walk (StructExprStruct &expr)
264 : {
265 13 : visit_outer_attrs (expr);
266 13 : visit_inner_attrs (expr);
267 13 : expr.get_struct_name ().accept_vis (*this);
268 13 : }
269 :
270 : void
271 86 : DefaultHIRVisitor::walk (StructExprFieldIdentifier &)
272 86 : {}
273 :
274 : void
275 288 : DefaultHIRVisitor::walk (StructExprFieldIdentifierValue &field)
276 : {
277 288 : field.get_value ().accept_vis (*this);
278 288 : }
279 :
280 : void
281 0 : DefaultHIRVisitor::walk (StructExprFieldIndexValue &field)
282 : {
283 0 : field.get_value ().accept_vis (*this);
284 0 : }
285 :
286 : void
287 190 : DefaultHIRVisitor::walk (StructExprStructFields &expr)
288 : {
289 190 : visit_outer_attrs (expr);
290 190 : visit_inner_attrs (expr);
291 190 : expr.get_struct_name ().accept_vis (*this);
292 190 : if (expr.has_struct_base ())
293 : {
294 0 : StructBase &base = expr.get_struct_base ();
295 0 : base.get_base ().accept_vis (*this);
296 : }
297 564 : for (auto &field : expr.get_fields ())
298 374 : field->accept_vis (*this);
299 190 : }
300 :
301 : void
302 0 : DefaultHIRVisitor::walk (StructExprStructBase &expr)
303 : {
304 0 : visit_outer_attrs (expr);
305 0 : visit_inner_attrs (expr);
306 0 : expr.get_struct_name ().accept_vis (*this);
307 0 : StructBase &base = expr.get_struct_base ();
308 0 : base.get_base ().accept_vis (*this);
309 0 : }
310 :
311 : void
312 9149 : DefaultHIRVisitor::walk (CallExpr &expr)
313 : {
314 9149 : visit_outer_attrs (expr);
315 9149 : expr.get_fnexpr ().accept_vis (*this);
316 19208 : for (auto &arg : expr.get_arguments ())
317 10059 : arg->accept_vis (*this);
318 9149 : }
319 :
320 : void
321 1379 : DefaultHIRVisitor::walk (MethodCallExpr &expr)
322 : {
323 1379 : visit_outer_attrs (expr);
324 1379 : expr.get_receiver ().accept_vis (*this);
325 1379 : visit_path_expr_segment (expr.get_method_name ());
326 2253 : for (auto &arg : expr.get_arguments ())
327 874 : arg->accept_vis (*this);
328 1379 : }
329 :
330 : void
331 0 : DefaultHIRVisitor::walk (FieldAccessExpr &expr)
332 : {
333 0 : visit_outer_attrs (expr);
334 0 : expr.get_receiver_expr ().accept_vis (*this);
335 0 : }
336 :
337 : void
338 0 : DefaultHIRVisitor::visit_closure_param (ClosureParam ¶m)
339 : {
340 0 : visit_outer_attrs (param);
341 0 : param.get_pattern ().accept_vis (*this);
342 0 : if (param.has_type_given ())
343 : {
344 0 : param.get_type ().accept_vis (*this);
345 : }
346 0 : }
347 :
348 : void
349 7 : DefaultHIRVisitor::walk (ClosureExpr &expr)
350 : {
351 7 : visit_outer_attrs (expr);
352 7 : for (auto ¶m : expr.get_params ())
353 0 : visit_closure_param (param);
354 7 : if (expr.has_return_type ())
355 0 : expr.get_return_type ().accept_vis (*this);
356 7 : expr.get_expr ().accept_vis (*this);
357 7 : }
358 :
359 : void
360 21731 : DefaultHIRVisitor::walk (BlockExpr &expr)
361 : {
362 21731 : visit_outer_attrs (expr);
363 21731 : visit_inner_attrs (expr);
364 45040 : for (auto &stmt : expr.get_statements ())
365 23309 : stmt->accept_vis (*this);
366 21731 : if (expr.has_expr ())
367 15425 : expr.get_final_expr ().accept_vis (*this);
368 21731 : }
369 :
370 : void
371 481 : DefaultHIRVisitor::walk (AnonConst &expr)
372 : {
373 481 : if (!expr.is_deferred ())
374 481 : expr.get_inner_expr ().accept_vis (*this);
375 481 : }
376 :
377 : void
378 7 : DefaultHIRVisitor::walk (ConstBlock &expr)
379 : {
380 7 : expr.get_const_expr ().accept_vis (*this);
381 7 : }
382 :
383 : void
384 9 : DefaultHIRVisitor::walk (ContinueExpr &expr)
385 : {
386 9 : visit_outer_attrs (expr);
387 9 : if (expr.has_label ())
388 4 : expr.get_label ().accept_vis (*this);
389 9 : }
390 :
391 : void
392 53 : DefaultHIRVisitor::walk (BreakExpr &expr)
393 : {
394 53 : visit_outer_attrs (expr);
395 53 : if (expr.has_label ())
396 20 : expr.get_label ().accept_vis (*this);
397 :
398 53 : if (expr.has_break_expr ())
399 1 : expr.get_expr ().accept_vis (*this);
400 53 : }
401 :
402 : void
403 0 : DefaultHIRVisitor::walk (RangeFromToExpr &expr)
404 : {
405 0 : expr.get_from_expr ().accept_vis (*this);
406 0 : expr.get_to_expr ().accept_vis (*this);
407 0 : }
408 :
409 : void
410 0 : DefaultHIRVisitor::walk (RangeFromExpr &expr)
411 : {
412 0 : expr.get_from_expr ().accept_vis (*this);
413 0 : }
414 :
415 : void
416 0 : DefaultHIRVisitor::walk (RangeToExpr &expr)
417 : {
418 0 : expr.get_to_expr ().accept_vis (*this);
419 0 : }
420 :
421 : void
422 0 : DefaultHIRVisitor::walk (RangeFullExpr &)
423 0 : {}
424 :
425 : void
426 0 : DefaultHIRVisitor::walk (RangeFromToInclExpr &expr)
427 : {
428 0 : expr.get_from_expr ().accept_vis (*this);
429 0 : expr.get_to_expr ().accept_vis (*this);
430 0 : }
431 :
432 : void
433 0 : DefaultHIRVisitor::walk (RangeToInclExpr &expr)
434 : {
435 0 : expr.get_to_expr ().accept_vis (*this);
436 0 : }
437 :
438 : void
439 1 : DefaultHIRVisitor::walk (BoxExpr &expr)
440 : {
441 1 : visit_outer_attrs (expr);
442 1 : expr.get_expr ().accept_vis (*this);
443 1 : }
444 :
445 : void
446 499 : DefaultHIRVisitor::walk (ReturnExpr &expr)
447 : {
448 499 : visit_outer_attrs (expr);
449 499 : if (expr.has_return_expr ())
450 470 : expr.get_expr ().accept_vis (*this);
451 499 : }
452 :
453 : void
454 3203 : DefaultHIRVisitor::walk (UnsafeBlockExpr &expr)
455 : {
456 3203 : visit_outer_attrs (expr);
457 3203 : expr.get_block_expr ().accept_vis (*this);
458 3203 : }
459 :
460 : void
461 40 : DefaultHIRVisitor::visit_loop_label (LoopLabel &label)
462 : {
463 40 : label.get_lifetime ().accept_vis (*this);
464 40 : }
465 :
466 : void
467 93 : DefaultHIRVisitor::walk (LoopExpr &expr)
468 : {
469 93 : visit_outer_attrs (expr);
470 93 : if (expr.has_loop_label ())
471 43 : visit_loop_label (expr.get_loop_label ());
472 93 : expr.get_loop_block ().accept_vis (*this);
473 93 : }
474 :
475 : void
476 73 : DefaultHIRVisitor::walk (WhileLoopExpr &expr)
477 : {
478 73 : visit_outer_attrs (expr);
479 73 : if (expr.has_loop_label ())
480 1 : visit_loop_label (expr.get_loop_label ());
481 73 : expr.get_predicate_expr ().accept_vis (*this);
482 73 : expr.get_loop_block ().accept_vis (*this);
483 73 : }
484 :
485 : void
486 0 : DefaultHIRVisitor::walk (WhileLetLoopExpr &expr)
487 : {
488 0 : visit_outer_attrs (expr);
489 0 : expr.get_pattern ()->accept_vis (*this);
490 0 : if (expr.has_loop_label ())
491 0 : visit_loop_label (expr.get_loop_label ());
492 0 : expr.get_cond ().accept_vis (*this);
493 0 : expr.get_loop_block ().accept_vis (*this);
494 0 : }
495 :
496 : void
497 2402 : DefaultHIRVisitor::walk (IfExpr &expr)
498 : {
499 2402 : visit_outer_attrs (expr);
500 2402 : expr.get_if_condition ().accept_vis (*this);
501 2402 : expr.get_if_block ().accept_vis (*this);
502 2402 : }
503 :
504 : void
505 1199 : DefaultHIRVisitor::walk (IfExprConseqElse &expr)
506 : {
507 1199 : expr.IfExpr::accept_vis (*this);
508 1199 : expr.get_else_block ().accept_vis (*this);
509 1199 : }
510 :
511 : void
512 2361 : DefaultHIRVisitor::visit_match_arm (MatchArm &arm)
513 : {
514 : // visit_outer_attrs (arm);
515 2361 : arm.get_pattern ()->accept_vis (*this);
516 2361 : if (arm.has_match_arm_guard ())
517 1 : arm.get_guard_expr ().accept_vis (*this);
518 2361 : }
519 :
520 : void
521 2361 : DefaultHIRVisitor::visit_match_case (MatchCase &arm)
522 : {
523 2361 : visit_match_arm (arm.get_arm ());
524 2361 : arm.get_expr ().accept_vis (*this);
525 2361 : }
526 :
527 : void
528 1004 : DefaultHIRVisitor::walk (MatchExpr &expr)
529 : {
530 1004 : visit_outer_attrs (expr);
531 1004 : visit_inner_attrs (expr);
532 1004 : expr.get_scrutinee_expr ().accept_vis (*this);
533 3365 : for (auto &arm : expr.get_match_cases ())
534 2361 : visit_match_case (arm);
535 1004 : }
536 :
537 : void
538 0 : DefaultHIRVisitor::walk (AwaitExpr &expr)
539 : {
540 0 : visit_outer_attrs (expr);
541 0 : expr.get_awaited_expr ().accept_vis (*this);
542 0 : }
543 :
544 : void
545 0 : DefaultHIRVisitor::walk (AsyncBlockExpr &expr)
546 : {
547 0 : visit_outer_attrs (expr);
548 0 : expr.get_block_expr ().accept_vis (*this);
549 0 : }
550 :
551 : void
552 24 : DefaultHIRVisitor::walk (InlineAsm &expr)
553 : {
554 24 : visit_outer_attrs (expr);
555 24 : auto &operands = expr.get_operands ();
556 24 : using RegisterType = AST::InlineAsmOperand::RegisterType;
557 53 : for (auto &operand : operands)
558 : {
559 29 : switch (operand.get_register_type ())
560 : {
561 10 : case RegisterType::In:
562 10 : {
563 10 : operand.get_in ().expr->accept_vis (*this);
564 10 : break;
565 : }
566 17 : case RegisterType::Out:
567 17 : {
568 17 : operand.get_out ().expr->accept_vis (*this);
569 17 : break;
570 : }
571 0 : case RegisterType::InOut:
572 0 : {
573 0 : operand.get_in_out ().expr->accept_vis (*this);
574 0 : break;
575 : }
576 2 : case RegisterType::SplitInOut:
577 2 : {
578 2 : operand.get_split_in_out ().in_expr->accept_vis (*this);
579 2 : operand.get_split_in_out ().out_expr->accept_vis (*this);
580 2 : break;
581 : }
582 0 : case RegisterType::Const:
583 0 : {
584 0 : operand.get_const ().anon_const.get_inner_expr ().accept_vis (
585 : *this);
586 0 : break;
587 : }
588 0 : case RegisterType::Sym:
589 0 : {
590 0 : operand.get_sym ().expr->accept_vis (*this);
591 0 : break;
592 : }
593 0 : case RegisterType::Label:
594 0 : {
595 0 : operand.get_label ().expr->accept_vis (*this);
596 0 : break;
597 : }
598 : }
599 : }
600 24 : }
601 :
602 : void
603 2 : DefaultHIRVisitor::walk (LlvmInlineAsm &expr)
604 : {
605 2 : for (auto &output : expr.outputs)
606 0 : output.expr->accept_vis (*this);
607 4 : for (auto &input : expr.inputs)
608 2 : input.expr->accept_vis (*this);
609 2 : }
610 :
611 : void
612 0 : DefaultHIRVisitor::walk (OffsetOf &expr)
613 : {
614 0 : expr.get_type ().accept_vis (*this);
615 0 : }
616 :
617 : void
618 8133 : DefaultHIRVisitor::walk (TypeParam ¶m)
619 : {
620 8133 : visit_outer_attrs (param);
621 8940 : for (auto &bounds : param.get_type_param_bounds ())
622 807 : bounds->accept_vis (*this);
623 8133 : if (param.has_type ())
624 347 : param.get_type ().accept_vis (*this);
625 8133 : }
626 :
627 : void
628 0 : DefaultHIRVisitor::walk (ConstGenericParam &const_param)
629 : {
630 0 : visit_outer_attrs (const_param);
631 0 : const_param.get_type ().accept_vis (*this);
632 0 : if (const_param.has_default_expression ())
633 0 : const_param.get_default_expression ().accept_vis (*this);
634 0 : }
635 :
636 : void
637 0 : DefaultHIRVisitor::walk (LifetimeWhereClauseItem &item)
638 : {
639 0 : item.get_lifetime ().accept_vis (*this);
640 0 : for (auto &bound : item.get_lifetime_bounds ())
641 0 : bound.accept_vis (*this);
642 0 : }
643 :
644 : void
645 139 : DefaultHIRVisitor::walk (TypeBoundWhereClauseItem &item)
646 : {
647 146 : for (auto &lifetime : item.get_for_lifetimes ())
648 7 : lifetime.accept_vis (*this);
649 139 : item.get_bound_type ().accept_vis (*this);
650 278 : for (auto ¶m : item.get_type_param_bounds ())
651 139 : param->accept_vis (*this);
652 139 : }
653 :
654 : void
655 1165 : DefaultHIRVisitor::walk (Module &module)
656 : {
657 1165 : visit_outer_attrs (module);
658 1165 : visit_inner_attrs (module);
659 4863 : for (auto &item : module.get_items ())
660 3698 : item->accept_vis (*this);
661 1165 : }
662 :
663 : void
664 0 : DefaultHIRVisitor::walk (ExternCrate &crate)
665 : {
666 0 : visit_outer_attrs (crate);
667 0 : }
668 :
669 : void
670 0 : DefaultHIRVisitor::walk (UseTreeGlob &)
671 0 : {}
672 :
673 : void
674 0 : DefaultHIRVisitor::walk (UseTreeList &)
675 0 : {}
676 :
677 : void
678 0 : DefaultHIRVisitor::walk (UseTreeRebind &)
679 0 : {}
680 :
681 : void
682 0 : DefaultHIRVisitor::walk (UseDeclaration &)
683 0 : {}
684 :
685 : void
686 7785 : DefaultHIRVisitor::visit_function_param (FunctionParam ¶m)
687 : {
688 7785 : param.get_param_name ().accept_vis (*this);
689 7785 : param.get_type ().accept_vis (*this);
690 7785 : }
691 :
692 : void
693 12953 : DefaultHIRVisitor::walk (Function &function)
694 : {
695 12953 : visit_outer_attrs (function);
696 13700 : for (auto &generic : function.get_generic_params ())
697 747 : generic->accept_vis (*this);
698 19127 : for (auto ¶m : function.get_function_params ())
699 6174 : visit_function_param (param);
700 12953 : if (function.has_return_type ())
701 9559 : function.get_return_type ().accept_vis (*this);
702 12953 : if (function.has_where_clause ())
703 27 : visit_where_clause (function.get_where_clause ());
704 12953 : function.get_definition ().accept_vis (*this);
705 12953 : }
706 :
707 : void
708 1235 : DefaultHIRVisitor::walk (TypeAlias &type_alias)
709 : {
710 1235 : visit_outer_attrs (type_alias);
711 1258 : for (auto &generic : type_alias.get_generic_params ())
712 23 : generic->accept_vis (*this);
713 1235 : if (type_alias.has_where_clause ())
714 0 : visit_where_clause (type_alias.get_where_clause ());
715 1235 : type_alias.get_type_aliased ().accept_vis (*this);
716 1235 : }
717 :
718 : void
719 2076 : DefaultHIRVisitor::visit_struct_field (StructField &field)
720 : {
721 2076 : field.get_field_type ().accept_vis (*this);
722 2076 : }
723 :
724 : void
725 1465 : DefaultHIRVisitor::walk (StructStruct &struct_item)
726 : {
727 1465 : visit_outer_attrs (struct_item);
728 1949 : for (auto &generic : struct_item.get_generic_params ())
729 484 : generic->accept_vis (*this);
730 1465 : if (struct_item.has_where_clause ())
731 2 : visit_where_clause (struct_item.get_where_clause ());
732 3248 : for (auto &field : struct_item.get_fields ())
733 1783 : visit_struct_field (field);
734 1465 : }
735 :
736 : void
737 932 : DefaultHIRVisitor::walk (TupleStruct &tuple_struct)
738 : {
739 932 : visit_outer_attrs (tuple_struct);
740 1280 : for (auto &generic : tuple_struct.get_generic_params ())
741 348 : generic->accept_vis (*this);
742 932 : if (tuple_struct.has_where_clause ())
743 0 : visit_where_clause (tuple_struct.get_where_clause ());
744 2514 : for (auto &field : tuple_struct.get_fields ())
745 1582 : field.get_field_type ().accept_vis (*this);
746 932 : }
747 :
748 : void
749 1157 : DefaultHIRVisitor::walk (EnumItem &item)
750 : {
751 1157 : visit_outer_attrs (item);
752 1157 : }
753 :
754 : void
755 390 : DefaultHIRVisitor::walk (EnumItemTuple &item_tuple)
756 : {
757 390 : item_tuple.EnumItem::accept_vis (*this);
758 803 : for (auto &field : item_tuple.get_tuple_fields ())
759 413 : field.get_field_type ().accept_vis (*this);
760 390 : }
761 :
762 : void
763 79 : DefaultHIRVisitor::walk (EnumItemStruct &item_struct)
764 : {
765 79 : item_struct.EnumItem::accept_vis (*this);
766 209 : for (auto &field : item_struct.get_struct_fields ())
767 130 : field.get_field_type ().accept_vis (*this);
768 79 : }
769 :
770 : void
771 273 : DefaultHIRVisitor::walk (EnumItemDiscriminant &item)
772 : {
773 273 : item.EnumItem::accept_vis (*this);
774 273 : item.get_discriminant_expression ().accept_vis (*this);
775 273 : }
776 :
777 : void
778 491 : DefaultHIRVisitor::walk (Enum &enum_item)
779 : {
780 491 : visit_outer_attrs (enum_item);
781 759 : for (auto &generic : enum_item.get_generic_params ())
782 268 : generic->accept_vis (*this);
783 491 : if (enum_item.has_where_clause ())
784 0 : visit_where_clause (enum_item.get_where_clause ());
785 1648 : for (auto &item : enum_item.get_variants ())
786 1157 : item->accept_vis (*this);
787 491 : }
788 :
789 : void
790 100 : DefaultHIRVisitor::walk (Union &union_item)
791 : {
792 100 : visit_outer_attrs (union_item);
793 173 : for (auto &generic : union_item.get_generic_params ())
794 73 : generic->accept_vis (*this);
795 100 : if (union_item.has_where_clause ())
796 0 : visit_where_clause (union_item.get_where_clause ());
797 393 : for (auto &variant : union_item.get_variants ())
798 293 : visit_struct_field (variant);
799 100 : }
800 :
801 : void
802 507 : DefaultHIRVisitor::walk (ConstantItem &const_item)
803 : {
804 507 : visit_outer_attrs (const_item);
805 507 : const_item.get_type ().accept_vis (*this);
806 507 : const_item.get_expr ().accept_vis (*this);
807 507 : }
808 :
809 : void
810 50 : DefaultHIRVisitor::walk (StaticItem &static_item)
811 : {
812 50 : visit_outer_attrs (static_item);
813 50 : static_item.get_type ().accept_vis (*this);
814 50 : static_item.get_expr ().accept_vis (*this);
815 50 : }
816 :
817 : void
818 2203 : DefaultHIRVisitor::visit_self_param (SelfParam &self_param)
819 : {
820 2203 : if (self_param.has_lifetime ())
821 : {
822 1644 : Lifetime lifetime = self_param.get_lifetime ();
823 1644 : lifetime.accept_vis (*this);
824 1644 : }
825 2203 : if (self_param.has_type ())
826 0 : self_param.get_type ().accept_vis (*this);
827 2203 : }
828 :
829 : void
830 2495 : DefaultHIRVisitor::walk (TraitItemFunc &item)
831 : {
832 2495 : visit_outer_attrs (item);
833 2495 : TraitFunctionDecl &decl = item.get_decl ();
834 2519 : for (auto &generic : decl.get_generic_params ())
835 24 : generic->accept_vis (*this);
836 2495 : if (decl.get_self ().has_value ())
837 2203 : visit_self_param (decl.get_self ().value ());
838 4106 : for (auto ¶m : decl.get_function_params ())
839 1611 : visit_function_param (param);
840 2495 : if (decl.has_return_type ())
841 2085 : decl.get_return_type ().accept_vis (*this);
842 2495 : if (decl.has_where_clause ())
843 0 : visit_where_clause (decl.get_where_clause ());
844 2495 : if (item.has_definition ())
845 842 : item.get_block_expr ().accept_vis (*this);
846 2495 : }
847 :
848 : void
849 30 : DefaultHIRVisitor::walk (TraitItemConst &item)
850 : {
851 30 : visit_outer_attrs (item);
852 30 : item.get_type ().accept_vis (*this);
853 30 : if (item.has_expr ())
854 7 : item.get_expr ().accept_vis (*this);
855 30 : }
856 :
857 : void
858 710 : DefaultHIRVisitor::walk (TraitItemType &item)
859 : {
860 710 : visit_outer_attrs (item);
861 746 : for (auto &bound : item.get_type_param_bounds ())
862 36 : bound->accept_vis (*this);
863 710 : }
864 :
865 : void
866 0 : DefaultHIRVisitor::visit_where_clause (const WhereClause &where_clause)
867 : {
868 0 : for (auto &item : where_clause.get_items ())
869 0 : item->accept_vis (*this);
870 0 : }
871 :
872 : void
873 119 : DefaultHIRVisitor::visit_where_clause (WhereClause &where_clause)
874 : {
875 258 : for (auto &item : where_clause.get_items ())
876 : {
877 139 : item->accept_vis (*this);
878 : }
879 119 : }
880 :
881 : void
882 0 : DefaultHIRVisitor::walk (WhereClauseItem &node)
883 0 : {}
884 :
885 : void
886 3699 : DefaultHIRVisitor::walk (Trait &trait)
887 : {
888 3699 : visit_outer_attrs (trait);
889 8019 : for (auto &generic : trait.get_generic_params ())
890 4320 : generic->accept_vis (*this);
891 3699 : if (trait.has_where_clause ())
892 7 : visit_where_clause (trait.get_where_clause ());
893 4278 : for (auto &bound : trait.get_type_param_bounds ())
894 579 : bound->accept_vis (*this);
895 6934 : for (auto &item : trait.get_trait_items ())
896 3235 : item->accept_vis (*this);
897 3699 : }
898 :
899 : void
900 5395 : DefaultHIRVisitor::walk (ImplBlock &impl)
901 : {
902 5395 : visit_outer_attrs (impl);
903 6462 : for (auto &generic : impl.get_generic_params ())
904 1067 : generic->accept_vis (*this);
905 5395 : if (impl.has_trait_ref ())
906 4462 : impl.get_trait_ref ().accept_vis (*this);
907 5395 : impl.get_type ().accept_vis (*this);
908 5395 : if (impl.has_where_clause ())
909 83 : visit_where_clause (impl.get_where_clause ());
910 5395 : visit_inner_attrs (impl);
911 13364 : for (auto &item : impl.get_impl_items ())
912 7969 : item->accept_vis (*this);
913 5395 : }
914 :
915 : void
916 0 : DefaultHIRVisitor::walk (ExternalStaticItem &item)
917 : {
918 0 : visit_outer_attrs (item);
919 0 : item.get_item_type ().accept_vis (*this);
920 0 : }
921 :
922 : void
923 2817 : DefaultHIRVisitor::visit_named_function_param (NamedFunctionParam ¶m)
924 : {
925 2817 : param.get_type ().accept_vis (*this);
926 2817 : }
927 :
928 : void
929 2481 : DefaultHIRVisitor::walk (ExternalFunctionItem &item)
930 : {
931 2481 : visit_outer_attrs (item);
932 3478 : for (auto &generic : item.get_generic_params ())
933 997 : generic->accept_vis (*this);
934 5298 : for (auto ¶m : item.get_function_params ())
935 2817 : visit_named_function_param (param);
936 2481 : if (item.has_return_type ())
937 1284 : item.get_return_type ().accept_vis (*this);
938 2481 : if (item.has_where_clause ())
939 0 : visit_where_clause (item.get_where_clause ());
940 2481 : }
941 :
942 : void
943 0 : DefaultHIRVisitor::walk (ExternalTypeItem &item)
944 : {
945 0 : visit_outer_attrs (item);
946 0 : }
947 :
948 : void
949 1606 : DefaultHIRVisitor::walk (ExternBlock &block)
950 : {
951 1606 : visit_outer_attrs (block);
952 1606 : visit_inner_attrs (block);
953 4087 : for (auto &item : block.get_extern_items ())
954 2481 : item->accept_vis (*this);
955 1606 : }
956 :
957 : void
958 405 : DefaultHIRVisitor::walk (LiteralPattern &)
959 405 : {}
960 :
961 : void
962 8348 : DefaultHIRVisitor::walk (IdentifierPattern &pattern)
963 : {
964 8348 : if (pattern.has_subpattern ())
965 9 : pattern.get_subpattern ().accept_vis (*this);
966 8348 : }
967 :
968 : void
969 749 : DefaultHIRVisitor::walk (WildcardPattern &)
970 749 : {}
971 :
972 : void
973 77 : DefaultHIRVisitor::walk (RangePatternBoundLiteral &)
974 77 : {}
975 :
976 : void
977 21 : DefaultHIRVisitor::walk (RangePatternBoundPath &bound)
978 : {
979 21 : bound.get_path ().accept_vis (*this);
980 21 : }
981 :
982 : void
983 0 : DefaultHIRVisitor::walk (RangePatternBoundQualPath &bound)
984 : {
985 0 : bound.get_qualified_path ().accept_vis (*this);
986 0 : }
987 :
988 : void
989 49 : DefaultHIRVisitor::walk (RangePattern &pattern)
990 : {
991 49 : pattern.get_lower_bound ().accept_vis (*this);
992 49 : pattern.get_upper_bound ().accept_vis (*this);
993 49 : }
994 :
995 : void
996 173 : DefaultHIRVisitor::walk (ReferencePattern &pattern)
997 : {
998 173 : pattern.get_referenced_pattern ().accept_vis (*this);
999 173 : }
1000 :
1001 : void
1002 18 : DefaultHIRVisitor::walk (StructPatternFieldTuplePat &field)
1003 : {
1004 18 : visit_outer_attrs (field);
1005 18 : field.get_tuple_pattern ().accept_vis (*this);
1006 18 : }
1007 :
1008 : void
1009 120 : DefaultHIRVisitor::walk (StructPatternFieldIdentPat &field)
1010 : {
1011 120 : visit_outer_attrs (field);
1012 120 : field.get_pattern ().accept_vis (*this);
1013 120 : }
1014 :
1015 : void
1016 93 : DefaultHIRVisitor::walk (StructPatternFieldIdent &field)
1017 : {
1018 93 : visit_outer_attrs (field);
1019 93 : }
1020 :
1021 : void
1022 137 : DefaultHIRVisitor::walk (StructPattern &pattern)
1023 : {
1024 137 : pattern.get_path ().accept_vis (*this);
1025 137 : StructPatternElements &elements = pattern.get_struct_pattern_elems ();
1026 370 : for (auto &field : elements.get_struct_pattern_fields ())
1027 233 : field->accept_vis (*this);
1028 137 : }
1029 :
1030 : void
1031 880 : DefaultHIRVisitor::walk (TupleStructItemsNoRest &tuple_items)
1032 : {
1033 1848 : for (auto &item : tuple_items.get_patterns ())
1034 968 : item->accept_vis (*this);
1035 880 : }
1036 :
1037 : void
1038 36 : DefaultHIRVisitor::walk (TupleStructItemsHasRest &tuple_items)
1039 : {
1040 65 : for (auto &lower : tuple_items.get_lower_patterns ())
1041 29 : lower->accept_vis (*this);
1042 50 : for (auto &upper : tuple_items.get_upper_patterns ())
1043 14 : upper->accept_vis (*this);
1044 36 : }
1045 :
1046 : void
1047 916 : DefaultHIRVisitor::walk (TupleStructPattern &pattern)
1048 : {
1049 916 : pattern.get_path ().accept_vis (*this);
1050 916 : pattern.get_items ().accept_vis (*this);
1051 916 : }
1052 :
1053 : void
1054 100 : DefaultHIRVisitor::walk (TuplePatternItemsNoRest &tuple_items)
1055 : {
1056 307 : for (auto &pattern : tuple_items.get_patterns ())
1057 207 : pattern->accept_vis (*this);
1058 100 : }
1059 :
1060 : void
1061 23 : DefaultHIRVisitor::walk (TuplePatternItemsHasRest &tuple_items)
1062 : {
1063 46 : for (auto &lower : tuple_items.get_lower_patterns ())
1064 23 : lower->accept_vis (*this);
1065 45 : for (auto &upper : tuple_items.get_upper_patterns ())
1066 22 : upper->accept_vis (*this);
1067 23 : }
1068 :
1069 : void
1070 123 : DefaultHIRVisitor::walk (TuplePattern &pattern)
1071 : {
1072 123 : pattern.get_items ().accept_vis (*this);
1073 123 : }
1074 :
1075 : void
1076 31 : DefaultHIRVisitor::walk (SlicePatternItemsNoRest &items)
1077 : {
1078 92 : for (auto &pattern : items.get_patterns ())
1079 61 : pattern->accept_vis (*this);
1080 31 : }
1081 :
1082 : void
1083 44 : DefaultHIRVisitor::walk (SlicePatternItemsHasRest &items)
1084 : {
1085 87 : for (auto &lower : items.get_lower_patterns ())
1086 43 : lower->accept_vis (*this);
1087 87 : for (auto &upper : items.get_upper_patterns ())
1088 43 : upper->accept_vis (*this);
1089 44 : }
1090 :
1091 : void
1092 75 : DefaultHIRVisitor::walk (SlicePattern &pattern)
1093 : {
1094 75 : pattern.get_items ().accept_vis (*this);
1095 75 : }
1096 :
1097 : void
1098 145 : DefaultHIRVisitor::walk (AltPattern &pattern)
1099 : {
1100 436 : for (auto &item : pattern.get_alts ())
1101 291 : item->accept_vis (*this);
1102 145 : }
1103 :
1104 : void
1105 46 : DefaultHIRVisitor::walk (EmptyStmt &stmt)
1106 46 : {}
1107 :
1108 : void
1109 12 : DefaultHIRVisitor::walk (LetStmt &stmt)
1110 : {
1111 12 : visit_outer_attrs (stmt);
1112 12 : stmt.get_pattern ().accept_vis (*this);
1113 12 : if (stmt.has_type ())
1114 0 : stmt.get_type ().accept_vis (*this);
1115 12 : if (stmt.has_init_expr ())
1116 12 : stmt.get_init_expr ().accept_vis (*this);
1117 12 : }
1118 :
1119 : void
1120 10477 : DefaultHIRVisitor::walk (ExprStmt &stmt)
1121 : {
1122 10477 : stmt.get_expr ().accept_vis (*this);
1123 10477 : }
1124 :
1125 : void
1126 1681 : DefaultHIRVisitor::walk (TraitBound &bound)
1127 : {
1128 1688 : for (auto &lifetime : bound.get_for_lifetimes ())
1129 7 : lifetime.accept_vis (*this);
1130 1681 : bound.get_path ().accept_vis (*this);
1131 1681 : }
1132 :
1133 : void
1134 28 : DefaultHIRVisitor::walk (ImplTraitType &type)
1135 : {
1136 56 : for (auto &bound : type.get_type_param_bounds ())
1137 28 : bound->accept_vis (*this);
1138 28 : }
1139 :
1140 : void
1141 91 : DefaultHIRVisitor::walk (TraitObjectType &type)
1142 : {
1143 194 : for (auto &bound : type.get_type_param_bounds ())
1144 103 : bound->accept_vis (*this);
1145 91 : }
1146 :
1147 : void
1148 4 : DefaultHIRVisitor::walk (ParenthesisedType &type)
1149 : {
1150 4 : type.get_type_in_parens ().accept_vis (*this);
1151 4 : }
1152 :
1153 : void
1154 316 : DefaultHIRVisitor::walk (TupleType &type)
1155 : {
1156 831 : for (auto &elem : type.get_elems ())
1157 515 : elem->accept_vis (*this);
1158 316 : }
1159 :
1160 : void
1161 185 : DefaultHIRVisitor::walk (NeverType &type)
1162 185 : {}
1163 :
1164 : void
1165 4036 : DefaultHIRVisitor::walk (RawPointerType &type)
1166 : {
1167 4036 : type.get_type ().accept_vis (*this);
1168 4036 : }
1169 :
1170 : void
1171 3975 : DefaultHIRVisitor::walk (ReferenceType &type)
1172 : {
1173 3975 : if (type.has_lifetime ())
1174 3975 : type.get_lifetime ().accept_vis (*this);
1175 3975 : type.get_base_type ().accept_vis (*this);
1176 3975 : }
1177 :
1178 : void
1179 474 : DefaultHIRVisitor::walk (ArrayType &type)
1180 : {
1181 474 : type.get_element_type ().accept_vis (*this);
1182 474 : type.get_size_expr ().accept_vis (*this);
1183 474 : }
1184 :
1185 : void
1186 848 : DefaultHIRVisitor::walk (SliceType &type)
1187 : {
1188 848 : type.get_element_type ().accept_vis (*this);
1189 848 : }
1190 :
1191 : void
1192 14 : DefaultHIRVisitor::walk (InferredType &type)
1193 14 : {}
1194 :
1195 : void
1196 33 : DefaultHIRVisitor::walk (BareFunctionType &type)
1197 : {
1198 33 : for (auto &lifetime : type.get_for_lifetimes ())
1199 0 : lifetime.accept_vis (*this);
1200 54 : for (auto ¶m : type.get_function_params ())
1201 21 : param.get_type ().accept_vis (*this);
1202 33 : if (type.has_return_type ())
1203 23 : type.get_return_type ().accept_vis (*this);
1204 33 : }
1205 :
1206 : } // namespace HIR
1207 : } // namespace Rust
|