par_sco.adb, [...]: Minor reformatting.
[gcc.git] / gcc / ada / lib-xref.adb
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- L I B . X R E F --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1998-2011, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
25
26 with Atree; use Atree;
27 with Csets; use Csets;
28 with Elists; use Elists;
29 with Errout; use Errout;
30 with Nlists; use Nlists;
31 with Opt; use Opt;
32 with Restrict; use Restrict;
33 with Rident; use Rident;
34 with Sem; use Sem;
35 with Sem_Aux; use Sem_Aux;
36 with Sem_Prag; use Sem_Prag;
37 with Sem_Util; use Sem_Util;
38 with Sem_Warn; use Sem_Warn;
39 with Sinfo; use Sinfo;
40 with Sinput; use Sinput;
41 with Snames; use Snames;
42 with Stringt; use Stringt;
43 with Stand; use Stand;
44 with Table; use Table;
45
46 with GNAT.Heap_Sort_G;
47
48 package body Lib.Xref is
49
50 ------------------
51 -- Declarations --
52 ------------------
53
54 -- The Xref table is used to record references. The Loc field is set
55 -- to No_Location for a definition entry.
56
57 subtype Xref_Entry_Number is Int;
58
59 type Xref_Entry is record
60 Ent : Entity_Id;
61 -- Entity referenced (E parameter to Generate_Reference)
62
63 Def : Source_Ptr;
64 -- Original source location for entity being referenced. Note that these
65 -- values are used only during the output process, they are not set when
66 -- the entries are originally built. This is because private entities
67 -- can be swapped when the initial call is made.
68
69 Loc : Source_Ptr;
70 -- Location of reference (Original_Location (Sloc field of N parameter
71 -- to Generate_Reference). Set to No_Location for the case of a
72 -- defining occurrence.
73
74 Typ : Character;
75 -- Reference type (Typ param to Generate_Reference)
76
77 Eun : Unit_Number_Type;
78 -- Unit number corresponding to Ent
79
80 Lun : Unit_Number_Type;
81 -- Unit number corresponding to Loc. Value is undefined and not
82 -- referenced if Loc is set to No_Location.
83
84 -- The following components are only used for ALFA cross-references
85
86 Ref_Scope : Entity_Id;
87 -- Entity of the closest subprogram or package enclosing the reference
88
89 Ent_Scope : Entity_Id;
90 -- Entity of the closest subprogram or package enclosing the definition,
91 -- which should be located in the same file as the definition itself.
92
93 Ent_Scope_File : Unit_Number_Type;
94 -- File for entity Ent_Scope
95 end record;
96
97 package Xrefs is new Table.Table (
98 Table_Component_Type => Xref_Entry,
99 Table_Index_Type => Xref_Entry_Number,
100 Table_Low_Bound => 1,
101 Table_Initial => Alloc.Xrefs_Initial,
102 Table_Increment => Alloc.Xrefs_Increment,
103 Table_Name => "Xrefs");
104
105 ----------------------
106 -- ALFA Information --
107 ----------------------
108
109 package body ALFA is separate;
110
111 ------------------------
112 -- Local Subprograms --
113 ------------------------
114
115 function Enclosing_Subprogram_Or_Package (N : Node_Id) return Entity_Id;
116 -- Return the closest enclosing subprogram of package
117
118 procedure Generate_Prim_Op_References (Typ : Entity_Id);
119 -- For a tagged type, generate implicit references to its primitive
120 -- operations, for source navigation. This is done right before emitting
121 -- cross-reference information rather than at the freeze point of the type
122 -- in order to handle late bodies that are primitive operations.
123
124 function Lt (T1, T2 : Xref_Entry) return Boolean;
125 -- Order cross-references
126
127 -------------------------------------
128 -- Enclosing_Subprogram_Or_Package --
129 -------------------------------------
130
131 function Enclosing_Subprogram_Or_Package (N : Node_Id) return Entity_Id is
132 Result : Entity_Id;
133
134 begin
135 -- If N is the defining identifier for a subprogram, then return the
136 -- enclosing subprogram or package, not this subprogram.
137
138 if Nkind_In (N, N_Defining_Identifier, N_Defining_Operator_Symbol)
139 and then Nkind (Parent (N)) in N_Subprogram_Specification
140 then
141 Result := Parent (Parent (Parent (N)));
142 else
143 Result := N;
144 end if;
145
146 loop
147 exit when No (Result);
148
149 case Nkind (Result) is
150 when N_Package_Specification =>
151 Result := Defining_Unit_Name (Result);
152 exit;
153
154 when N_Package_Body =>
155 Result := Defining_Unit_Name (Result);
156 exit;
157
158 when N_Subprogram_Specification =>
159 Result := Defining_Unit_Name (Result);
160 exit;
161
162 when N_Subprogram_Declaration =>
163 Result := Defining_Unit_Name (Specification (Result));
164 exit;
165
166 when N_Subprogram_Body =>
167 Result := Defining_Unit_Name (Specification (Result));
168 exit;
169
170 -- The enclosing subprogram for a pre- or postconditions should be
171 -- the subprogram to which the pragma is attached. This is not
172 -- always the case in the AST, as the pragma may be declared after
173 -- the declaration of the subprogram. Return Empty in this case.
174
175 when N_Pragma =>
176 if Get_Pragma_Id (Result) = Pragma_Precondition
177 or else
178 Get_Pragma_Id (Result) = Pragma_Postcondition
179 then
180 return Empty;
181 else
182 Result := Parent (Result);
183 end if;
184
185 when others =>
186 Result := Parent (Result);
187 end case;
188 end loop;
189
190 if Nkind (Result) = N_Defining_Program_Unit_Name then
191 Result := Defining_Identifier (Result);
192 end if;
193
194 -- Do no return a scope without a proper location
195
196 if Present (Result)
197 and then Sloc (Result) = No_Location
198 then
199 return Empty;
200 end if;
201
202 return Result;
203 end Enclosing_Subprogram_Or_Package;
204
205 -------------------------
206 -- Generate_Definition --
207 -------------------------
208
209 procedure Generate_Definition (E : Entity_Id) is
210 Loc : Source_Ptr;
211 Indx : Nat;
212
213 begin
214 pragma Assert (Nkind (E) in N_Entity);
215
216 -- Note that we do not test Xref_Entity_Letters here. It is too early
217 -- to do so, since we are often called before the entity is fully
218 -- constructed, so that the Ekind is still E_Void.
219
220 if Opt.Xref_Active
221
222 -- Definition must come from source
223
224 -- We make an exception for subprogram child units that have no spec.
225 -- For these we generate a subprogram declaration for library use,
226 -- and the corresponding entity does not come from source.
227 -- Nevertheless, all references will be attached to it and we have
228 -- to treat is as coming from user code.
229
230 and then (Comes_From_Source (E) or else Is_Child_Unit (E))
231
232 -- And must have a reasonable source location that is not
233 -- within an instance (all entities in instances are ignored)
234
235 and then Sloc (E) > No_Location
236 and then Instantiation_Location (Sloc (E)) = No_Location
237
238 -- And must be a non-internal name from the main source unit
239
240 and then In_Extended_Main_Source_Unit (E)
241 and then not Is_Internal_Name (Chars (E))
242 then
243 Xrefs.Increment_Last;
244 Indx := Xrefs.Last;
245 Loc := Original_Location (Sloc (E));
246
247 Xrefs.Table (Indx).Ent := E;
248 Xrefs.Table (Indx).Typ := ' ';
249 Xrefs.Table (Indx).Def := No_Location;
250 Xrefs.Table (Indx).Loc := No_Location;
251
252 Xrefs.Table (Indx).Eun := Get_Source_Unit (Loc);
253
254 Xrefs.Table (Indx).Ref_Scope := Empty;
255 Xrefs.Table (Indx).Ent_Scope := Empty;
256 Xrefs.Table (Indx).Ent_Scope_File := No_Unit;
257
258 Set_Has_Xref_Entry (E);
259
260 if In_Inlined_Body then
261 Set_Referenced (E);
262 end if;
263 end if;
264 end Generate_Definition;
265
266 ---------------------------------
267 -- Generate_Operator_Reference --
268 ---------------------------------
269
270 procedure Generate_Operator_Reference
271 (N : Node_Id;
272 T : Entity_Id)
273 is
274 begin
275 if not In_Extended_Main_Source_Unit (N) then
276 return;
277 end if;
278
279 -- If the operator is not a Standard operator, then we generate a real
280 -- reference to the user defined operator.
281
282 if Sloc (Entity (N)) /= Standard_Location then
283 Generate_Reference (Entity (N), N);
284
285 -- A reference to an implicit inequality operator is also a reference
286 -- to the user-defined equality.
287
288 if Nkind (N) = N_Op_Ne
289 and then not Comes_From_Source (Entity (N))
290 and then Present (Corresponding_Equality (Entity (N)))
291 then
292 Generate_Reference (Corresponding_Equality (Entity (N)), N);
293 end if;
294
295 -- For the case of Standard operators, we mark the result type as
296 -- referenced. This ensures that in the case where we are using a
297 -- derived operator, we mark an entity of the unit that implicitly
298 -- defines this operator as used. Otherwise we may think that no entity
299 -- of the unit is used. The actual entity marked as referenced is the
300 -- first subtype, which is the relevant user defined entity.
301
302 -- Note: we only do this for operators that come from source. The
303 -- generated code sometimes reaches for entities that do not need to be
304 -- explicitly visible (for example, when we expand the code for
305 -- comparing two record objects, the fields of the record may not be
306 -- visible).
307
308 elsif Comes_From_Source (N) then
309 Set_Referenced (First_Subtype (T));
310 end if;
311 end Generate_Operator_Reference;
312
313 ---------------------------------
314 -- Generate_Prim_Op_References --
315 ---------------------------------
316
317 procedure Generate_Prim_Op_References (Typ : Entity_Id) is
318 Base_T : Entity_Id;
319 Prim : Elmt_Id;
320 Prim_List : Elist_Id;
321
322 begin
323 -- Handle subtypes of synchronized types
324
325 if Ekind (Typ) = E_Protected_Subtype
326 or else Ekind (Typ) = E_Task_Subtype
327 then
328 Base_T := Etype (Typ);
329 else
330 Base_T := Typ;
331 end if;
332
333 -- References to primitive operations are only relevant for tagged types
334
335 if not Is_Tagged_Type (Base_T)
336 or else Is_Class_Wide_Type (Base_T)
337 then
338 return;
339 end if;
340
341 -- Ada 2005 (AI-345): For synchronized types generate reference to the
342 -- wrapper that allow us to dispatch calls through their implemented
343 -- abstract interface types.
344
345 -- The check for Present here is to protect against previously reported
346 -- critical errors.
347
348 Prim_List := Primitive_Operations (Base_T);
349
350 if No (Prim_List) then
351 return;
352 end if;
353
354 Prim := First_Elmt (Prim_List);
355 while Present (Prim) loop
356
357 -- If the operation is derived, get the original for cross-reference
358 -- reference purposes (it is the original for which we want the xref
359 -- and for which the comes_from_source test must be performed).
360
361 Generate_Reference
362 (Typ, Ultimate_Alias (Node (Prim)), 'p', Set_Ref => False);
363 Next_Elmt (Prim);
364 end loop;
365 end Generate_Prim_Op_References;
366
367 ------------------------
368 -- Generate_Reference --
369 ------------------------
370
371 procedure Generate_Reference
372 (E : Entity_Id;
373 N : Node_Id;
374 Typ : Character := 'r';
375 Set_Ref : Boolean := True;
376 Force : Boolean := False)
377 is
378 Indx : Nat;
379 Nod : Node_Id;
380 Ref : Source_Ptr;
381 Def : Source_Ptr;
382 Ent : Entity_Id;
383
384 Ref_Scope : Entity_Id;
385 Ent_Scope : Entity_Id;
386
387 Call : Node_Id;
388 Formal : Entity_Id;
389 -- Used for call to Find_Actual
390
391 Kind : Entity_Kind;
392 -- If Formal is non-Empty, then its Ekind, otherwise E_Void
393
394 function Is_On_LHS (Node : Node_Id) return Boolean;
395 -- Used to check if a node is on the left hand side of an assignment.
396 -- The following cases are handled:
397 --
398 -- Variable Node is a direct descendant of left hand side of an
399 -- assignment statement.
400 --
401 -- Prefix Of an indexed or selected component that is present in
402 -- a subtree rooted by an assignment statement. There is
403 -- no restriction of nesting of components, thus cases
404 -- such as A.B (C).D are handled properly. However a prefix
405 -- of a dereference (either implicit or explicit) is never
406 -- considered as on a LHS.
407 --
408 -- Out param Same as above cases, but OUT parameter
409
410 function OK_To_Set_Referenced return Boolean;
411 -- Returns True if the Referenced flag can be set. There are a few
412 -- exceptions where we do not want to set this flag, see body for
413 -- details of these exceptional cases.
414
415 ---------------
416 -- Is_On_LHS --
417 ---------------
418
419 -- ??? There are several routines here and there that perform a similar
420 -- (but subtly different) computation, which should be factored:
421
422 -- Sem_Util.May_Be_Lvalue
423 -- Sem_Util.Known_To_Be_Assigned
424 -- Exp_Ch2.Expand_Entry_Parameter.In_Assignment_Context
425 -- Exp_Smem.Is_Out_Actual
426
427 function Is_On_LHS (Node : Node_Id) return Boolean is
428 N : Node_Id;
429 P : Node_Id;
430 K : Node_Kind;
431
432 begin
433 -- Only identifiers are considered, is this necessary???
434
435 if Nkind (Node) /= N_Identifier then
436 return False;
437 end if;
438
439 -- Immediate return if appeared as OUT parameter
440
441 if Kind = E_Out_Parameter then
442 return True;
443 end if;
444
445 -- Search for assignment statement subtree root
446
447 N := Node;
448 loop
449 P := Parent (N);
450 K := Nkind (P);
451
452 if K = N_Assignment_Statement then
453 return Name (P) = N;
454
455 -- Check whether the parent is a component and the current node is
456 -- its prefix, but return False if the current node has an access
457 -- type, as in that case the selected or indexed component is an
458 -- implicit dereference, and the LHS is the designated object, not
459 -- the access object.
460
461 -- ??? case of a slice assignment?
462
463 -- ??? Note that in some cases this is called too early
464 -- (see comments in Sem_Ch8.Find_Direct_Name), at a point where
465 -- the tree is not fully typed yet. In that case we may lack
466 -- an Etype for N, and we must disable the check for an implicit
467 -- dereference. If the dereference is on an LHS, this causes a
468 -- false positive.
469
470 elsif (K = N_Selected_Component or else K = N_Indexed_Component)
471 and then Prefix (P) = N
472 and then not (Present (Etype (N))
473 and then
474 Is_Access_Type (Etype (N)))
475 then
476 N := P;
477
478 -- All other cases, definitely not on left side
479
480 else
481 return False;
482 end if;
483 end loop;
484 end Is_On_LHS;
485
486 ---------------------------
487 -- OK_To_Set_Referenced --
488 ---------------------------
489
490 function OK_To_Set_Referenced return Boolean is
491 P : Node_Id;
492
493 begin
494 -- A reference from a pragma Unreferenced or pragma Unmodified or
495 -- pragma Warnings does not cause the Referenced flag to be set.
496 -- This avoids silly warnings about things being referenced and
497 -- not assigned when the only reference is from the pragma.
498
499 if Nkind (N) = N_Identifier then
500 P := Parent (N);
501
502 if Nkind (P) = N_Pragma_Argument_Association then
503 P := Parent (P);
504
505 if Nkind (P) = N_Pragma then
506 if Pragma_Name (P) = Name_Warnings
507 or else
508 Pragma_Name (P) = Name_Unmodified
509 or else
510 Pragma_Name (P) = Name_Unreferenced
511 then
512 return False;
513 end if;
514 end if;
515 end if;
516 end if;
517
518 return True;
519 end OK_To_Set_Referenced;
520
521 -- Start of processing for Generate_Reference
522
523 begin
524 pragma Assert (Nkind (E) in N_Entity);
525 Find_Actual (N, Formal, Call);
526
527 if Present (Formal) then
528 Kind := Ekind (Formal);
529 else
530 Kind := E_Void;
531 end if;
532
533 -- Check for obsolescent reference to package ASCII. GNAT treats this
534 -- element of annex J specially since in practice, programs make a lot
535 -- of use of this feature, so we don't include it in the set of features
536 -- diagnosed when Warn_On_Obsolescent_Features mode is set. However we
537 -- are required to note it as a violation of the RM defined restriction.
538
539 if E = Standard_ASCII then
540 Check_Restriction (No_Obsolescent_Features, N);
541 end if;
542
543 -- Check for reference to entity marked with Is_Obsolescent
544
545 -- Note that we always allow obsolescent references in the compiler
546 -- itself and the run time, since we assume that we know what we are
547 -- doing in such cases. For example the calls in Ada.Characters.Handling
548 -- to its own obsolescent subprograms are just fine.
549
550 -- In any case we do not generate warnings within the extended source
551 -- unit of the entity in question, since we assume the source unit
552 -- itself knows what is going on (and for sure we do not want silly
553 -- warnings, e.g. on the end line of an obsolescent procedure body).
554
555 if Is_Obsolescent (E)
556 and then not GNAT_Mode
557 and then not In_Extended_Main_Source_Unit (E)
558 then
559 Check_Restriction (No_Obsolescent_Features, N);
560
561 if Warn_On_Obsolescent_Feature then
562 Output_Obsolescent_Entity_Warnings (N, E);
563 end if;
564 end if;
565
566 -- Warn if reference to Ada 2005 entity not in Ada 2005 mode. We only
567 -- detect real explicit references (modifications and references).
568
569 if Comes_From_Source (N)
570 and then Is_Ada_2005_Only (E)
571 and then Ada_Version < Ada_2005
572 and then Warn_On_Ada_2005_Compatibility
573 and then (Typ = 'm' or else Typ = 'r' or else Typ = 's')
574 then
575 Error_Msg_NE ("& is only defined in Ada 2005?", N, E);
576 end if;
577
578 -- Warn if reference to Ada 2012 entity not in Ada 2012 mode. We only
579 -- detect real explicit references (modifications and references).
580
581 if Comes_From_Source (N)
582 and then Is_Ada_2012_Only (E)
583 and then Ada_Version < Ada_2012
584 and then Warn_On_Ada_2012_Compatibility
585 and then (Typ = 'm' or else Typ = 'r')
586 then
587 Error_Msg_NE ("& is only defined in Ada 2012?", N, E);
588 end if;
589
590 -- Never collect references if not in main source unit. However, we omit
591 -- this test if Typ is 'e' or 'k', since these entries are structural,
592 -- and it is useful to have them in units that reference packages as
593 -- well as units that define packages. We also omit the test for the
594 -- case of 'p' since we want to include inherited primitive operations
595 -- from other packages.
596
597 -- We also omit this test is this is a body reference for a subprogram
598 -- instantiation. In this case the reference is to the generic body,
599 -- which clearly need not be in the main unit containing the instance.
600 -- For the same reason we accept an implicit reference generated for
601 -- a default in an instance.
602
603 if not In_Extended_Main_Source_Unit (N) then
604 if Typ = 'e'
605 or else Typ = 'I'
606 or else Typ = 'p'
607 or else Typ = 'i'
608 or else Typ = 'k'
609 or else (Typ = 'b' and then Is_Generic_Instance (E))
610 then
611 null;
612 else
613 return;
614 end if;
615 end if;
616
617 -- For reference type p, the entity must be in main source unit
618
619 if Typ = 'p' and then not In_Extended_Main_Source_Unit (E) then
620 return;
621 end if;
622
623 -- Unless the reference is forced, we ignore references where the
624 -- reference itself does not come from source.
625
626 if not Force and then not Comes_From_Source (N) then
627 return;
628 end if;
629
630 -- Deal with setting entity as referenced, unless suppressed. Note that
631 -- we still do Set_Referenced on entities that do not come from source.
632 -- This situation arises when we have a source reference to a derived
633 -- operation, where the derived operation itself does not come from
634 -- source, but we still want to mark it as referenced, since we really
635 -- are referencing an entity in the corresponding package (this avoids
636 -- wrong complaints that the package contains no referenced entities).
637
638 if Set_Ref then
639
640 -- Assignable object appearing on left side of assignment or as
641 -- an out parameter.
642
643 if Is_Assignable (E)
644 and then Is_On_LHS (N)
645 and then Ekind (E) /= E_In_Out_Parameter
646 then
647 -- For objects that are renamings, just set as simply referenced
648 -- we do not try to do assignment type tracking in this case.
649
650 if Present (Renamed_Object (E)) then
651 Set_Referenced (E);
652
653 -- Out parameter case
654
655 elsif Kind = E_Out_Parameter then
656
657 -- If warning mode for all out parameters is set, or this is
658 -- the only warning parameter, then we want to mark this for
659 -- later warning logic by setting Referenced_As_Out_Parameter
660
661 if Warn_On_Modified_As_Out_Parameter (Formal) then
662 Set_Referenced_As_Out_Parameter (E, True);
663 Set_Referenced_As_LHS (E, False);
664
665 -- For OUT parameter not covered by the above cases, we simply
666 -- regard it as a normal reference (in this case we do not
667 -- want any of the warning machinery for out parameters).
668
669 else
670 Set_Referenced (E);
671 end if;
672
673 -- For the left hand of an assignment case, we do nothing here.
674 -- The processing for Analyze_Assignment_Statement will set the
675 -- Referenced_As_LHS flag.
676
677 else
678 null;
679 end if;
680
681 -- Check for a reference in a pragma that should not count as a
682 -- making the variable referenced for warning purposes.
683
684 elsif Is_Non_Significant_Pragma_Reference (N) then
685 null;
686
687 -- A reference in an attribute definition clause does not count as a
688 -- reference except for the case of Address. The reason that 'Address
689 -- is an exception is that it creates an alias through which the
690 -- variable may be referenced.
691
692 elsif Nkind (Parent (N)) = N_Attribute_Definition_Clause
693 and then Chars (Parent (N)) /= Name_Address
694 and then N = Name (Parent (N))
695 then
696 null;
697
698 -- Constant completion does not count as a reference
699
700 elsif Typ = 'c'
701 and then Ekind (E) = E_Constant
702 then
703 null;
704
705 -- Record representation clause does not count as a reference
706
707 elsif Nkind (N) = N_Identifier
708 and then Nkind (Parent (N)) = N_Record_Representation_Clause
709 then
710 null;
711
712 -- Discriminants do not need to produce a reference to record type
713
714 elsif Typ = 'd'
715 and then Nkind (Parent (N)) = N_Discriminant_Specification
716 then
717 null;
718
719 -- All other cases
720
721 else
722 -- Special processing for IN OUT parameters, where we have an
723 -- implicit assignment to a simple variable.
724
725 if Kind = E_In_Out_Parameter
726 and then Is_Assignable (E)
727 then
728 -- For sure this counts as a normal read reference
729
730 Set_Referenced (E);
731 Set_Last_Assignment (E, Empty);
732
733 -- We count it as being referenced as an out parameter if the
734 -- option is set to warn on all out parameters, except that we
735 -- have a special exclusion for an intrinsic subprogram, which
736 -- is most likely an instantiation of Unchecked_Deallocation
737 -- which we do not want to consider as an assignment since it
738 -- generates false positives. We also exclude the case of an
739 -- IN OUT parameter if the name of the procedure is Free,
740 -- since we suspect similar semantics.
741
742 if Warn_On_All_Unread_Out_Parameters
743 and then Is_Entity_Name (Name (Call))
744 and then not Is_Intrinsic_Subprogram (Entity (Name (Call)))
745 and then Chars (Name (Call)) /= Name_Free
746 then
747 Set_Referenced_As_Out_Parameter (E, True);
748 Set_Referenced_As_LHS (E, False);
749 end if;
750
751 -- Don't count a recursive reference within a subprogram as a
752 -- reference (that allows detection of a recursive subprogram
753 -- whose only references are recursive calls as unreferenced).
754
755 elsif Is_Subprogram (E)
756 and then E = Nearest_Dynamic_Scope (Current_Scope)
757 then
758 null;
759
760 -- Any other occurrence counts as referencing the entity
761
762 elsif OK_To_Set_Referenced then
763 Set_Referenced (E);
764
765 -- If variable, this is an OK reference after an assignment
766 -- so we can clear the Last_Assignment indication.
767
768 if Is_Assignable (E) then
769 Set_Last_Assignment (E, Empty);
770 end if;
771 end if;
772 end if;
773
774 -- Check for pragma Unreferenced given and reference is within
775 -- this source unit (occasion for possible warning to be issued).
776
777 if Has_Unreferenced (E)
778 and then In_Same_Extended_Unit (E, N)
779 then
780 -- A reference as a named parameter in a call does not count
781 -- as a violation of pragma Unreferenced for this purpose...
782
783 if Nkind (N) = N_Identifier
784 and then Nkind (Parent (N)) = N_Parameter_Association
785 and then Selector_Name (Parent (N)) = N
786 then
787 null;
788
789 -- ... Neither does a reference to a variable on the left side
790 -- of an assignment.
791
792 elsif Is_On_LHS (N) then
793 null;
794
795 -- For entry formals, we want to place the warning message on the
796 -- corresponding entity in the accept statement. The current scope
797 -- is the body of the accept, so we find the formal whose name
798 -- matches that of the entry formal (there is no link between the
799 -- two entities, and the one in the accept statement is only used
800 -- for conformance checking).
801
802 elsif Ekind (Scope (E)) = E_Entry then
803 declare
804 BE : Entity_Id;
805
806 begin
807 BE := First_Entity (Current_Scope);
808 while Present (BE) loop
809 if Chars (BE) = Chars (E) then
810 Error_Msg_NE -- CODEFIX
811 ("?pragma Unreferenced given for&!", N, BE);
812 exit;
813 end if;
814
815 Next_Entity (BE);
816 end loop;
817 end;
818
819 -- Here we issue the warning, since this is a real reference
820
821 else
822 Error_Msg_NE -- CODEFIX
823 ("?pragma Unreferenced given for&!", N, E);
824 end if;
825 end if;
826
827 -- If this is a subprogram instance, mark as well the internal
828 -- subprogram in the wrapper package, which may be a visible
829 -- compilation unit.
830
831 if Is_Overloadable (E)
832 and then Is_Generic_Instance (E)
833 and then Present (Alias (E))
834 then
835 Set_Referenced (Alias (E));
836 end if;
837 end if;
838
839 -- Generate reference if all conditions are met:
840
841 if
842 -- Cross referencing must be active
843
844 Opt.Xref_Active
845
846 -- The entity must be one for which we collect references
847
848 and then Xref_Entity_Letters (Ekind (E)) /= ' '
849
850 -- Both Sloc values must be set to something sensible
851
852 and then Sloc (E) > No_Location
853 and then Sloc (N) > No_Location
854
855 -- We ignore references from within an instance, except for default
856 -- subprograms, for which we generate an implicit reference.
857
858 and then
859 (Instantiation_Location (Sloc (N)) = No_Location or else Typ = 'i')
860
861 -- Ignore dummy references
862
863 and then Typ /= ' '
864 then
865 if Nkind (N) = N_Identifier
866 or else
867 Nkind (N) = N_Defining_Identifier
868 or else
869 Nkind (N) in N_Op
870 or else
871 Nkind (N) = N_Defining_Operator_Symbol
872 or else
873 Nkind (N) = N_Operator_Symbol
874 or else
875 (Nkind (N) = N_Character_Literal
876 and then Sloc (Entity (N)) /= Standard_Location)
877 or else
878 Nkind (N) = N_Defining_Character_Literal
879 then
880 Nod := N;
881
882 elsif Nkind (N) = N_Expanded_Name
883 or else
884 Nkind (N) = N_Selected_Component
885 then
886 Nod := Selector_Name (N);
887
888 else
889 return;
890 end if;
891
892 -- Normal case of source entity comes from source
893
894 if Comes_From_Source (E) then
895 Ent := E;
896
897 -- Entity does not come from source, but is a derived subprogram and
898 -- the derived subprogram comes from source (after one or more
899 -- derivations) in which case the reference is to parent subprogram.
900
901 elsif Is_Overloadable (E)
902 and then Present (Alias (E))
903 then
904 Ent := Alias (E);
905 while not Comes_From_Source (Ent) loop
906 if No (Alias (Ent)) then
907 return;
908 end if;
909
910 Ent := Alias (Ent);
911 end loop;
912
913 -- The internally created defining entity for a child subprogram
914 -- that has no previous spec has valid references.
915
916 elsif Is_Overloadable (E)
917 and then Is_Child_Unit (E)
918 then
919 Ent := E;
920
921 -- Record components of discriminated subtypes or derived types must
922 -- be treated as references to the original component.
923
924 elsif Ekind (E) = E_Component
925 and then Comes_From_Source (Original_Record_Component (E))
926 then
927 Ent := Original_Record_Component (E);
928
929 -- If this is an expanded reference to a discriminant, recover the
930 -- original discriminant, which gets the reference.
931
932 elsif Ekind (E) = E_In_Parameter
933 and then Present (Discriminal_Link (E))
934 then
935 Ent := Discriminal_Link (E);
936 Set_Referenced (Ent);
937
938 -- Ignore reference to any other entity that is not from source
939
940 else
941 return;
942 end if;
943
944 -- Record reference to entity
945
946 Ref := Original_Location (Sloc (Nod));
947 Def := Original_Location (Sloc (Ent));
948
949 Ref_Scope := Enclosing_Subprogram_Or_Package (N);
950 Ent_Scope := Enclosing_Subprogram_Or_Package (Ent);
951
952 Xrefs.Increment_Last;
953 Indx := Xrefs.Last;
954
955 Xrefs.Table (Indx).Loc := Ref;
956
957 -- Overriding operations are marked with 'P'
958
959 if Typ = 'p'
960 and then Is_Subprogram (N)
961 and then Present (Overridden_Operation (N))
962 then
963 Xrefs.Table (Indx).Typ := 'P';
964 else
965 Xrefs.Table (Indx).Typ := Typ;
966 end if;
967
968 Xrefs.Table (Indx).Eun := Get_Source_Unit (Def);
969 Xrefs.Table (Indx).Lun := Get_Source_Unit (Ref);
970 Xrefs.Table (Indx).Ent := Ent;
971
972 Xrefs.Table (Indx).Ref_Scope := Ref_Scope;
973 Xrefs.Table (Indx).Ent_Scope := Ent_Scope;
974 Xrefs.Table (Indx).Ent_Scope_File := Get_Source_Unit (Ent_Scope);
975
976 Set_Has_Xref_Entry (Ent);
977 end if;
978 end Generate_Reference;
979
980 -----------------------------------
981 -- Generate_Reference_To_Formals --
982 -----------------------------------
983
984 procedure Generate_Reference_To_Formals (E : Entity_Id) is
985 Formal : Entity_Id;
986
987 begin
988 if Is_Generic_Subprogram (E) then
989 Formal := First_Entity (E);
990
991 while Present (Formal)
992 and then not Is_Formal (Formal)
993 loop
994 Next_Entity (Formal);
995 end loop;
996
997 else
998 Formal := First_Formal (E);
999 end if;
1000
1001 while Present (Formal) loop
1002 if Ekind (Formal) = E_In_Parameter then
1003
1004 if Nkind (Parameter_Type (Parent (Formal)))
1005 = N_Access_Definition
1006 then
1007 Generate_Reference (E, Formal, '^', False);
1008 else
1009 Generate_Reference (E, Formal, '>', False);
1010 end if;
1011
1012 elsif Ekind (Formal) = E_In_Out_Parameter then
1013 Generate_Reference (E, Formal, '=', False);
1014
1015 else
1016 Generate_Reference (E, Formal, '<', False);
1017 end if;
1018
1019 Next_Formal (Formal);
1020 end loop;
1021 end Generate_Reference_To_Formals;
1022
1023 -------------------------------------------
1024 -- Generate_Reference_To_Generic_Formals --
1025 -------------------------------------------
1026
1027 procedure Generate_Reference_To_Generic_Formals (E : Entity_Id) is
1028 Formal : Entity_Id;
1029
1030 begin
1031 Formal := First_Entity (E);
1032 while Present (Formal) loop
1033 if Comes_From_Source (Formal) then
1034 Generate_Reference (E, Formal, 'z', False);
1035 end if;
1036
1037 Next_Entity (Formal);
1038 end loop;
1039 end Generate_Reference_To_Generic_Formals;
1040
1041 ----------------
1042 -- Initialize --
1043 ----------------
1044
1045 procedure Initialize is
1046 begin
1047 Xrefs.Init;
1048 end Initialize;
1049
1050 --------
1051 -- Lt --
1052 --------
1053
1054 function Lt (T1, T2 : Xref_Entry) return Boolean is
1055 begin
1056 -- First test: if entity is in different unit, sort by unit
1057
1058 if T1.Eun /= T2.Eun then
1059 return Dependency_Num (T1.Eun) < Dependency_Num (T2.Eun);
1060
1061 -- Second test: within same unit, sort by entity Sloc
1062
1063 elsif T1.Def /= T2.Def then
1064 return T1.Def < T2.Def;
1065
1066 -- Third test: sort definitions ahead of references
1067
1068 elsif T1.Loc = No_Location then
1069 return True;
1070
1071 elsif T2.Loc = No_Location then
1072 return False;
1073
1074 -- Fourth test: for same entity, sort by reference location unit
1075
1076 elsif T1.Lun /= T2.Lun then
1077 return Dependency_Num (T1.Lun) < Dependency_Num (T2.Lun);
1078
1079 -- Fifth test: order of location within referencing unit
1080
1081 elsif T1.Loc /= T2.Loc then
1082 return T1.Loc < T2.Loc;
1083
1084 -- Finally, for two locations at the same address, we prefer
1085 -- the one that does NOT have the type 'r' so that a modification
1086 -- or extension takes preference, when there are more than one
1087 -- reference at the same location. As a result, in the case of
1088 -- entities that are in-out actuals, the read reference follows
1089 -- the modify reference.
1090
1091 else
1092 return T2.Typ = 'r';
1093 end if;
1094 end Lt;
1095
1096 -----------------------
1097 -- Output_References --
1098 -----------------------
1099
1100 procedure Output_References is
1101
1102 procedure Get_Type_Reference
1103 (Ent : Entity_Id;
1104 Tref : out Entity_Id;
1105 Left : out Character;
1106 Right : out Character);
1107 -- Given an Entity_Id Ent, determines whether a type reference is
1108 -- required. If so, Tref is set to the entity for the type reference
1109 -- and Left and Right are set to the left/right brackets to be output
1110 -- for the reference. If no type reference is required, then Tref is
1111 -- set to Empty, and Left/Right are set to space.
1112
1113 procedure Output_Import_Export_Info (Ent : Entity_Id);
1114 -- Output language and external name information for an interfaced
1115 -- entity, using the format <language, external_name>,
1116
1117 ------------------------
1118 -- Get_Type_Reference --
1119 ------------------------
1120
1121 procedure Get_Type_Reference
1122 (Ent : Entity_Id;
1123 Tref : out Entity_Id;
1124 Left : out Character;
1125 Right : out Character)
1126 is
1127 Sav : Entity_Id;
1128
1129 begin
1130 -- See if we have a type reference
1131
1132 Tref := Ent;
1133 Left := '{';
1134 Right := '}';
1135
1136 loop
1137 Sav := Tref;
1138
1139 -- Processing for types
1140
1141 if Is_Type (Tref) then
1142
1143 -- Case of base type
1144
1145 if Base_Type (Tref) = Tref then
1146
1147 -- If derived, then get first subtype
1148
1149 if Tref /= Etype (Tref) then
1150 Tref := First_Subtype (Etype (Tref));
1151
1152 -- Set brackets for derived type, but don't override
1153 -- pointer case since the fact that something is a
1154 -- pointer is more important.
1155
1156 if Left /= '(' then
1157 Left := '<';
1158 Right := '>';
1159 end if;
1160
1161 -- If non-derived ptr, get directly designated type.
1162 -- If the type has a full view, all references are on the
1163 -- partial view, that is seen first.
1164
1165 elsif Is_Access_Type (Tref) then
1166 Tref := Directly_Designated_Type (Tref);
1167 Left := '(';
1168 Right := ')';
1169
1170 elsif Is_Private_Type (Tref)
1171 and then Present (Full_View (Tref))
1172 then
1173 if Is_Access_Type (Full_View (Tref)) then
1174 Tref := Directly_Designated_Type (Full_View (Tref));
1175 Left := '(';
1176 Right := ')';
1177
1178 -- If the full view is an array type, we also retrieve
1179 -- the corresponding component type, because the ali
1180 -- entry already indicates that this is an array.
1181
1182 elsif Is_Array_Type (Full_View (Tref)) then
1183 Tref := Component_Type (Full_View (Tref));
1184 Left := '(';
1185 Right := ')';
1186 end if;
1187
1188 -- If non-derived array, get component type. Skip component
1189 -- type for case of String or Wide_String, saves worthwhile
1190 -- space.
1191
1192 elsif Is_Array_Type (Tref)
1193 and then Tref /= Standard_String
1194 and then Tref /= Standard_Wide_String
1195 then
1196 Tref := Component_Type (Tref);
1197 Left := '(';
1198 Right := ')';
1199
1200 -- For other non-derived base types, nothing
1201
1202 else
1203 exit;
1204 end if;
1205
1206 -- For a subtype, go to ancestor subtype
1207
1208 else
1209 Tref := Ancestor_Subtype (Tref);
1210
1211 -- If no ancestor subtype, go to base type
1212
1213 if No (Tref) then
1214 Tref := Base_Type (Sav);
1215 end if;
1216 end if;
1217
1218 -- For objects, functions, enum literals, just get type from
1219 -- Etype field.
1220
1221 elsif Is_Object (Tref)
1222 or else Ekind (Tref) = E_Enumeration_Literal
1223 or else Ekind (Tref) = E_Function
1224 or else Ekind (Tref) = E_Operator
1225 then
1226 Tref := Etype (Tref);
1227
1228 -- For anything else, exit
1229
1230 else
1231 exit;
1232 end if;
1233
1234 -- Exit if no type reference, or we are stuck in some loop trying
1235 -- to find the type reference, or if the type is standard void
1236 -- type (the latter is an implementation artifact that should not
1237 -- show up in the generated cross-references).
1238
1239 exit when No (Tref)
1240 or else Tref = Sav
1241 or else Tref = Standard_Void_Type;
1242
1243 -- If we have a usable type reference, return, otherwise keep
1244 -- looking for something useful (we are looking for something
1245 -- that either comes from source or standard)
1246
1247 if Sloc (Tref) = Standard_Location
1248 or else Comes_From_Source (Tref)
1249 then
1250 -- If the reference is a subtype created for a generic actual,
1251 -- go actual directly, the inner subtype is not user visible.
1252
1253 if Nkind (Parent (Tref)) = N_Subtype_Declaration
1254 and then not Comes_From_Source (Parent (Tref))
1255 and then
1256 (Is_Wrapper_Package (Scope (Tref))
1257 or else Is_Generic_Instance (Scope (Tref)))
1258 then
1259 Tref := First_Subtype (Base_Type (Tref));
1260 end if;
1261
1262 return;
1263 end if;
1264 end loop;
1265
1266 -- If we fall through the loop, no type reference
1267
1268 Tref := Empty;
1269 Left := ' ';
1270 Right := ' ';
1271 end Get_Type_Reference;
1272
1273 -------------------------------
1274 -- Output_Import_Export_Info --
1275 -------------------------------
1276
1277 procedure Output_Import_Export_Info (Ent : Entity_Id) is
1278 Language_Name : Name_Id;
1279 Conv : constant Convention_Id := Convention (Ent);
1280
1281 begin
1282 -- Generate language name from convention
1283
1284 if Conv = Convention_C then
1285 Language_Name := Name_C;
1286
1287 elsif Conv = Convention_CPP then
1288 Language_Name := Name_CPP;
1289
1290 elsif Conv = Convention_Ada then
1291 Language_Name := Name_Ada;
1292
1293 else
1294 -- For the moment we ignore all other cases ???
1295
1296 return;
1297 end if;
1298
1299 Write_Info_Char ('<');
1300 Get_Unqualified_Name_String (Language_Name);
1301
1302 for J in 1 .. Name_Len loop
1303 Write_Info_Char (Name_Buffer (J));
1304 end loop;
1305
1306 if Present (Interface_Name (Ent)) then
1307 Write_Info_Char (',');
1308 String_To_Name_Buffer (Strval (Interface_Name (Ent)));
1309
1310 for J in 1 .. Name_Len loop
1311 Write_Info_Char (Name_Buffer (J));
1312 end loop;
1313 end if;
1314
1315 Write_Info_Char ('>');
1316 end Output_Import_Export_Info;
1317
1318 -- Start of processing for Output_References
1319
1320 begin
1321 -- First we add references to the primitive operations of tagged types
1322 -- declared in the main unit.
1323
1324 Handle_Prim_Ops : declare
1325 Ent : Entity_Id;
1326
1327 begin
1328 for J in 1 .. Xrefs.Last loop
1329 Ent := Xrefs.Table (J).Ent;
1330
1331 if Is_Type (Ent)
1332 and then Is_Tagged_Type (Ent)
1333 and then Is_Base_Type (Ent)
1334 and then In_Extended_Main_Source_Unit (Ent)
1335 then
1336 Generate_Prim_Op_References (Ent);
1337 end if;
1338 end loop;
1339 end Handle_Prim_Ops;
1340
1341 -- Before we go ahead and output the references we have a problem
1342 -- that needs dealing with. So far we have captured things that are
1343 -- definitely referenced by the main unit, or defined in the main
1344 -- unit. That's because we don't want to clutter up the ali file
1345 -- for this unit with definition lines for entities in other units
1346 -- that are not referenced.
1347
1348 -- But there is a glitch. We may reference an entity in another unit,
1349 -- and it may have a type reference to an entity that is not directly
1350 -- referenced in the main unit, which may mean that there is no xref
1351 -- entry for this entity yet in the list of references.
1352
1353 -- If we don't do something about this, we will end with an orphan type
1354 -- reference, i.e. it will point to an entity that does not appear
1355 -- within the generated references in the ali file. That is not good for
1356 -- tools using the xref information.
1357
1358 -- To fix this, we go through the references adding definition entries
1359 -- for any unreferenced entities that can be referenced in a type
1360 -- reference. There is a recursion problem here, and that is dealt with
1361 -- by making sure that this traversal also traverses any entries that
1362 -- get added by the traversal.
1363
1364 Handle_Orphan_Type_References : declare
1365 J : Nat;
1366 Tref : Entity_Id;
1367 Indx : Nat;
1368 Ent : Entity_Id;
1369 Loc : Source_Ptr;
1370
1371 L, R : Character;
1372 pragma Warnings (Off, L);
1373 pragma Warnings (Off, R);
1374
1375 procedure New_Entry (E : Entity_Id);
1376 -- Make an additional entry into the Xref table for a type entity
1377 -- that is related to the current entity (parent, type ancestor,
1378 -- progenitor, etc.).
1379
1380 ----------------
1381 -- New_Entry --
1382 ----------------
1383
1384 procedure New_Entry (E : Entity_Id) is
1385 begin
1386 if Present (E)
1387 and then not Has_Xref_Entry (E)
1388 and then Sloc (E) > No_Location
1389 then
1390 Xrefs.Increment_Last;
1391 Indx := Xrefs.Last;
1392 Loc := Original_Location (Sloc (E));
1393 Xrefs.Table (Indx).Ent := E;
1394 Xrefs.Table (Indx).Loc := No_Location;
1395 Xrefs.Table (Indx).Eun := Get_Source_Unit (Loc);
1396 Xrefs.Table (Indx).Lun := No_Unit;
1397 Set_Has_Xref_Entry (E);
1398 end if;
1399 end New_Entry;
1400
1401 -- Start of processing for Handle_Orphan_Type_References
1402
1403 begin
1404 -- Note that this is not a for loop for a very good reason. The
1405 -- processing of items in the table can add new items to the table,
1406 -- and they must be processed as well.
1407
1408 J := 1;
1409 while J <= Xrefs.Last loop
1410 Ent := Xrefs.Table (J).Ent;
1411 Get_Type_Reference (Ent, Tref, L, R);
1412
1413 if Present (Tref)
1414 and then not Has_Xref_Entry (Tref)
1415 and then Sloc (Tref) > No_Location
1416 then
1417 New_Entry (Tref);
1418
1419 if Is_Record_Type (Ent)
1420 and then Present (Interfaces (Ent))
1421 then
1422 -- Add an entry for each one of the given interfaces
1423 -- implemented by type Ent.
1424
1425 declare
1426 Elmt : Elmt_Id := First_Elmt (Interfaces (Ent));
1427 begin
1428 while Present (Elmt) loop
1429 New_Entry (Node (Elmt));
1430 Next_Elmt (Elmt);
1431 end loop;
1432 end;
1433 end if;
1434 end if;
1435
1436 -- Collect inherited primitive operations that may be declared in
1437 -- another unit and have no visible reference in the current one.
1438
1439 if Is_Type (Ent)
1440 and then Is_Tagged_Type (Ent)
1441 and then Is_Derived_Type (Ent)
1442 and then Is_Base_Type (Ent)
1443 and then In_Extended_Main_Source_Unit (Ent)
1444 then
1445 declare
1446 Op_List : constant Elist_Id := Primitive_Operations (Ent);
1447 Op : Elmt_Id;
1448 Prim : Entity_Id;
1449
1450 function Parent_Op (E : Entity_Id) return Entity_Id;
1451 -- Find original operation, which may be inherited through
1452 -- several derivations.
1453
1454 function Parent_Op (E : Entity_Id) return Entity_Id is
1455 Orig_Op : constant Entity_Id := Alias (E);
1456
1457 begin
1458 if No (Orig_Op) then
1459 return Empty;
1460
1461 elsif not Comes_From_Source (E)
1462 and then not Has_Xref_Entry (Orig_Op)
1463 and then Comes_From_Source (Orig_Op)
1464 then
1465 return Orig_Op;
1466 else
1467 return Parent_Op (Orig_Op);
1468 end if;
1469 end Parent_Op;
1470
1471 begin
1472 Op := First_Elmt (Op_List);
1473 while Present (Op) loop
1474 Prim := Parent_Op (Node (Op));
1475
1476 if Present (Prim) then
1477 Xrefs.Increment_Last;
1478 Indx := Xrefs.Last;
1479 Loc := Original_Location (Sloc (Prim));
1480 Xrefs.Table (Indx).Ent := Prim;
1481 Xrefs.Table (Indx).Loc := No_Location;
1482 Xrefs.Table (Indx).Eun :=
1483 Get_Source_Unit (Sloc (Prim));
1484 Xrefs.Table (Indx).Lun := No_Unit;
1485 Set_Has_Xref_Entry (Prim);
1486 end if;
1487
1488 Next_Elmt (Op);
1489 end loop;
1490 end;
1491 end if;
1492
1493 J := J + 1;
1494 end loop;
1495 end Handle_Orphan_Type_References;
1496
1497 -- Now we have all the references, including those for any embedded
1498 -- type references, so we can sort them, and output them.
1499
1500 Output_Refs : declare
1501
1502 Nrefs : Nat := Xrefs.Last;
1503 -- Number of references in table. This value may get reset (reduced)
1504 -- when we eliminate duplicate reference entries.
1505
1506 Rnums : array (0 .. Nrefs) of Nat;
1507 -- This array contains numbers of references in the Xrefs table.
1508 -- This list is sorted in output order. The extra 0'th entry is
1509 -- convenient for the call to sort. When we sort the table, we
1510 -- move the entries in Rnums around, but we do not move the
1511 -- original table entries.
1512
1513 Curxu : Unit_Number_Type;
1514 -- Current xref unit
1515
1516 Curru : Unit_Number_Type;
1517 -- Current reference unit for one entity
1518
1519 Curent : Entity_Id;
1520 -- Current entity
1521
1522 Curnam : String (1 .. Name_Buffer'Length);
1523 Curlen : Natural;
1524 -- Simple name and length of current entity
1525
1526 Curdef : Source_Ptr;
1527 -- Original source location for current entity
1528
1529 Crloc : Source_Ptr;
1530 -- Current reference location
1531
1532 Ctyp : Character;
1533 -- Entity type character
1534
1535 Prevt : Character;
1536 -- reference kind of previous reference
1537
1538 Tref : Entity_Id;
1539 -- Type reference
1540
1541 Rref : Node_Id;
1542 -- Renaming reference
1543
1544 Trunit : Unit_Number_Type;
1545 -- Unit number for type reference
1546
1547 function Lt (Op1, Op2 : Natural) return Boolean;
1548 -- Comparison function for Sort call
1549
1550 function Name_Change (X : Entity_Id) return Boolean;
1551 -- Determines if entity X has a different simple name from Curent
1552
1553 procedure Move (From : Natural; To : Natural);
1554 -- Move procedure for Sort call
1555
1556 package Sorting is new GNAT.Heap_Sort_G (Move, Lt);
1557
1558 --------
1559 -- Lt --
1560 --------
1561
1562 function Lt (Op1, Op2 : Natural) return Boolean is
1563 T1 : Xref_Entry renames Xrefs.Table (Rnums (Nat (Op1)));
1564 T2 : Xref_Entry renames Xrefs.Table (Rnums (Nat (Op2)));
1565
1566 begin
1567 return Lt (T1, T2);
1568 end Lt;
1569
1570 ----------
1571 -- Move --
1572 ----------
1573
1574 procedure Move (From : Natural; To : Natural) is
1575 begin
1576 Rnums (Nat (To)) := Rnums (Nat (From));
1577 end Move;
1578
1579 -----------------
1580 -- Name_Change --
1581 -----------------
1582
1583 -- Why a string comparison here??? Why not compare Name_Id values???
1584
1585 function Name_Change (X : Entity_Id) return Boolean is
1586 begin
1587 Get_Unqualified_Name_String (Chars (X));
1588
1589 if Name_Len /= Curlen then
1590 return True;
1591 else
1592 return Name_Buffer (1 .. Curlen) /= Curnam (1 .. Curlen);
1593 end if;
1594 end Name_Change;
1595
1596 -- Start of processing for Output_Refs
1597
1598 begin
1599 -- Capture the definition Sloc values. We delay doing this till now,
1600 -- since at the time the reference or definition is made, private
1601 -- types may be swapped, and the Sloc value may be incorrect. We
1602 -- also set up the pointer vector for the sort.
1603
1604 for J in 1 .. Nrefs loop
1605 Rnums (J) := J;
1606 Xrefs.Table (J).Def :=
1607 Original_Location (Sloc (Xrefs.Table (J).Ent));
1608 end loop;
1609
1610 -- Sort the references
1611
1612 Sorting.Sort (Integer (Nrefs));
1613
1614 -- Eliminate duplicate entries
1615
1616 declare
1617 NR : constant Nat := Nrefs;
1618
1619 begin
1620 -- We need this test for NR because if we force ALI file
1621 -- generation in case of errors detected, it may be the case
1622 -- that Nrefs is 0, so we should not reset it here
1623
1624 if NR >= 2 then
1625 Nrefs := 1;
1626
1627 for J in 2 .. NR loop
1628 if Xrefs.Table (Rnums (J)) /=
1629 Xrefs.Table (Rnums (Nrefs))
1630 then
1631 Nrefs := Nrefs + 1;
1632 Rnums (Nrefs) := Rnums (J);
1633 end if;
1634 end loop;
1635 end if;
1636 end;
1637
1638 -- Initialize loop through references
1639
1640 Curxu := No_Unit;
1641 Curent := Empty;
1642 Curdef := No_Location;
1643 Curru := No_Unit;
1644 Crloc := No_Location;
1645 Prevt := 'm';
1646
1647 -- Loop to output references
1648
1649 for Refno in 1 .. Nrefs loop
1650 Output_One_Ref : declare
1651 Ent : Entity_Id;
1652
1653 XE : Xref_Entry renames Xrefs.Table (Rnums (Refno));
1654 -- The current entry to be accessed
1655
1656 Left : Character;
1657 Right : Character;
1658 -- Used for {} or <> or () for type reference
1659
1660 procedure Check_Type_Reference
1661 (Ent : Entity_Id;
1662 List_Interface : Boolean);
1663 -- Find whether there is a meaningful type reference for
1664 -- Ent, and display it accordingly. If List_Interface is
1665 -- true, then Ent is a progenitor interface of the current
1666 -- type entity being listed. In that case list it as is,
1667 -- without looking for a type reference for it.
1668
1669 procedure Output_Instantiation_Refs (Loc : Source_Ptr);
1670 -- Recursive procedure to output instantiation references for
1671 -- the given source ptr in [file|line[...]] form. No output
1672 -- if the given location is not a generic template reference.
1673
1674 procedure Output_Overridden_Op (Old_E : Entity_Id);
1675 -- For a subprogram that is overriding, display information
1676 -- about the inherited operation that it overrides.
1677
1678 --------------------------
1679 -- Check_Type_Reference --
1680 --------------------------
1681
1682 procedure Check_Type_Reference
1683 (Ent : Entity_Id;
1684 List_Interface : Boolean)
1685 is
1686 begin
1687 if List_Interface then
1688
1689 -- This is a progenitor interface of the type for which
1690 -- xref information is being generated.
1691
1692 Tref := Ent;
1693 Left := '<';
1694 Right := '>';
1695
1696 else
1697 Get_Type_Reference (Ent, Tref, Left, Right);
1698 end if;
1699
1700 if Present (Tref) then
1701
1702 -- Case of standard entity, output name
1703
1704 if Sloc (Tref) = Standard_Location then
1705 Write_Info_Char (Left);
1706 Write_Info_Name (Chars (Tref));
1707 Write_Info_Char (Right);
1708
1709 -- Case of source entity, output location
1710
1711 else
1712 Write_Info_Char (Left);
1713 Trunit := Get_Source_Unit (Sloc (Tref));
1714
1715 if Trunit /= Curxu then
1716 Write_Info_Nat (Dependency_Num (Trunit));
1717 Write_Info_Char ('|');
1718 end if;
1719
1720 Write_Info_Nat
1721 (Int (Get_Logical_Line_Number (Sloc (Tref))));
1722
1723 declare
1724 Ent : Entity_Id;
1725 Ctyp : Character;
1726
1727 begin
1728 Ent := Tref;
1729 Ctyp := Xref_Entity_Letters (Ekind (Ent));
1730
1731 if Ctyp = '+'
1732 and then Present (Full_View (Ent))
1733 then
1734 Ent := Underlying_Type (Ent);
1735
1736 if Present (Ent) then
1737 Ctyp := Xref_Entity_Letters (Ekind (Ent));
1738 end if;
1739 end if;
1740
1741 Write_Info_Char (Ctyp);
1742 end;
1743
1744 Write_Info_Nat
1745 (Int (Get_Column_Number (Sloc (Tref))));
1746
1747 -- If the type comes from an instantiation, add the
1748 -- corresponding info.
1749
1750 Output_Instantiation_Refs (Sloc (Tref));
1751 Write_Info_Char (Right);
1752 end if;
1753 end if;
1754 end Check_Type_Reference;
1755
1756 -------------------------------
1757 -- Output_Instantiation_Refs --
1758 -------------------------------
1759
1760 procedure Output_Instantiation_Refs (Loc : Source_Ptr) is
1761 Iloc : constant Source_Ptr := Instantiation_Location (Loc);
1762 Lun : Unit_Number_Type;
1763 Cu : constant Unit_Number_Type := Curru;
1764
1765 begin
1766 -- Nothing to do if this is not an instantiation
1767
1768 if Iloc = No_Location then
1769 return;
1770 end if;
1771
1772 -- Output instantiation reference
1773
1774 Write_Info_Char ('[');
1775 Lun := Get_Source_Unit (Iloc);
1776
1777 if Lun /= Curru then
1778 Curru := Lun;
1779 Write_Info_Nat (Dependency_Num (Curru));
1780 Write_Info_Char ('|');
1781 end if;
1782
1783 Write_Info_Nat (Int (Get_Logical_Line_Number (Iloc)));
1784
1785 -- Recursive call to get nested instantiations
1786
1787 Output_Instantiation_Refs (Iloc);
1788
1789 -- Output final ] after call to get proper nesting
1790
1791 Write_Info_Char (']');
1792 Curru := Cu;
1793 return;
1794 end Output_Instantiation_Refs;
1795
1796 --------------------------
1797 -- Output_Overridden_Op --
1798 --------------------------
1799
1800 procedure Output_Overridden_Op (Old_E : Entity_Id) is
1801 Op : Entity_Id;
1802
1803 begin
1804 -- The overridden operation has an implicit declaration
1805 -- at the point of derivation. What we want to display
1806 -- is the original operation, which has the actual body
1807 -- (or abstract declaration) that is being overridden.
1808 -- The overridden operation is not always set, e.g. when
1809 -- it is a predefined operator.
1810
1811 if No (Old_E) then
1812 return;
1813
1814 -- Follow alias chain if one is present
1815
1816 elsif Present (Alias (Old_E)) then
1817
1818 -- The subprogram may have been implicitly inherited
1819 -- through several levels of derivation, so find the
1820 -- ultimate (source) ancestor.
1821
1822 Op := Ultimate_Alias (Old_E);
1823
1824 -- Normal case of no alias present
1825
1826 else
1827 Op := Old_E;
1828 end if;
1829
1830 if Present (Op)
1831 and then Sloc (Op) /= Standard_Location
1832 then
1833 declare
1834 Loc : constant Source_Ptr := Sloc (Op);
1835 Par_Unit : constant Unit_Number_Type :=
1836 Get_Source_Unit (Loc);
1837
1838 begin
1839 Write_Info_Char ('<');
1840
1841 if Par_Unit /= Curxu then
1842 Write_Info_Nat (Dependency_Num (Par_Unit));
1843 Write_Info_Char ('|');
1844 end if;
1845
1846 Write_Info_Nat (Int (Get_Logical_Line_Number (Loc)));
1847 Write_Info_Char ('p');
1848 Write_Info_Nat (Int (Get_Column_Number (Loc)));
1849 Write_Info_Char ('>');
1850 end;
1851 end if;
1852 end Output_Overridden_Op;
1853
1854 -- Start of processing for Output_One_Ref
1855
1856 begin
1857 Ent := XE.Ent;
1858 Ctyp := Xref_Entity_Letters (Ekind (Ent));
1859
1860 -- Skip reference if it is the only reference to an entity,
1861 -- and it is an END line reference, and the entity is not in
1862 -- the current extended source. This prevents junk entries
1863 -- consisting only of packages with END lines, where no
1864 -- entity from the package is actually referenced.
1865
1866 if XE.Typ = 'e'
1867 and then Ent /= Curent
1868 and then (Refno = Nrefs or else
1869 Ent /= Xrefs.Table (Rnums (Refno + 1)).Ent)
1870 and then
1871 not In_Extended_Main_Source_Unit (Ent)
1872 then
1873 goto Continue;
1874 end if;
1875
1876 -- For private type, get full view type
1877
1878 if Ctyp = '+'
1879 and then Present (Full_View (XE.Ent))
1880 then
1881 Ent := Underlying_Type (Ent);
1882
1883 if Present (Ent) then
1884 Ctyp := Xref_Entity_Letters (Ekind (Ent));
1885 end if;
1886 end if;
1887
1888 -- Special exception for Boolean
1889
1890 if Ctyp = 'E' and then Is_Boolean_Type (Ent) then
1891 Ctyp := 'B';
1892 end if;
1893
1894 -- For variable reference, get corresponding type
1895
1896 if Ctyp = '*' then
1897 Ent := Etype (XE.Ent);
1898 Ctyp := Fold_Lower (Xref_Entity_Letters (Ekind (Ent)));
1899
1900 -- If variable is private type, get full view type
1901
1902 if Ctyp = '+'
1903 and then Present (Full_View (Etype (XE.Ent)))
1904 then
1905 Ent := Underlying_Type (Etype (XE.Ent));
1906
1907 if Present (Ent) then
1908 Ctyp := Fold_Lower (Xref_Entity_Letters (Ekind (Ent)));
1909 end if;
1910
1911 elsif Is_Generic_Type (Ent) then
1912
1913 -- If the type of the entity is a generic private type,
1914 -- there is no usable full view, so retain the indication
1915 -- that this is an object.
1916
1917 Ctyp := '*';
1918 end if;
1919
1920 -- Special handling for access parameters and objects of
1921 -- an anonymous access type.
1922
1923 if Ekind_In (Etype (XE.Ent),
1924 E_Anonymous_Access_Type,
1925 E_Anonymous_Access_Subprogram_Type,
1926 E_Anonymous_Access_Protected_Subprogram_Type)
1927 then
1928 if Is_Formal (XE.Ent)
1929 or else Ekind_In (XE.Ent, E_Variable, E_Constant)
1930 then
1931 Ctyp := 'p';
1932 end if;
1933
1934 -- Special handling for Boolean
1935
1936 elsif Ctyp = 'e' and then Is_Boolean_Type (Ent) then
1937 Ctyp := 'b';
1938 end if;
1939 end if;
1940
1941 -- Special handling for abstract types and operations
1942
1943 if Is_Overloadable (XE.Ent)
1944 and then Is_Abstract_Subprogram (XE.Ent)
1945 then
1946 if Ctyp = 'U' then
1947 Ctyp := 'x'; -- Abstract procedure
1948
1949 elsif Ctyp = 'V' then
1950 Ctyp := 'y'; -- Abstract function
1951 end if;
1952
1953 elsif Is_Type (XE.Ent)
1954 and then Is_Abstract_Type (XE.Ent)
1955 then
1956 if Is_Interface (XE.Ent) then
1957 Ctyp := 'h';
1958
1959 elsif Ctyp = 'R' then
1960 Ctyp := 'H'; -- Abstract type
1961 end if;
1962 end if;
1963
1964 -- Only output reference if interesting type of entity
1965
1966 if Ctyp = ' '
1967
1968 -- Suppress references to object definitions, used for local
1969 -- references.
1970
1971 or else XE.Typ = 'D'
1972 or else XE.Typ = 'I'
1973
1974 -- Suppress self references, except for bodies that act as
1975 -- specs.
1976
1977 or else (XE.Loc = XE.Def
1978 and then
1979 (XE.Typ /= 'b'
1980 or else not Is_Subprogram (XE.Ent)))
1981
1982 -- Also suppress definitions of body formals (we only
1983 -- treat these as references, and the references were
1984 -- separately recorded).
1985
1986 or else (Is_Formal (XE.Ent)
1987 and then Present (Spec_Entity (XE.Ent)))
1988 then
1989 null;
1990
1991 else
1992 -- Start new Xref section if new xref unit
1993
1994 if XE.Eun /= Curxu then
1995 if Write_Info_Col > 1 then
1996 Write_Info_EOL;
1997 end if;
1998
1999 Curxu := XE.Eun;
2000
2001 Write_Info_Initiate ('X');
2002 Write_Info_Char (' ');
2003 Write_Info_Nat (Dependency_Num (XE.Eun));
2004 Write_Info_Char (' ');
2005 Write_Info_Name (Reference_Name (Source_Index (XE.Eun)));
2006 end if;
2007
2008 -- Start new Entity line if new entity. Note that we
2009 -- consider two entities the same if they have the same
2010 -- name and source location. This causes entities in
2011 -- instantiations to be treated as though they referred
2012 -- to the template.
2013
2014 if No (Curent)
2015 or else
2016 (XE.Ent /= Curent
2017 and then
2018 (Name_Change (XE.Ent) or else XE.Def /= Curdef))
2019 then
2020 Curent := XE.Ent;
2021 Curdef := XE.Def;
2022
2023 Get_Unqualified_Name_String (Chars (XE.Ent));
2024 Curlen := Name_Len;
2025 Curnam (1 .. Curlen) := Name_Buffer (1 .. Curlen);
2026
2027 if Write_Info_Col > 1 then
2028 Write_Info_EOL;
2029 end if;
2030
2031 -- Write column number information
2032
2033 Write_Info_Nat (Int (Get_Logical_Line_Number (XE.Def)));
2034 Write_Info_Char (Ctyp);
2035 Write_Info_Nat (Int (Get_Column_Number (XE.Def)));
2036
2037 -- Write level information
2038
2039 Write_Level_Info : declare
2040 function Is_Visible_Generic_Entity
2041 (E : Entity_Id) return Boolean;
2042 -- Check whether E is declared in the visible part
2043 -- of a generic package. For source navigation
2044 -- purposes, treat this as a visible entity.
2045
2046 function Is_Private_Record_Component
2047 (E : Entity_Id) return Boolean;
2048 -- Check whether E is a non-inherited component of a
2049 -- private extension. Even if the enclosing record is
2050 -- public, we want to treat the component as private
2051 -- for navigation purposes.
2052
2053 ---------------------------------
2054 -- Is_Private_Record_Component --
2055 ---------------------------------
2056
2057 function Is_Private_Record_Component
2058 (E : Entity_Id) return Boolean
2059 is
2060 S : constant Entity_Id := Scope (E);
2061 begin
2062 return
2063 Ekind (E) = E_Component
2064 and then Nkind (Declaration_Node (S)) =
2065 N_Private_Extension_Declaration
2066 and then Original_Record_Component (E) = E;
2067 end Is_Private_Record_Component;
2068
2069 -------------------------------
2070 -- Is_Visible_Generic_Entity --
2071 -------------------------------
2072
2073 function Is_Visible_Generic_Entity
2074 (E : Entity_Id) return Boolean
2075 is
2076 Par : Node_Id;
2077
2078 begin
2079 -- The Present check here is an error defense
2080
2081 if Present (Scope (E))
2082 and then Ekind (Scope (E)) /= E_Generic_Package
2083 then
2084 return False;
2085 end if;
2086
2087 Par := Parent (E);
2088 while Present (Par) loop
2089 if
2090 Nkind (Par) = N_Generic_Package_Declaration
2091 then
2092 -- Entity is a generic formal
2093
2094 return False;
2095
2096 elsif
2097 Nkind (Parent (Par)) = N_Package_Specification
2098 then
2099 return
2100 Is_List_Member (Par)
2101 and then List_Containing (Par) =
2102 Visible_Declarations (Parent (Par));
2103 else
2104 Par := Parent (Par);
2105 end if;
2106 end loop;
2107
2108 return False;
2109 end Is_Visible_Generic_Entity;
2110
2111 -- Start of processing for Write_Level_Info
2112
2113 begin
2114 if Is_Hidden (Curent)
2115 or else Is_Private_Record_Component (Curent)
2116 then
2117 Write_Info_Char (' ');
2118
2119 elsif
2120 Is_Public (Curent)
2121 or else Is_Visible_Generic_Entity (Curent)
2122 then
2123 Write_Info_Char ('*');
2124
2125 else
2126 Write_Info_Char (' ');
2127 end if;
2128 end Write_Level_Info;
2129
2130 -- Output entity name. We use the occurrence from the
2131 -- actual source program at the definition point.
2132
2133 declare
2134 Ent_Name : constant String :=
2135 Exact_Source_Name (Sloc (XE.Ent));
2136 begin
2137 for C in Ent_Name'Range loop
2138 Write_Info_Char (Ent_Name (C));
2139 end loop;
2140 end;
2141
2142 -- See if we have a renaming reference
2143
2144 if Is_Object (XE.Ent)
2145 and then Present (Renamed_Object (XE.Ent))
2146 then
2147 Rref := Renamed_Object (XE.Ent);
2148
2149 elsif Is_Overloadable (XE.Ent)
2150 and then Nkind (Parent (Declaration_Node (XE.Ent))) =
2151 N_Subprogram_Renaming_Declaration
2152 then
2153 Rref := Name (Parent (Declaration_Node (XE.Ent)));
2154
2155 elsif Ekind (XE.Ent) = E_Package
2156 and then Nkind (Declaration_Node (XE.Ent)) =
2157 N_Package_Renaming_Declaration
2158 then
2159 Rref := Name (Declaration_Node (XE.Ent));
2160
2161 else
2162 Rref := Empty;
2163 end if;
2164
2165 if Present (Rref) then
2166 if Nkind (Rref) = N_Expanded_Name then
2167 Rref := Selector_Name (Rref);
2168 end if;
2169
2170 if Nkind (Rref) = N_Identifier
2171 or else Nkind (Rref) = N_Operator_Symbol
2172 then
2173 null;
2174
2175 -- For renamed array components, use the array name
2176 -- for the renamed entity, which reflect the fact that
2177 -- in general the whole array is aliased.
2178
2179 elsif Nkind (Rref) = N_Indexed_Component then
2180 if Nkind (Prefix (Rref)) = N_Identifier then
2181 Rref := Prefix (Rref);
2182 elsif Nkind (Prefix (Rref)) = N_Expanded_Name then
2183 Rref := Selector_Name (Prefix (Rref));
2184 else
2185 Rref := Empty;
2186 end if;
2187
2188 else
2189 Rref := Empty;
2190 end if;
2191 end if;
2192
2193 -- Write out renaming reference if we have one
2194
2195 if Present (Rref) then
2196 Write_Info_Char ('=');
2197 Write_Info_Nat
2198 (Int (Get_Logical_Line_Number (Sloc (Rref))));
2199 Write_Info_Char (':');
2200 Write_Info_Nat
2201 (Int (Get_Column_Number (Sloc (Rref))));
2202 end if;
2203
2204 -- Indicate that the entity is in the unit of the current
2205 -- xref section.
2206
2207 Curru := Curxu;
2208
2209 -- Write out information about generic parent, if entity
2210 -- is an instance.
2211
2212 if Is_Generic_Instance (XE.Ent) then
2213 declare
2214 Gen_Par : constant Entity_Id :=
2215 Generic_Parent
2216 (Specification
2217 (Unit_Declaration_Node (XE.Ent)));
2218 Loc : constant Source_Ptr := Sloc (Gen_Par);
2219 Gen_U : constant Unit_Number_Type :=
2220 Get_Source_Unit (Loc);
2221
2222 begin
2223 Write_Info_Char ('[');
2224
2225 if Curru /= Gen_U then
2226 Write_Info_Nat (Dependency_Num (Gen_U));
2227 Write_Info_Char ('|');
2228 end if;
2229
2230 Write_Info_Nat
2231 (Int (Get_Logical_Line_Number (Loc)));
2232 Write_Info_Char (']');
2233 end;
2234 end if;
2235
2236 -- See if we have a type reference and if so output
2237
2238 Check_Type_Reference (XE.Ent, False);
2239
2240 -- Additional information for types with progenitors
2241
2242 if Is_Record_Type (XE.Ent)
2243 and then Present (Interfaces (XE.Ent))
2244 then
2245 declare
2246 Elmt : Elmt_Id := First_Elmt (Interfaces (XE.Ent));
2247 begin
2248 while Present (Elmt) loop
2249 Check_Type_Reference (Node (Elmt), True);
2250 Next_Elmt (Elmt);
2251 end loop;
2252 end;
2253
2254 -- For array types, list index types as well. (This is
2255 -- not C, indexes have distinct types).
2256
2257 elsif Is_Array_Type (XE.Ent) then
2258 declare
2259 Indx : Node_Id;
2260 begin
2261 Indx := First_Index (XE.Ent);
2262 while Present (Indx) loop
2263 Check_Type_Reference
2264 (First_Subtype (Etype (Indx)), True);
2265 Next_Index (Indx);
2266 end loop;
2267 end;
2268 end if;
2269
2270 -- If the entity is an overriding operation, write info
2271 -- on operation that was overridden.
2272
2273 if Is_Subprogram (XE.Ent)
2274 and then Present (Overridden_Operation (XE.Ent))
2275 then
2276 Output_Overridden_Op (Overridden_Operation (XE.Ent));
2277 end if;
2278
2279 -- End of processing for entity output
2280
2281 Crloc := No_Location;
2282 end if;
2283
2284 -- Output the reference if it is not as the same location
2285 -- as the previous one, or it is a read-reference that
2286 -- indicates that the entity is an in-out actual in a call.
2287
2288 if XE.Loc /= No_Location
2289 and then
2290 (XE.Loc /= Crloc
2291 or else (Prevt = 'm' and then XE.Typ = 'r'))
2292 then
2293 Crloc := XE.Loc;
2294 Prevt := XE.Typ;
2295
2296 -- Start continuation if line full, else blank
2297
2298 if Write_Info_Col > 72 then
2299 Write_Info_EOL;
2300 Write_Info_Initiate ('.');
2301 end if;
2302
2303 Write_Info_Char (' ');
2304
2305 -- Output file number if changed
2306
2307 if XE.Lun /= Curru then
2308 Curru := XE.Lun;
2309 Write_Info_Nat (Dependency_Num (Curru));
2310 Write_Info_Char ('|');
2311 end if;
2312
2313 Write_Info_Nat (Int (Get_Logical_Line_Number (XE.Loc)));
2314 Write_Info_Char (XE.Typ);
2315
2316 if Is_Overloadable (XE.Ent)
2317 and then Is_Imported (XE.Ent)
2318 and then XE.Typ = 'b'
2319 then
2320 Output_Import_Export_Info (XE.Ent);
2321 end if;
2322
2323 Write_Info_Nat (Int (Get_Column_Number (XE.Loc)));
2324
2325 Output_Instantiation_Refs (Sloc (XE.Ent));
2326 end if;
2327 end if;
2328 end Output_One_Ref;
2329
2330 <<Continue>>
2331 null;
2332 end loop;
2333
2334 Write_Info_EOL;
2335 end Output_Refs;
2336 end Output_References;
2337
2338 end Lib.Xref;