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 6243 : DefaultHIRVisitor::walk (Lifetime &)
30 6243 : {}
31 :
32 : void
33 166 : DefaultHIRVisitor::walk (LifetimeParam &lifetime_param)
34 : {
35 166 : visit_outer_attrs (lifetime_param);
36 166 : lifetime_param.get_lifetime ().accept_vis (*this);
37 166 : for (Lifetime &lifetime_bound : lifetime_param.get_lifetime_bounds ())
38 0 : lifetime_bound.accept_vis (*this);
39 166 : }
40 :
41 : void
42 2562 : DefaultHIRVisitor::visit_generic_args (GenericArgs &generic_args)
43 : {
44 2581 : for (auto &lifetime : generic_args.get_lifetime_args ())
45 19 : lifetime.accept_vis (*this);
46 5208 : for (auto &type : generic_args.get_type_args ())
47 2646 : type->accept_vis (*this);
48 2647 : for (auto &binding : generic_args.get_binding_args ())
49 85 : binding.get_type ().accept_vis (*this);
50 2598 : for (auto &const_arg : generic_args.get_const_args ())
51 36 : const_arg.get_expression ()->accept_vis (*this);
52 2562 : }
53 :
54 : void
55 56 : DefaultHIRVisitor::walk (PathInExpression &path_in_expr)
56 : {
57 56 : visit_outer_attrs (path_in_expr);
58 56 : if (!path_in_expr.is_lang_item ())
59 112 : for (auto &segment : path_in_expr.get_segments ())
60 56 : visit_path_expr_segment (segment);
61 56 : }
62 :
63 : void
64 50877 : DefaultHIRVisitor::walk (TypePathSegment &)
65 50877 : {}
66 :
67 : void
68 28 : DefaultHIRVisitor::walk (TypePathSegmentFunction &segment_function)
69 : {
70 28 : TypePathFunction &function_path = segment_function.get_function_path ();
71 28 : if (function_path.has_inputs ())
72 56 : for (auto ¶m : function_path.get_params ())
73 29 : param->accept_vis (*this);
74 28 : if (function_path.has_return_type ())
75 28 : function_path.get_return_type ().accept_vis (*this);
76 28 : }
77 :
78 : void
79 2562 : DefaultHIRVisitor::walk (TypePathSegmentGeneric &segment_generic)
80 : {
81 2562 : if (segment_generic.has_generic_args ())
82 2562 : visit_generic_args (segment_generic.get_generic_args ());
83 2562 : }
84 :
85 : void
86 51356 : DefaultHIRVisitor::walk (TypePath &type_path)
87 : {
88 104622 : for (auto &segment : type_path.get_segments ())
89 53266 : segment->accept_vis (*this);
90 51356 : }
91 :
92 : void
93 280 : DefaultHIRVisitor::visit_qualified_path_type (QualifiedPathType &path)
94 : {
95 280 : path.get_type ().accept_vis (*this);
96 280 : if (path.has_as_clause ())
97 241 : path.get_trait ().accept_vis (*this);
98 280 : }
99 :
100 : // TODO: Implement visit_path_expr_segment
101 : void
102 1537 : DefaultHIRVisitor::visit_path_expr_segment (PathExprSegment &segment)
103 : {
104 1537 : if (segment.has_generic_args ())
105 0 : visit_generic_args (segment.get_generic_args ());
106 1537 : }
107 :
108 : void
109 79 : DefaultHIRVisitor::walk (QualifiedPathInExpression &path_in_expr)
110 : {
111 79 : visit_outer_attrs (path_in_expr);
112 79 : visit_qualified_path_type (path_in_expr.get_path_type ());
113 158 : for (auto &segment : path_in_expr.get_segments ())
114 79 : visit_path_expr_segment (segment);
115 79 : }
116 :
117 : void
118 201 : DefaultHIRVisitor::walk (QualifiedPathInType &path_in_type)
119 : {
120 201 : visit_qualified_path_type (path_in_type.get_path_type ());
121 201 : path_in_type.get_associated_segment ().accept_vis (*this);
122 201 : for (auto &segment : path_in_type.get_segments ())
123 0 : segment->accept_vis (*this);
124 201 : }
125 :
126 : void
127 74 : DefaultHIRVisitor::walk (LiteralExpr &expr)
128 : {
129 74 : visit_outer_attrs (expr);
130 74 : }
131 :
132 : void
133 1298 : DefaultHIRVisitor::walk (BorrowExpr &expr)
134 : {
135 1298 : visit_outer_attrs (expr);
136 1298 : expr.get_expr ().accept_vis (*this);
137 1298 : }
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 504 : DefaultHIRVisitor::walk (NegationExpr &expr)
155 : {
156 504 : visit_outer_attrs (expr);
157 504 : expr.get_expr ().accept_vis (*this);
158 504 : }
159 :
160 : void
161 2483 : DefaultHIRVisitor::walk (ArithmeticOrLogicalExpr &expr)
162 : {
163 2483 : visit_outer_attrs (expr);
164 2483 : expr.get_lhs ().accept_vis (*this);
165 2483 : expr.get_rhs ().accept_vis (*this);
166 2483 : }
167 :
168 : void
169 3587 : DefaultHIRVisitor::walk (ComparisonExpr &expr)
170 : {
171 3587 : visit_outer_attrs (expr);
172 3587 : expr.get_lhs ().accept_vis (*this);
173 3587 : expr.get_rhs ().accept_vis (*this);
174 3587 : }
175 :
176 : void
177 370 : DefaultHIRVisitor::walk (LazyBooleanExpr &expr)
178 : {
179 370 : visit_outer_attrs (expr);
180 370 : expr.get_lhs ().accept_vis (*this);
181 370 : expr.get_rhs ().accept_vis (*this);
182 370 : }
183 :
184 : void
185 2149 : DefaultHIRVisitor::walk (TypeCastExpr &expr)
186 : {
187 2149 : visit_outer_attrs (expr);
188 2149 : expr.get_expr ().accept_vis (*this);
189 2149 : expr.get_type_to_convert_to ().accept_vis (*this);
190 2149 : }
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 682 : DefaultHIRVisitor::walk (CompoundAssignmentExpr &expr)
202 : {
203 682 : visit_outer_attrs (expr);
204 682 : expr.get_lhs ().accept_vis (*this);
205 682 : expr.get_rhs ().accept_vis (*this);
206 682 : }
207 :
208 : void
209 231 : DefaultHIRVisitor::walk (GroupedExpr &expr)
210 : {
211 231 : visit_outer_attrs (expr);
212 231 : visit_inner_attrs (expr);
213 231 : expr.get_expr_in_parens ().accept_vis (*this);
214 231 : }
215 :
216 : void
217 39 : DefaultHIRVisitor::walk (ArrayElemsValues &elems)
218 : {
219 250 : for (auto &elem : elems.get_values ())
220 211 : elem->accept_vis (*this);
221 39 : }
222 :
223 : void
224 38 : DefaultHIRVisitor::walk (ArrayElemsCopied &elems)
225 : {
226 38 : elems.get_elem_to_copy ().accept_vis (*this);
227 38 : elems.get_num_copies_expr ().accept_vis (*this);
228 38 : }
229 :
230 : void
231 77 : DefaultHIRVisitor::walk (ArrayExpr &expr)
232 : {
233 77 : visit_outer_attrs (expr);
234 77 : visit_inner_attrs (expr);
235 77 : expr.get_internal_elements ().accept_vis (*this);
236 77 : }
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 102 : DefaultHIRVisitor::walk (StructExprFieldIdentifier &)
272 102 : {}
273 :
274 : void
275 302 : DefaultHIRVisitor::walk (StructExprFieldIdentifierValue &field)
276 : {
277 302 : field.get_value ().accept_vis (*this);
278 302 : }
279 :
280 : void
281 0 : DefaultHIRVisitor::walk (StructExprFieldIndexValue &field)
282 : {
283 0 : field.get_value ().accept_vis (*this);
284 0 : }
285 :
286 : void
287 205 : DefaultHIRVisitor::walk (StructExprStructFields &expr)
288 : {
289 205 : visit_outer_attrs (expr);
290 205 : visit_inner_attrs (expr);
291 205 : expr.get_struct_name ().accept_vis (*this);
292 205 : if (expr.has_struct_base ())
293 : {
294 0 : StructBase &base = expr.get_struct_base ();
295 0 : base.get_base ().accept_vis (*this);
296 : }
297 609 : for (auto &field : expr.get_fields ())
298 404 : field->accept_vis (*this);
299 205 : }
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 9913 : DefaultHIRVisitor::walk (CallExpr &expr)
313 : {
314 9913 : visit_outer_attrs (expr);
315 9913 : expr.get_fnexpr ().accept_vis (*this);
316 20995 : for (auto &arg : expr.get_arguments ())
317 11082 : arg->accept_vis (*this);
318 9913 : }
319 :
320 : void
321 1402 : DefaultHIRVisitor::walk (MethodCallExpr &expr)
322 : {
323 1402 : visit_outer_attrs (expr);
324 1402 : expr.get_receiver ().accept_vis (*this);
325 1402 : visit_path_expr_segment (expr.get_method_name ());
326 2293 : for (auto &arg : expr.get_arguments ())
327 891 : arg->accept_vis (*this);
328 1402 : }
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 23529 : DefaultHIRVisitor::walk (BlockExpr &expr)
361 : {
362 23529 : visit_outer_attrs (expr);
363 23529 : visit_inner_attrs (expr);
364 47888 : for (auto &stmt : expr.get_statements ())
365 24359 : stmt->accept_vis (*this);
366 23529 : if (expr.has_expr ())
367 16901 : expr.get_final_expr ().accept_vis (*this);
368 23529 : }
369 :
370 : void
371 559 : DefaultHIRVisitor::walk (AnonConst &expr)
372 : {
373 559 : if (!expr.is_deferred ())
374 559 : expr.get_inner_expr ().accept_vis (*this);
375 559 : }
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 21 : DefaultHIRVisitor::walk (ContinueExpr &expr)
385 : {
386 21 : visit_outer_attrs (expr);
387 21 : if (expr.has_label ())
388 8 : expr.get_label ().accept_vis (*this);
389 21 : }
390 :
391 : void
392 75 : DefaultHIRVisitor::walk (BreakExpr &expr)
393 : {
394 75 : visit_outer_attrs (expr);
395 75 : if (expr.has_label ())
396 33 : expr.get_label ().accept_vis (*this);
397 :
398 75 : if (expr.has_break_expr ())
399 4 : expr.get_expr ().accept_vis (*this);
400 75 : }
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 (RangeToInclExpr &expr)
427 : {
428 0 : expr.get_to_expr ().accept_vis (*this);
429 0 : }
430 :
431 : void
432 4 : DefaultHIRVisitor::walk (BoxExpr &expr)
433 : {
434 4 : visit_outer_attrs (expr);
435 4 : expr.get_expr ().accept_vis (*this);
436 4 : }
437 :
438 : void
439 541 : DefaultHIRVisitor::walk (ReturnExpr &expr)
440 : {
441 541 : visit_outer_attrs (expr);
442 541 : if (expr.has_return_expr ())
443 507 : expr.get_expr ().accept_vis (*this);
444 541 : }
445 :
446 : void
447 3464 : DefaultHIRVisitor::walk (UnsafeBlockExpr &expr)
448 : {
449 3464 : visit_outer_attrs (expr);
450 3464 : expr.get_block_expr ().accept_vis (*this);
451 3464 : }
452 :
453 : void
454 55 : DefaultHIRVisitor::visit_loop_label (LoopLabel &label)
455 : {
456 55 : label.get_lifetime ().accept_vis (*this);
457 55 : }
458 :
459 : void
460 113 : DefaultHIRVisitor::walk (LoopExpr &expr)
461 : {
462 113 : visit_outer_attrs (expr);
463 113 : if (expr.has_loop_label ())
464 54 : visit_loop_label (expr.get_loop_label ());
465 113 : expr.get_loop_block ().accept_vis (*this);
466 113 : }
467 :
468 : void
469 88 : DefaultHIRVisitor::walk (WhileLoopExpr &expr)
470 : {
471 88 : visit_outer_attrs (expr);
472 88 : if (expr.has_loop_label ())
473 6 : visit_loop_label (expr.get_loop_label ());
474 88 : expr.get_predicate_expr ().accept_vis (*this);
475 88 : expr.get_loop_block ().accept_vis (*this);
476 88 : }
477 :
478 : void
479 0 : DefaultHIRVisitor::walk (WhileLetLoopExpr &expr)
480 : {
481 0 : visit_outer_attrs (expr);
482 0 : expr.get_pattern ()->accept_vis (*this);
483 0 : if (expr.has_loop_label ())
484 0 : visit_loop_label (expr.get_loop_label ());
485 0 : expr.get_cond ().accept_vis (*this);
486 0 : expr.get_loop_block ().accept_vis (*this);
487 0 : }
488 :
489 : void
490 2533 : DefaultHIRVisitor::walk (IfExpr &expr)
491 : {
492 2533 : visit_outer_attrs (expr);
493 2533 : expr.get_if_condition ().accept_vis (*this);
494 2533 : expr.get_if_block ().accept_vis (*this);
495 2533 : }
496 :
497 : void
498 1268 : DefaultHIRVisitor::walk (IfExprConseqElse &expr)
499 : {
500 1268 : expr.IfExpr::accept_vis (*this);
501 1268 : expr.get_else_block ().accept_vis (*this);
502 1268 : }
503 :
504 : void
505 2398 : DefaultHIRVisitor::visit_match_arm (MatchArm &arm)
506 : {
507 : // visit_outer_attrs (arm);
508 2398 : arm.get_pattern ()->accept_vis (*this);
509 2398 : if (arm.has_match_arm_guard ())
510 1 : arm.get_guard_expr ().accept_vis (*this);
511 2398 : }
512 :
513 : void
514 2398 : DefaultHIRVisitor::visit_match_case (MatchCase &arm)
515 : {
516 2398 : visit_match_arm (arm.get_arm ());
517 2398 : arm.get_expr ().accept_vis (*this);
518 2398 : }
519 :
520 : void
521 1021 : DefaultHIRVisitor::walk (MatchExpr &expr)
522 : {
523 1021 : visit_outer_attrs (expr);
524 1021 : visit_inner_attrs (expr);
525 1021 : expr.get_scrutinee_expr ().accept_vis (*this);
526 3419 : for (auto &arm : expr.get_match_cases ())
527 2398 : visit_match_case (arm);
528 1021 : }
529 :
530 : void
531 0 : DefaultHIRVisitor::walk (AwaitExpr &expr)
532 : {
533 0 : visit_outer_attrs (expr);
534 0 : expr.get_awaited_expr ().accept_vis (*this);
535 0 : }
536 :
537 : void
538 0 : DefaultHIRVisitor::walk (AsyncBlockExpr &expr)
539 : {
540 0 : visit_outer_attrs (expr);
541 0 : expr.get_block_expr ().accept_vis (*this);
542 0 : }
543 :
544 : void
545 24 : DefaultHIRVisitor::walk (InlineAsm &expr)
546 : {
547 24 : visit_outer_attrs (expr);
548 24 : auto &operands = expr.get_operands ();
549 24 : using RegisterType = AST::InlineAsmOperand::RegisterType;
550 53 : for (auto &operand : operands)
551 : {
552 29 : switch (operand.get_register_type ())
553 : {
554 10 : case RegisterType::In:
555 10 : {
556 10 : operand.get_in ().expr->accept_vis (*this);
557 10 : break;
558 : }
559 17 : case RegisterType::Out:
560 17 : {
561 17 : operand.get_out ().expr->accept_vis (*this);
562 17 : break;
563 : }
564 0 : case RegisterType::InOut:
565 0 : {
566 0 : operand.get_in_out ().expr->accept_vis (*this);
567 0 : break;
568 : }
569 2 : case RegisterType::SplitInOut:
570 2 : {
571 2 : operand.get_split_in_out ().in_expr->accept_vis (*this);
572 2 : operand.get_split_in_out ().out_expr->accept_vis (*this);
573 2 : break;
574 : }
575 0 : case RegisterType::Const:
576 0 : {
577 0 : operand.get_const ().anon_const.get_inner_expr ().accept_vis (
578 : *this);
579 0 : break;
580 : }
581 0 : case RegisterType::Sym:
582 0 : {
583 0 : operand.get_sym ().expr->accept_vis (*this);
584 0 : break;
585 : }
586 0 : case RegisterType::Label:
587 0 : {
588 0 : operand.get_label ().expr->accept_vis (*this);
589 0 : break;
590 : }
591 : }
592 : }
593 24 : }
594 :
595 : void
596 2 : DefaultHIRVisitor::walk (LlvmInlineAsm &expr)
597 : {
598 2 : visit_outer_attrs (expr);
599 2 : for (auto &output : expr.outputs)
600 0 : output.expr->accept_vis (*this);
601 4 : for (auto &input : expr.inputs)
602 2 : input.expr->accept_vis (*this);
603 2 : }
604 :
605 : void
606 0 : DefaultHIRVisitor::walk (OffsetOf &expr)
607 : {
608 0 : expr.get_type ().accept_vis (*this);
609 0 : }
610 :
611 : void
612 8781 : DefaultHIRVisitor::walk (TypeParam ¶m)
613 : {
614 8781 : visit_outer_attrs (param);
615 9698 : for (auto &bounds : param.get_type_param_bounds ())
616 917 : bounds->accept_vis (*this);
617 8781 : if (param.has_type ())
618 385 : param.get_type ().accept_vis (*this);
619 8781 : }
620 :
621 : void
622 0 : DefaultHIRVisitor::walk (ConstGenericParam &const_param)
623 : {
624 0 : visit_outer_attrs (const_param);
625 0 : const_param.get_type ().accept_vis (*this);
626 0 : if (const_param.has_default_expression ())
627 0 : const_param.get_default_expression ().accept_vis (*this);
628 0 : }
629 :
630 : void
631 0 : DefaultHIRVisitor::walk (LifetimeWhereClauseItem &item)
632 : {
633 0 : item.get_lifetime ().accept_vis (*this);
634 0 : for (auto &bound : item.get_lifetime_bounds ())
635 0 : bound.accept_vis (*this);
636 0 : }
637 :
638 : void
639 343 : DefaultHIRVisitor::walk (TypeBoundWhereClauseItem &item)
640 : {
641 350 : for (auto &lifetime : item.get_for_lifetimes ())
642 7 : lifetime.accept_vis (*this);
643 343 : item.get_bound_type ().accept_vis (*this);
644 686 : for (auto ¶m : item.get_type_param_bounds ())
645 343 : param->accept_vis (*this);
646 343 : }
647 :
648 : void
649 1203 : DefaultHIRVisitor::walk (Module &module)
650 : {
651 1203 : visit_outer_attrs (module);
652 1203 : visit_inner_attrs (module);
653 5102 : for (auto &item : module.get_items ())
654 3899 : item->accept_vis (*this);
655 1203 : }
656 :
657 : void
658 0 : DefaultHIRVisitor::walk (ExternCrate &crate)
659 : {
660 0 : visit_outer_attrs (crate);
661 0 : }
662 :
663 : void
664 0 : DefaultHIRVisitor::walk (UseTreeGlob &)
665 0 : {}
666 :
667 : void
668 0 : DefaultHIRVisitor::walk (UseTreeList &)
669 0 : {}
670 :
671 : void
672 0 : DefaultHIRVisitor::walk (UseTreeRebind &)
673 0 : {}
674 :
675 : void
676 0 : DefaultHIRVisitor::walk (UseDeclaration &)
677 0 : {}
678 :
679 : void
680 8744 : DefaultHIRVisitor::visit_function_param (FunctionParam ¶m)
681 : {
682 8744 : param.get_param_name ().accept_vis (*this);
683 8744 : param.get_type ().accept_vis (*this);
684 8744 : }
685 :
686 : void
687 14146 : DefaultHIRVisitor::walk (Function &function)
688 : {
689 14146 : visit_outer_attrs (function);
690 14969 : for (auto &generic : function.get_generic_params ())
691 823 : generic->accept_vis (*this);
692 21193 : for (auto ¶m : function.get_function_params ())
693 7047 : visit_function_param (param);
694 14146 : if (function.has_return_type ())
695 10539 : function.get_return_type ().accept_vis (*this);
696 14146 : if (function.has_where_clause ())
697 37 : visit_where_clause (function.get_where_clause ());
698 14146 : function.get_definition ().accept_vis (*this);
699 14146 : }
700 :
701 : void
702 1450 : DefaultHIRVisitor::walk (TypeAlias &type_alias)
703 : {
704 1450 : visit_outer_attrs (type_alias);
705 1473 : for (auto &generic : type_alias.get_generic_params ())
706 23 : generic->accept_vis (*this);
707 1450 : if (type_alias.has_where_clause ())
708 0 : visit_where_clause (type_alias.get_where_clause ());
709 1450 : type_alias.get_type_aliased ().accept_vis (*this);
710 1450 : }
711 :
712 : void
713 2162 : DefaultHIRVisitor::visit_struct_field (StructField &field)
714 : {
715 2162 : field.get_field_type ().accept_vis (*this);
716 2162 : }
717 :
718 : void
719 1565 : DefaultHIRVisitor::walk (StructStruct &struct_item)
720 : {
721 1565 : visit_outer_attrs (struct_item);
722 2086 : for (auto &generic : struct_item.get_generic_params ())
723 521 : generic->accept_vis (*this);
724 1565 : if (struct_item.has_where_clause ())
725 3 : visit_where_clause (struct_item.get_where_clause ());
726 3432 : for (auto &field : struct_item.get_fields ())
727 1867 : visit_struct_field (field);
728 1565 : }
729 :
730 : void
731 967 : DefaultHIRVisitor::walk (TupleStruct &tuple_struct)
732 : {
733 967 : visit_outer_attrs (tuple_struct);
734 1328 : for (auto &generic : tuple_struct.get_generic_params ())
735 361 : generic->accept_vis (*this);
736 967 : if (tuple_struct.has_where_clause ())
737 0 : visit_where_clause (tuple_struct.get_where_clause ());
738 2643 : for (auto &field : tuple_struct.get_fields ())
739 1676 : field.get_field_type ().accept_vis (*this);
740 967 : }
741 :
742 : void
743 1213 : DefaultHIRVisitor::walk (EnumItem &item)
744 : {
745 1213 : visit_outer_attrs (item);
746 1213 : }
747 :
748 : void
749 413 : DefaultHIRVisitor::walk (EnumItemTuple &item_tuple)
750 : {
751 413 : item_tuple.EnumItem::accept_vis (*this);
752 849 : for (auto &field : item_tuple.get_tuple_fields ())
753 436 : field.get_field_type ().accept_vis (*this);
754 413 : }
755 :
756 : void
757 79 : DefaultHIRVisitor::walk (EnumItemStruct &item_struct)
758 : {
759 79 : item_struct.EnumItem::accept_vis (*this);
760 209 : for (auto &field : item_struct.get_struct_fields ())
761 130 : field.get_field_type ().accept_vis (*this);
762 79 : }
763 :
764 : void
765 285 : DefaultHIRVisitor::walk (EnumItemDiscriminant &item)
766 : {
767 285 : item.EnumItem::accept_vis (*this);
768 285 : item.get_discriminant_expression ().accept_vis (*this);
769 285 : }
770 :
771 : void
772 522 : DefaultHIRVisitor::walk (Enum &enum_item)
773 : {
774 522 : visit_outer_attrs (enum_item);
775 812 : for (auto &generic : enum_item.get_generic_params ())
776 290 : generic->accept_vis (*this);
777 522 : if (enum_item.has_where_clause ())
778 0 : visit_where_clause (enum_item.get_where_clause ());
779 1735 : for (auto &item : enum_item.get_variants ())
780 1213 : item->accept_vis (*this);
781 522 : }
782 :
783 : void
784 101 : DefaultHIRVisitor::walk (Union &union_item)
785 : {
786 101 : visit_outer_attrs (union_item);
787 175 : for (auto &generic : union_item.get_generic_params ())
788 74 : generic->accept_vis (*this);
789 101 : if (union_item.has_where_clause ())
790 0 : visit_where_clause (union_item.get_where_clause ());
791 396 : for (auto &variant : union_item.get_variants ())
792 295 : visit_struct_field (variant);
793 101 : }
794 :
795 : void
796 521 : DefaultHIRVisitor::walk (ConstantItem &const_item)
797 : {
798 521 : visit_outer_attrs (const_item);
799 521 : const_item.get_type ().accept_vis (*this);
800 521 : const_item.get_expr ().accept_vis (*this);
801 521 : }
802 :
803 : void
804 55 : DefaultHIRVisitor::walk (StaticItem &static_item)
805 : {
806 55 : visit_outer_attrs (static_item);
807 55 : static_item.get_type ().accept_vis (*this);
808 55 : static_item.get_expr ().accept_vis (*this);
809 55 : }
810 :
811 : void
812 2338 : DefaultHIRVisitor::visit_self_param (SelfParam &self_param)
813 : {
814 2338 : if (self_param.has_lifetime ())
815 : {
816 1745 : Lifetime lifetime = self_param.get_lifetime ();
817 1745 : lifetime.accept_vis (*this);
818 1745 : }
819 2338 : if (self_param.has_type ())
820 1 : self_param.get_type ().accept_vis (*this);
821 2338 : }
822 :
823 : void
824 2653 : DefaultHIRVisitor::walk (TraitItemFunc &item)
825 : {
826 2653 : visit_outer_attrs (item);
827 2653 : TraitFunctionDecl &decl = item.get_decl ();
828 2680 : for (auto &generic : decl.get_generic_params ())
829 27 : generic->accept_vis (*this);
830 2653 : if (decl.get_self ().has_value ())
831 2338 : visit_self_param (decl.get_self ().value ());
832 4350 : for (auto ¶m : decl.get_function_params ())
833 1697 : visit_function_param (param);
834 2653 : if (decl.has_return_type ())
835 2218 : decl.get_return_type ().accept_vis (*this);
836 2653 : if (decl.has_where_clause ())
837 174 : visit_where_clause (decl.get_where_clause ());
838 2653 : if (item.has_definition ())
839 852 : item.get_block_expr ().accept_vis (*this);
840 2653 : }
841 :
842 : void
843 31 : DefaultHIRVisitor::walk (TraitItemConst &item)
844 : {
845 31 : visit_outer_attrs (item);
846 31 : item.get_type ().accept_vis (*this);
847 31 : if (item.has_expr ())
848 7 : item.get_expr ().accept_vis (*this);
849 31 : }
850 :
851 : void
852 781 : DefaultHIRVisitor::walk (TraitItemType &item)
853 : {
854 781 : visit_outer_attrs (item);
855 827 : for (auto &bound : item.get_type_param_bounds ())
856 46 : bound->accept_vis (*this);
857 781 : }
858 :
859 : void
860 0 : DefaultHIRVisitor::visit_where_clause (const WhereClause &where_clause)
861 : {
862 0 : for (auto &item : where_clause.get_items ())
863 0 : item->accept_vis (*this);
864 0 : }
865 :
866 : void
867 319 : DefaultHIRVisitor::visit_where_clause (WhereClause &where_clause)
868 : {
869 662 : for (auto &item : where_clause.get_items ())
870 : {
871 343 : item->accept_vis (*this);
872 : }
873 319 : }
874 :
875 : void
876 0 : DefaultHIRVisitor::walk (WhereClauseItem &node)
877 0 : {}
878 :
879 : void
880 3944 : DefaultHIRVisitor::walk (Trait &trait)
881 : {
882 3944 : visit_outer_attrs (trait);
883 8577 : for (auto &generic : trait.get_generic_params ())
884 4633 : generic->accept_vis (*this);
885 3944 : if (trait.has_where_clause ())
886 7 : visit_where_clause (trait.get_where_clause ());
887 4556 : for (auto &bound : trait.get_type_param_bounds ())
888 612 : bound->accept_vis (*this);
889 7412 : for (auto &item : trait.get_trait_items ())
890 3468 : item->accept_vis (*this);
891 3944 : }
892 :
893 : void
894 6030 : DefaultHIRVisitor::walk (ImplBlock &impl)
895 : {
896 6030 : visit_outer_attrs (impl);
897 7198 : for (auto &generic : impl.get_generic_params ())
898 1168 : generic->accept_vis (*this);
899 6030 : if (impl.has_trait_ref ())
900 5028 : impl.get_trait_ref ().accept_vis (*this);
901 6030 : impl.get_type ().accept_vis (*this);
902 6030 : if (impl.has_where_clause ())
903 98 : visit_where_clause (impl.get_where_clause ());
904 6030 : visit_inner_attrs (impl);
905 15085 : for (auto &item : impl.get_impl_items ())
906 9055 : item->accept_vis (*this);
907 6030 : }
908 :
909 : void
910 0 : DefaultHIRVisitor::walk (ExternalStaticItem &item)
911 : {
912 0 : visit_outer_attrs (item);
913 0 : item.get_item_type ().accept_vis (*this);
914 0 : }
915 :
916 : void
917 3009 : DefaultHIRVisitor::visit_named_function_param (NamedFunctionParam ¶m)
918 : {
919 3009 : param.get_type ().accept_vis (*this);
920 3009 : }
921 :
922 : void
923 2618 : DefaultHIRVisitor::walk (ExternalFunctionItem &item)
924 : {
925 2618 : visit_outer_attrs (item);
926 3707 : for (auto &generic : item.get_generic_params ())
927 1089 : generic->accept_vis (*this);
928 5627 : for (auto ¶m : item.get_function_params ())
929 3009 : visit_named_function_param (param);
930 2618 : if (item.has_return_type ())
931 1361 : item.get_return_type ().accept_vis (*this);
932 2618 : if (item.has_where_clause ())
933 0 : visit_where_clause (item.get_where_clause ());
934 2618 : }
935 :
936 : void
937 2 : DefaultHIRVisitor::walk (ExternalTypeItem &item)
938 : {
939 2 : visit_outer_attrs (item);
940 2 : }
941 :
942 : void
943 1671 : DefaultHIRVisitor::walk (ExternBlock &block)
944 : {
945 1671 : visit_outer_attrs (block);
946 1671 : visit_inner_attrs (block);
947 4291 : for (auto &item : block.get_extern_items ())
948 2620 : item->accept_vis (*this);
949 1671 : }
950 :
951 : void
952 410 : DefaultHIRVisitor::walk (LiteralPattern &)
953 410 : {}
954 :
955 : void
956 9318 : DefaultHIRVisitor::walk (IdentifierPattern &pattern)
957 : {
958 9318 : if (pattern.has_subpattern ())
959 11 : pattern.get_subpattern ().accept_vis (*this);
960 9318 : }
961 :
962 : void
963 779 : DefaultHIRVisitor::walk (WildcardPattern &)
964 779 : {}
965 :
966 : void
967 77 : DefaultHIRVisitor::walk (RangePatternBoundLiteral &)
968 77 : {}
969 :
970 : void
971 21 : DefaultHIRVisitor::walk (RangePatternBoundPath &bound)
972 : {
973 21 : bound.get_path ().accept_vis (*this);
974 21 : }
975 :
976 : void
977 0 : DefaultHIRVisitor::walk (RangePatternBoundQualPath &bound)
978 : {
979 0 : bound.get_qualified_path ().accept_vis (*this);
980 0 : }
981 :
982 : void
983 49 : DefaultHIRVisitor::walk (RangePattern &pattern)
984 : {
985 49 : pattern.get_lower_bound ().accept_vis (*this);
986 49 : pattern.get_upper_bound ().accept_vis (*this);
987 49 : }
988 :
989 : void
990 175 : DefaultHIRVisitor::walk (ReferencePattern &pattern)
991 : {
992 175 : pattern.get_referenced_pattern ().accept_vis (*this);
993 175 : }
994 :
995 : void
996 18 : DefaultHIRVisitor::walk (StructPatternFieldTuplePat &field)
997 : {
998 18 : visit_outer_attrs (field);
999 18 : field.get_tuple_pattern ().accept_vis (*this);
1000 18 : }
1001 :
1002 : void
1003 120 : DefaultHIRVisitor::walk (StructPatternFieldIdentPat &field)
1004 : {
1005 120 : visit_outer_attrs (field);
1006 120 : field.get_pattern ().accept_vis (*this);
1007 120 : }
1008 :
1009 : void
1010 93 : DefaultHIRVisitor::walk (StructPatternFieldIdent &field)
1011 : {
1012 93 : visit_outer_attrs (field);
1013 93 : }
1014 :
1015 : void
1016 137 : DefaultHIRVisitor::walk (StructPattern &pattern)
1017 : {
1018 137 : pattern.get_path ().accept_vis (*this);
1019 137 : StructPatternElements &elements = pattern.get_struct_pattern_elems ();
1020 370 : for (auto &field : elements.get_struct_pattern_fields ())
1021 233 : field->accept_vis (*this);
1022 137 : }
1023 :
1024 : void
1025 902 : DefaultHIRVisitor::walk (TupleStructItemsNoRest &tuple_items)
1026 : {
1027 1892 : for (auto &item : tuple_items.get_patterns ())
1028 990 : item->accept_vis (*this);
1029 902 : }
1030 :
1031 : void
1032 36 : DefaultHIRVisitor::walk (TupleStructItemsHasRest &tuple_items)
1033 : {
1034 65 : for (auto &lower : tuple_items.get_lower_patterns ())
1035 29 : lower->accept_vis (*this);
1036 50 : for (auto &upper : tuple_items.get_upper_patterns ())
1037 14 : upper->accept_vis (*this);
1038 36 : }
1039 :
1040 : void
1041 938 : DefaultHIRVisitor::walk (TupleStructPattern &pattern)
1042 : {
1043 938 : pattern.get_path ().accept_vis (*this);
1044 938 : pattern.get_items ().accept_vis (*this);
1045 938 : }
1046 :
1047 : void
1048 113 : DefaultHIRVisitor::walk (TuplePatternItemsNoRest &tuple_items)
1049 : {
1050 346 : for (auto &pattern : tuple_items.get_patterns ())
1051 233 : pattern->accept_vis (*this);
1052 113 : }
1053 :
1054 : void
1055 26 : DefaultHIRVisitor::walk (TuplePatternItemsHasRest &tuple_items)
1056 : {
1057 50 : for (auto &lower : tuple_items.get_lower_patterns ())
1058 24 : lower->accept_vis (*this);
1059 49 : for (auto &upper : tuple_items.get_upper_patterns ())
1060 23 : upper->accept_vis (*this);
1061 26 : }
1062 :
1063 : void
1064 139 : DefaultHIRVisitor::walk (TuplePattern &pattern)
1065 : {
1066 139 : pattern.get_items ().accept_vis (*this);
1067 139 : }
1068 :
1069 : void
1070 31 : DefaultHIRVisitor::walk (SlicePatternItemsNoRest &items)
1071 : {
1072 92 : for (auto &pattern : items.get_patterns ())
1073 61 : pattern->accept_vis (*this);
1074 31 : }
1075 :
1076 : void
1077 44 : DefaultHIRVisitor::walk (SlicePatternItemsHasRest &items)
1078 : {
1079 87 : for (auto &lower : items.get_lower_patterns ())
1080 43 : lower->accept_vis (*this);
1081 44 : if (items.has_rest_bind ())
1082 0 : items.get_rest_bind ().accept_vis (*this);
1083 87 : for (auto &upper : items.get_upper_patterns ())
1084 43 : upper->accept_vis (*this);
1085 44 : }
1086 :
1087 : void
1088 75 : DefaultHIRVisitor::walk (SlicePattern &pattern)
1089 : {
1090 75 : pattern.get_items ().accept_vis (*this);
1091 75 : }
1092 :
1093 : void
1094 145 : DefaultHIRVisitor::walk (AltPattern &pattern)
1095 : {
1096 436 : for (auto &item : pattern.get_alts ())
1097 291 : item->accept_vis (*this);
1098 145 : }
1099 :
1100 : void
1101 46 : DefaultHIRVisitor::walk (EmptyStmt &stmt)
1102 46 : {}
1103 :
1104 : void
1105 30 : DefaultHIRVisitor::walk (LetStmt &stmt)
1106 : {
1107 30 : visit_outer_attrs (stmt);
1108 30 : stmt.get_pattern ().accept_vis (*this);
1109 30 : if (stmt.has_type ())
1110 0 : stmt.get_type ().accept_vis (*this);
1111 30 : if (stmt.has_init_expr ())
1112 28 : stmt.get_init_expr ().accept_vis (*this);
1113 30 : }
1114 :
1115 : void
1116 10959 : DefaultHIRVisitor::walk (ExprStmt &stmt)
1117 : {
1118 10959 : stmt.get_expr ().accept_vis (*this);
1119 10959 : }
1120 :
1121 : void
1122 2054 : DefaultHIRVisitor::walk (TraitBound &bound)
1123 : {
1124 2061 : for (auto &lifetime : bound.get_for_lifetimes ())
1125 7 : lifetime.accept_vis (*this);
1126 2054 : bound.get_path ().accept_vis (*this);
1127 2054 : }
1128 :
1129 : void
1130 36 : DefaultHIRVisitor::walk (ImplTraitType &type)
1131 : {
1132 73 : for (auto &bound : type.get_type_param_bounds ())
1133 37 : bound->accept_vis (*this);
1134 36 : }
1135 :
1136 : void
1137 98 : DefaultHIRVisitor::walk (TraitObjectType &type)
1138 : {
1139 208 : for (auto &bound : type.get_type_param_bounds ())
1140 110 : bound->accept_vis (*this);
1141 98 : }
1142 :
1143 : void
1144 4 : DefaultHIRVisitor::walk (ParenthesisedType &type)
1145 : {
1146 4 : type.get_type_in_parens ().accept_vis (*this);
1147 4 : }
1148 :
1149 : void
1150 378 : DefaultHIRVisitor::walk (TupleType &type)
1151 : {
1152 1011 : for (auto &elem : type.get_elems ())
1153 633 : elem->accept_vis (*this);
1154 378 : }
1155 :
1156 : void
1157 192 : DefaultHIRVisitor::walk (NeverType &type)
1158 192 : {}
1159 :
1160 : void
1161 4271 : DefaultHIRVisitor::walk (RawPointerType &type)
1162 : {
1163 4271 : type.get_type ().accept_vis (*this);
1164 4271 : }
1165 :
1166 : void
1167 4206 : DefaultHIRVisitor::walk (ReferenceType &type)
1168 : {
1169 4206 : if (type.has_lifetime ())
1170 4206 : type.get_lifetime ().accept_vis (*this);
1171 4206 : type.get_base_type ().accept_vis (*this);
1172 4206 : }
1173 :
1174 : void
1175 552 : DefaultHIRVisitor::walk (ArrayType &type)
1176 : {
1177 552 : type.get_element_type ().accept_vis (*this);
1178 552 : type.get_size_expr ().accept_vis (*this);
1179 552 : }
1180 :
1181 : void
1182 862 : DefaultHIRVisitor::walk (SliceType &type)
1183 : {
1184 862 : type.get_element_type ().accept_vis (*this);
1185 862 : }
1186 :
1187 : void
1188 14 : DefaultHIRVisitor::walk (InferredType &type)
1189 14 : {}
1190 :
1191 : void
1192 35 : DefaultHIRVisitor::walk (BareFunctionType &type)
1193 : {
1194 35 : for (auto &lifetime : type.get_for_lifetimes ())
1195 0 : lifetime.accept_vis (*this);
1196 58 : for (auto ¶m : type.get_function_params ())
1197 23 : param.get_type ().accept_vis (*this);
1198 35 : if (type.has_return_type ())
1199 23 : type.get_return_type ().accept_vis (*this);
1200 35 : }
1201 :
1202 : } // namespace HIR
1203 : } // namespace Rust
|