1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1998-2008, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Atree; use Atree;
27 with Csets; use Csets;
28 with Elists; use Elists;
29 with Errout; use Errout;
30 with Lib.Util; use Lib.Util;
31 with Nlists; use Nlists;
33 with Restrict; use Restrict;
34 with Rident; use Rident;
36 with Sem_Aux; use Sem_Aux;
37 with Sem_Prag; use Sem_Prag;
38 with Sem_Util; use Sem_Util;
39 with Sem_Warn; use Sem_Warn;
40 with Sinfo; use Sinfo;
41 with Sinput; use Sinput;
42 with Snames; use Snames;
43 with Stringt; use Stringt;
44 with Stand; use Stand;
45 with Table; use Table;
46 with Widechar; use Widechar;
48 with GNAT.Heap_Sort_G;
50 package body Lib.Xref is
56 -- The Xref table is used to record references. The Loc field is set
57 -- to No_Location for a definition entry.
59 subtype Xref_Entry_Number is Int;
61 type Xref_Entry is record
63 -- Entity referenced (E parameter to Generate_Reference)
66 -- Original source location for entity being referenced. Note that these
67 -- values are used only during the output process, they are not set when
68 -- the entries are originally built. This is because private entities
69 -- can be swapped when the initial call is made.
72 -- Location of reference (Original_Location (Sloc field of N parameter
73 -- to Generate_Reference). Set to No_Location for the case of a
74 -- defining occurrence.
77 -- Reference type (Typ param to Generate_Reference)
79 Eun : Unit_Number_Type;
80 -- Unit number corresponding to Ent
82 Lun : Unit_Number_Type;
83 -- Unit number corresponding to Loc. Value is undefined and not
84 -- referenced if Loc is set to No_Location.
88 package Xrefs is new Table.Table (
89 Table_Component_Type => Xref_Entry,
90 Table_Index_Type => Xref_Entry_Number,
92 Table_Initial => Alloc.Xrefs_Initial,
93 Table_Increment => Alloc.Xrefs_Increment,
94 Table_Name => "Xrefs");
96 -------------------------
97 -- Generate_Definition --
98 -------------------------
100 procedure Generate_Definition (E : Entity_Id) is
105 pragma Assert (Nkind (E) in N_Entity);
107 -- Note that we do not test Xref_Entity_Letters here. It is too early
108 -- to do so, since we are often called before the entity is fully
109 -- constructed, so that the Ekind is still E_Void.
113 -- Definition must come from source
115 -- We make an exception for subprogram child units that have no spec.
116 -- For these we generate a subprogram declaration for library use,
117 -- and the corresponding entity does not come from source.
118 -- Nevertheless, all references will be attached to it and we have
119 -- to treat is as coming from user code.
121 and then (Comes_From_Source (E) or else Is_Child_Unit (E))
123 -- And must have a reasonable source location that is not
124 -- within an instance (all entities in instances are ignored)
126 and then Sloc (E) > No_Location
127 and then Instantiation_Location (Sloc (E)) = No_Location
129 -- And must be a non-internal name from the main source unit
131 and then In_Extended_Main_Source_Unit (E)
132 and then not Is_Internal_Name (Chars (E))
134 Xrefs.Increment_Last;
136 Loc := Original_Location (Sloc (E));
138 Xrefs.Table (Indx).Ent := E;
139 Xrefs.Table (Indx).Def := No_Location;
140 Xrefs.Table (Indx).Loc := No_Location;
141 Xrefs.Table (Indx).Typ := ' ';
142 Xrefs.Table (Indx).Eun := Get_Source_Unit (Loc);
143 Xrefs.Table (Indx).Lun := No_Unit;
144 Set_Has_Xref_Entry (E);
146 if In_Inlined_Body then
150 end Generate_Definition;
152 ---------------------------------
153 -- Generate_Operator_Reference --
154 ---------------------------------
156 procedure Generate_Operator_Reference
161 if not In_Extended_Main_Source_Unit (N) then
165 -- If the operator is not a Standard operator, then we generate a real
166 -- reference to the user defined operator.
168 if Sloc (Entity (N)) /= Standard_Location then
169 Generate_Reference (Entity (N), N);
171 -- A reference to an implicit inequality operator is also a reference
172 -- to the user-defined equality.
174 if Nkind (N) = N_Op_Ne
175 and then not Comes_From_Source (Entity (N))
176 and then Present (Corresponding_Equality (Entity (N)))
178 Generate_Reference (Corresponding_Equality (Entity (N)), N);
181 -- For the case of Standard operators, we mark the result type as
182 -- referenced. This ensures that in the case where we are using a
183 -- derived operator, we mark an entity of the unit that implicitly
184 -- defines this operator as used. Otherwise we may think that no entity
185 -- of the unit is used. The actual entity marked as referenced is the
186 -- first subtype, which is the relevant user defined entity.
188 -- Note: we only do this for operators that come from source. The
189 -- generated code sometimes reaches for entities that do not need to be
190 -- explicitly visible (for example, when we expand the code for
191 -- comparing two record objects, the fields of the record may not be
194 elsif Comes_From_Source (N) then
195 Set_Referenced (First_Subtype (T));
197 end Generate_Operator_Reference;
199 ------------------------
200 -- Generate_Reference --
201 ------------------------
203 procedure Generate_Reference
206 Typ : Character := 'r';
207 Set_Ref : Boolean := True;
208 Force : Boolean := False)
218 -- Used for call to Find_Actual
221 -- If Formal is non-Empty, then its Ekind, otherwise E_Void
223 function Is_On_LHS (Node : Node_Id) return Boolean;
224 -- Used to check if a node is on the left hand side of an assignment.
225 -- The following cases are handled:
227 -- Variable Node is a direct descendant of left hand side of an
228 -- assignment statement.
230 -- Prefix Of an indexed or selected component that is present in
231 -- a subtree rooted by an assignment statement. There is
232 -- no restriction of nesting of components, thus cases
233 -- such as A.B (C).D are handled properly. However a prefix
234 -- of a dereference (either implicit or explicit) is never
235 -- considered as on a LHS.
237 -- Out param Same as above cases, but OUT parameter
239 function OK_To_Set_Referenced return Boolean;
240 -- Returns True if the Referenced flag can be set. There are a few
241 -- exceptions where we do not want to set this flag, see body for
242 -- details of these exceptional cases.
248 -- ??? There are several routines here and there that perform a similar
249 -- (but subtly different) computation, which should be factored:
251 -- Sem_Util.May_Be_Lvalue
252 -- Sem_Util.Known_To_Be_Assigned
253 -- Exp_Ch2.Expand_Entry_Parameter.In_Assignment_Context
254 -- Exp_Smem.Is_Out_Actual
256 function Is_On_LHS (Node : Node_Id) return Boolean is
262 -- Only identifiers are considered, is this necessary???
264 if Nkind (Node) /= N_Identifier then
268 -- Immediate return if appeared as OUT parameter
270 if Kind = E_Out_Parameter then
274 -- Search for assignment statement subtree root
281 if K = N_Assignment_Statement then
284 -- Check whether the parent is a component and the current node is
285 -- its prefix, but return False if the current node has an access
286 -- type, as in that case the selected or indexed component is an
287 -- implicit dereference, and the LHS is the designated object, not
288 -- the access object.
290 -- ??? case of a slice assignment?
292 -- ??? Note that in some cases this is called too early
293 -- (see comments in Sem_Ch8.Find_Direct_Name), at a point where
294 -- the tree is not fully typed yet. In that case we may lack
295 -- an Etype for N, and we must disable the check for an implicit
296 -- dereference. If the dereference is on an LHS, this causes a
299 elsif (K = N_Selected_Component or else K = N_Indexed_Component)
300 and then Prefix (P) = N
301 and then not (Present (Etype (N))
303 Is_Access_Type (Etype (N)))
307 -- All other cases, definitely not on left side
315 ---------------------------
316 -- OK_To_Set_Referenced --
317 ---------------------------
319 function OK_To_Set_Referenced return Boolean is
323 -- A reference from a pragma Unreferenced or pragma Unmodified or
324 -- pragma Warnings does not cause the Referenced flag to be set.
325 -- This avoids silly warnings about things being referenced and
326 -- not assigned when the only reference is from the pragma.
328 if Nkind (N) = N_Identifier then
331 if Nkind (P) = N_Pragma_Argument_Association then
334 if Nkind (P) = N_Pragma then
335 if Pragma_Name (P) = Name_Warnings
337 Pragma_Name (P) = Name_Unmodified
339 Pragma_Name (P) = Name_Unreferenced
348 end OK_To_Set_Referenced;
350 -- Start of processing for Generate_Reference
353 pragma Assert (Nkind (E) in N_Entity);
354 Find_Actual (N, Formal, Call);
356 if Present (Formal) then
357 Kind := Ekind (Formal);
362 -- Check for obsolescent reference to package ASCII. GNAT treats this
363 -- element of annex J specially since in practice, programs make a lot
364 -- of use of this feature, so we don't include it in the set of features
365 -- diagnosed when Warn_On_Obsolescent_Features mode is set. However we
366 -- are required to note it as a violation of the RM defined restriction.
368 if E = Standard_ASCII then
369 Check_Restriction (No_Obsolescent_Features, N);
372 -- Check for reference to entity marked with Is_Obsolescent
374 -- Note that we always allow obsolescent references in the compiler
375 -- itself and the run time, since we assume that we know what we are
376 -- doing in such cases. For example the calls in Ada.Characters.Handling
377 -- to its own obsolescent subprograms are just fine.
379 -- In any case we do not generate warnings within the extended source
380 -- unit of the entity in question, since we assume the source unit
381 -- itself knows what is going on (and for sure we do not want silly
382 -- warnings, e.g. on the end line of an obsolescent procedure body).
384 if Is_Obsolescent (E)
385 and then not GNAT_Mode
386 and then not In_Extended_Main_Source_Unit (E)
388 Check_Restriction (No_Obsolescent_Features, N);
390 if Warn_On_Obsolescent_Feature then
391 Output_Obsolescent_Entity_Warnings (N, E);
395 -- Warn if reference to Ada 2005 entity not in Ada 2005 mode. We only
396 -- detect real explicit references (modifications and references).
398 if Comes_From_Source (N)
399 and then Is_Ada_2005_Only (E)
400 and then Ada_Version < Ada_05
401 and then Warn_On_Ada_2005_Compatibility
402 and then (Typ = 'm' or else Typ = 'r')
404 Error_Msg_NE ("& is only defined in Ada 2005?", N, E);
407 -- Never collect references if not in main source unit. However, we omit
408 -- this test if Typ is 'e' or 'k', since these entries are structural,
409 -- and it is useful to have them in units that reference packages as
410 -- well as units that define packages. We also omit the test for the
411 -- case of 'p' since we want to include inherited primitive operations
412 -- from other packages.
414 -- We also omit this test is this is a body reference for a subprogram
415 -- instantiation. In this case the reference is to the generic body,
416 -- which clearly need not be in the main unit containing the instance.
417 -- For the same reason we accept an implicit reference generated for
418 -- a default in an instance.
420 if not In_Extended_Main_Source_Unit (N) then
425 or else (Typ = 'b' and then Is_Generic_Instance (E))
433 -- For reference type p, the entity must be in main source unit
435 if Typ = 'p' and then not In_Extended_Main_Source_Unit (E) then
439 -- Unless the reference is forced, we ignore references where the
440 -- reference itself does not come from source.
442 if not Force and then not Comes_From_Source (N) then
446 -- Deal with setting entity as referenced, unless suppressed. Note that
447 -- we still do Set_Referenced on entities that do not come from source.
448 -- This situation arises when we have a source reference to a derived
449 -- operation, where the derived operation itself does not come from
450 -- source, but we still want to mark it as referenced, since we really
451 -- are referencing an entity in the corresponding package (this avoids
452 -- wrong complaints that the package contains no referenced entities).
456 -- Assignable object appearing on left side of assignment or as
460 and then Is_On_LHS (N)
461 and then Ekind (E) /= E_In_Out_Parameter
463 -- For objects that are renamings, just set as simply referenced
464 -- we do not try to do assignment type tracking in this case.
466 if Present (Renamed_Object (E)) then
469 -- Out parameter case
471 elsif Kind = E_Out_Parameter then
473 -- If warning mode for all out parameters is set, or this is
474 -- the only warning parameter, then we want to mark this for
475 -- later warning logic by setting Referenced_As_Out_Parameter
477 if Warn_On_Modified_As_Out_Parameter (Formal) then
478 Set_Referenced_As_Out_Parameter (E, True);
479 Set_Referenced_As_LHS (E, False);
481 -- For OUT parameter not covered by the above cases, we simply
482 -- regard it as a normal reference (in this case we do not
483 -- want any of the warning machinery for out parameters).
489 -- For the left hand of an assignment case, we do nothing here.
490 -- The processing for Analyze_Assignment_Statement will set the
491 -- Referenced_As_LHS flag.
497 -- Check for a reference in a pragma that should not count as a
498 -- making the variable referenced for warning purposes.
500 elsif Is_Non_Significant_Pragma_Reference (N) then
503 -- A reference in an attribute definition clause does not count as a
504 -- reference except for the case of Address. The reason that 'Address
505 -- is an exception is that it creates an alias through which the
506 -- variable may be referenced.
508 elsif Nkind (Parent (N)) = N_Attribute_Definition_Clause
509 and then Chars (Parent (N)) /= Name_Address
510 and then N = Name (Parent (N))
514 -- Constant completion does not count as a reference
517 and then Ekind (E) = E_Constant
521 -- Record representation clause does not count as a reference
523 elsif Nkind (N) = N_Identifier
524 and then Nkind (Parent (N)) = N_Record_Representation_Clause
528 -- Discriminants do not need to produce a reference to record type
531 and then Nkind (Parent (N)) = N_Discriminant_Specification
538 -- Special processing for IN OUT parameters, where we have an
539 -- implicit assignment to a simple variable.
541 if Kind = E_In_Out_Parameter
542 and then Is_Assignable (E)
544 -- For sure this counts as a normal read reference
547 Set_Last_Assignment (E, Empty);
549 -- We count it as being referenced as an out parameter if the
550 -- option is set to warn on all out parameters, except that we
551 -- have a special exclusion for an intrinsic subprogram, which
552 -- is most likely an instantiation of Unchecked_Deallocation
553 -- which we do not want to consider as an assignment since it
554 -- generates false positives. We also exclude the case of an
555 -- IN OUT parameter if the name of the procedure is Free,
556 -- since we suspect similar semantics.
558 if Warn_On_All_Unread_Out_Parameters
559 and then Is_Entity_Name (Name (Call))
560 and then not Is_Intrinsic_Subprogram (Entity (Name (Call)))
561 and then Chars (Name (Call)) /= Name_Free
563 Set_Referenced_As_Out_Parameter (E, True);
564 Set_Referenced_As_LHS (E, False);
567 -- Any other occurrence counts as referencing the entity
569 elsif OK_To_Set_Referenced then
572 -- If variable, this is an OK reference after an assignment
573 -- so we can clear the Last_Assignment indication.
575 if Is_Assignable (E) then
576 Set_Last_Assignment (E, Empty);
581 -- Check for pragma Unreferenced given and reference is within
582 -- this source unit (occasion for possible warning to be issued).
584 if Has_Pragma_Unreferenced (E)
585 and then In_Same_Extended_Unit (E, N)
587 -- A reference as a named parameter in a call does not count
588 -- as a violation of pragma Unreferenced for this purpose...
590 if Nkind (N) = N_Identifier
591 and then Nkind (Parent (N)) = N_Parameter_Association
592 and then Selector_Name (Parent (N)) = N
596 -- ... Neither does a reference to a variable on the left side
599 elsif Is_On_LHS (N) then
602 -- For entry formals, we want to place the warning message on the
603 -- corresponding entity in the accept statement. The current scope
604 -- is the body of the accept, so we find the formal whose name
605 -- matches that of the entry formal (there is no link between the
606 -- two entities, and the one in the accept statement is only used
607 -- for conformance checking).
609 elsif Ekind (Scope (E)) = E_Entry then
614 BE := First_Entity (Current_Scope);
615 while Present (BE) loop
616 if Chars (BE) = Chars (E) then
618 ("?pragma Unreferenced given for&!", N, BE);
626 -- Here we issue the warning, since this is a real reference
629 Error_Msg_NE ("?pragma Unreferenced given for&!", N, E);
633 -- If this is a subprogram instance, mark as well the internal
634 -- subprogram in the wrapper package, which may be a visible
637 if Is_Overloadable (E)
638 and then Is_Generic_Instance (E)
639 and then Present (Alias (E))
641 Set_Referenced (Alias (E));
645 -- Generate reference if all conditions are met:
648 -- Cross referencing must be active
652 -- The entity must be one for which we collect references
654 and then Xref_Entity_Letters (Ekind (E)) /= ' '
656 -- Both Sloc values must be set to something sensible
658 and then Sloc (E) > No_Location
659 and then Sloc (N) > No_Location
661 -- We ignore references from within an instance, except for default
662 -- subprograms, for which we generate an implicit reference.
665 (Instantiation_Location (Sloc (N)) = No_Location or else Typ = 'i')
667 -- Ignore dummy references
671 if Nkind (N) = N_Identifier
673 Nkind (N) = N_Defining_Identifier
677 Nkind (N) = N_Defining_Operator_Symbol
679 Nkind (N) = N_Operator_Symbol
681 (Nkind (N) = N_Character_Literal
682 and then Sloc (Entity (N)) /= Standard_Location)
684 Nkind (N) = N_Defining_Character_Literal
688 elsif Nkind (N) = N_Expanded_Name
690 Nkind (N) = N_Selected_Component
692 Nod := Selector_Name (N);
698 -- Normal case of source entity comes from source
700 if Comes_From_Source (E) then
703 -- Entity does not come from source, but is a derived subprogram and
704 -- the derived subprogram comes from source (after one or more
705 -- derivations) in which case the reference is to parent subprogram.
707 elsif Is_Overloadable (E)
708 and then Present (Alias (E))
711 while not Comes_From_Source (Ent) loop
712 if No (Alias (Ent)) then
719 -- The internally created defining entity for a child subprogram
720 -- that has no previous spec has valid references.
722 elsif Is_Overloadable (E)
723 and then Is_Child_Unit (E)
727 -- Record components of discriminated subtypes or derived types must
728 -- be treated as references to the original component.
730 elsif Ekind (E) = E_Component
731 and then Comes_From_Source (Original_Record_Component (E))
733 Ent := Original_Record_Component (E);
735 -- If this is an expanded reference to a discriminant, recover the
736 -- original discriminant, which gets the reference.
738 elsif Ekind (E) = E_In_Parameter
739 and then Present (Discriminal_Link (E))
741 Ent := Discriminal_Link (E);
742 Set_Referenced (Ent);
744 -- Ignore reference to any other entity that is not from source
750 -- Record reference to entity
752 Ref := Original_Location (Sloc (Nod));
753 Def := Original_Location (Sloc (Ent));
755 Xrefs.Increment_Last;
758 Xrefs.Table (Indx).Loc := Ref;
760 -- Overriding operations are marked with 'P'
763 and then Is_Subprogram (N)
764 and then Is_Overriding_Operation (N)
766 Xrefs.Table (Indx).Typ := 'P';
768 Xrefs.Table (Indx).Typ := Typ;
771 Xrefs.Table (Indx).Eun := Get_Source_Unit (Def);
772 Xrefs.Table (Indx).Lun := Get_Source_Unit (Ref);
773 Xrefs.Table (Indx).Ent := Ent;
774 Set_Has_Xref_Entry (Ent);
776 end Generate_Reference;
778 -----------------------------------
779 -- Generate_Reference_To_Formals --
780 -----------------------------------
782 procedure Generate_Reference_To_Formals (E : Entity_Id) is
786 if Is_Generic_Subprogram (E) then
787 Formal := First_Entity (E);
789 while Present (Formal)
790 and then not Is_Formal (Formal)
792 Next_Entity (Formal);
796 Formal := First_Formal (E);
799 while Present (Formal) loop
800 if Ekind (Formal) = E_In_Parameter then
802 if Nkind (Parameter_Type (Parent (Formal)))
803 = N_Access_Definition
805 Generate_Reference (E, Formal, '^', False);
807 Generate_Reference (E, Formal, '>', False);
810 elsif Ekind (Formal) = E_In_Out_Parameter then
811 Generate_Reference (E, Formal, '=', False);
814 Generate_Reference (E, Formal, '<', False);
817 Next_Formal (Formal);
819 end Generate_Reference_To_Formals;
821 -------------------------------------------
822 -- Generate_Reference_To_Generic_Formals --
823 -------------------------------------------
825 procedure Generate_Reference_To_Generic_Formals (E : Entity_Id) is
829 Formal := First_Entity (E);
830 while Present (Formal) loop
831 if Comes_From_Source (Formal) then
832 Generate_Reference (E, Formal, 'z', False);
835 Next_Entity (Formal);
837 end Generate_Reference_To_Generic_Formals;
843 procedure Initialize is
848 -----------------------
849 -- Output_References --
850 -----------------------
852 procedure Output_References is
854 procedure Get_Type_Reference
856 Tref : out Entity_Id;
857 Left : out Character;
858 Right : out Character);
859 -- Given an Entity_Id Ent, determines whether a type reference is
860 -- required. If so, Tref is set to the entity for the type reference
861 -- and Left and Right are set to the left/right brackets to be output
862 -- for the reference. If no type reference is required, then Tref is
863 -- set to Empty, and Left/Right are set to space.
865 procedure Output_Import_Export_Info (Ent : Entity_Id);
866 -- Output language and external name information for an interfaced
867 -- entity, using the format <language, external_name>,
869 ------------------------
870 -- Get_Type_Reference --
871 ------------------------
873 procedure Get_Type_Reference
875 Tref : out Entity_Id;
876 Left : out Character;
877 Right : out Character)
882 -- See if we have a type reference
891 -- Processing for types
893 if Is_Type (Tref) then
897 if Base_Type (Tref) = Tref then
899 -- If derived, then get first subtype
901 if Tref /= Etype (Tref) then
902 Tref := First_Subtype (Etype (Tref));
904 -- Set brackets for derived type, but don't override
905 -- pointer case since the fact that something is a
906 -- pointer is more important.
913 -- If non-derived ptr, get directly designated type.
914 -- If the type has a full view, all references are on the
915 -- partial view, that is seen first.
917 elsif Is_Access_Type (Tref) then
918 Tref := Directly_Designated_Type (Tref);
922 elsif Is_Private_Type (Tref)
923 and then Present (Full_View (Tref))
925 if Is_Access_Type (Full_View (Tref)) then
926 Tref := Directly_Designated_Type (Full_View (Tref));
930 -- If the full view is an array type, we also retrieve
931 -- the corresponding component type, because the ali
932 -- entry already indicates that this is an array.
934 elsif Is_Array_Type (Full_View (Tref)) then
935 Tref := Component_Type (Full_View (Tref));
940 -- If non-derived array, get component type. Skip component
941 -- type for case of String or Wide_String, saves worthwhile
944 elsif Is_Array_Type (Tref)
945 and then Tref /= Standard_String
946 and then Tref /= Standard_Wide_String
948 Tref := Component_Type (Tref);
952 -- For other non-derived base types, nothing
958 -- For a subtype, go to ancestor subtype
961 Tref := Ancestor_Subtype (Tref);
963 -- If no ancestor subtype, go to base type
966 Tref := Base_Type (Sav);
970 -- For objects, functions, enum literals, just get type from
973 elsif Is_Object (Tref)
974 or else Ekind (Tref) = E_Enumeration_Literal
975 or else Ekind (Tref) = E_Function
976 or else Ekind (Tref) = E_Operator
978 Tref := Etype (Tref);
980 -- For anything else, exit
986 -- Exit if no type reference, or we are stuck in some loop trying
987 -- to find the type reference, or if the type is standard void
988 -- type (the latter is an implementation artifact that should not
989 -- show up in the generated cross-references).
993 or else Tref = Standard_Void_Type;
995 -- If we have a usable type reference, return, otherwise keep
996 -- looking for something useful (we are looking for something
997 -- that either comes from source or standard)
999 if Sloc (Tref) = Standard_Location
1000 or else Comes_From_Source (Tref)
1002 -- If the reference is a subtype created for a generic actual,
1003 -- go actual directly, the inner subtype is not user visible.
1005 if Nkind (Parent (Tref)) = N_Subtype_Declaration
1006 and then not Comes_From_Source (Parent (Tref))
1008 (Is_Wrapper_Package (Scope (Tref))
1009 or else Is_Generic_Instance (Scope (Tref)))
1011 Tref := First_Subtype (Base_Type (Tref));
1018 -- If we fall through the loop, no type reference
1023 end Get_Type_Reference;
1025 -------------------------------
1026 -- Output_Import_Export_Info --
1027 -------------------------------
1029 procedure Output_Import_Export_Info (Ent : Entity_Id) is
1030 Language_Name : Name_Id;
1031 Conv : constant Convention_Id := Convention (Ent);
1034 -- Generate language name from convention
1036 if Conv = Convention_C then
1037 Language_Name := Name_C;
1039 elsif Conv = Convention_CPP then
1040 Language_Name := Name_CPP;
1042 elsif Conv = Convention_Ada then
1043 Language_Name := Name_Ada;
1046 -- For the moment we ignore all other cases ???
1051 Write_Info_Char ('<');
1052 Get_Unqualified_Name_String (Language_Name);
1054 for J in 1 .. Name_Len loop
1055 Write_Info_Char (Name_Buffer (J));
1058 if Present (Interface_Name (Ent)) then
1059 Write_Info_Char (',');
1060 String_To_Name_Buffer (Strval (Interface_Name (Ent)));
1062 for J in 1 .. Name_Len loop
1063 Write_Info_Char (Name_Buffer (J));
1067 Write_Info_Char ('>');
1068 end Output_Import_Export_Info;
1070 -- Start of processing for Output_References
1073 if not Opt.Xref_Active then
1077 -- Before we go ahead and output the references we have a problem
1078 -- that needs dealing with. So far we have captured things that are
1079 -- definitely referenced by the main unit, or defined in the main
1080 -- unit. That's because we don't want to clutter up the ali file
1081 -- for this unit with definition lines for entities in other units
1082 -- that are not referenced.
1084 -- But there is a glitch. We may reference an entity in another unit,
1085 -- and it may have a type reference to an entity that is not directly
1086 -- referenced in the main unit, which may mean that there is no xref
1087 -- entry for this entity yet in the list of references.
1089 -- If we don't do something about this, we will end with an orphan type
1090 -- reference, i.e. it will point to an entity that does not appear
1091 -- within the generated references in the ali file. That is not good for
1092 -- tools using the xref information.
1094 -- To fix this, we go through the references adding definition entries
1095 -- for any unreferenced entities that can be referenced in a type
1096 -- reference. There is a recursion problem here, and that is dealt with
1097 -- by making sure that this traversal also traverses any entries that
1098 -- get added by the traversal.
1100 Handle_Orphan_Type_References : declare
1108 pragma Warnings (Off, L);
1109 pragma Warnings (Off, R);
1111 procedure New_Entry (E : Entity_Id);
1112 -- Make an additional entry into the Xref table for a type entity
1113 -- that is related to the current entity (parent, type ancestor,
1114 -- progenitor, etc.).
1120 procedure New_Entry (E : Entity_Id) is
1123 and then not Has_Xref_Entry (E)
1124 and then Sloc (E) > No_Location
1126 Xrefs.Increment_Last;
1128 Loc := Original_Location (Sloc (E));
1129 Xrefs.Table (Indx).Ent := E;
1130 Xrefs.Table (Indx).Loc := No_Location;
1131 Xrefs.Table (Indx).Eun := Get_Source_Unit (Loc);
1132 Xrefs.Table (Indx).Lun := No_Unit;
1133 Set_Has_Xref_Entry (E);
1137 -- Start of processing for Handle_Orphan_Type_References
1140 -- Note that this is not a for loop for a very good reason. The
1141 -- processing of items in the table can add new items to the table,
1142 -- and they must be processed as well.
1145 while J <= Xrefs.Last loop
1146 Ent := Xrefs.Table (J).Ent;
1147 Get_Type_Reference (Ent, Tref, L, R);
1150 and then not Has_Xref_Entry (Tref)
1151 and then Sloc (Tref) > No_Location
1155 if Is_Record_Type (Ent)
1156 and then Present (Interfaces (Ent))
1158 -- Add an entry for each one of the given interfaces
1159 -- implemented by type Ent.
1162 Elmt : Elmt_Id := First_Elmt (Interfaces (Ent));
1164 while Present (Elmt) loop
1165 New_Entry (Node (Elmt));
1172 -- Collect inherited primitive operations that may be declared in
1173 -- another unit and have no visible reference in the current one.
1176 and then Is_Tagged_Type (Ent)
1177 and then Is_Derived_Type (Ent)
1178 and then Ent = Base_Type (Ent)
1179 and then In_Extended_Main_Source_Unit (Ent)
1182 Op_List : constant Elist_Id := Primitive_Operations (Ent);
1186 function Parent_Op (E : Entity_Id) return Entity_Id;
1187 -- Find original operation, which may be inherited through
1188 -- several derivations.
1190 function Parent_Op (E : Entity_Id) return Entity_Id is
1191 Orig_Op : constant Entity_Id := Alias (E);
1193 if No (Orig_Op) then
1195 elsif not Comes_From_Source (E)
1196 and then not Has_Xref_Entry (Orig_Op)
1197 and then Comes_From_Source (Orig_Op)
1201 return Parent_Op (Orig_Op);
1206 Op := First_Elmt (Op_List);
1207 while Present (Op) loop
1208 Prim := Parent_Op (Node (Op));
1210 if Present (Prim) then
1211 Xrefs.Increment_Last;
1213 Loc := Original_Location (Sloc (Prim));
1214 Xrefs.Table (Indx).Ent := Prim;
1215 Xrefs.Table (Indx).Loc := No_Location;
1216 Xrefs.Table (Indx).Eun :=
1217 Get_Source_Unit (Sloc (Prim));
1218 Xrefs.Table (Indx).Lun := No_Unit;
1219 Set_Has_Xref_Entry (Prim);
1229 end Handle_Orphan_Type_References;
1231 -- Now we have all the references, including those for any embedded
1232 -- type references, so we can sort them, and output them.
1234 Output_Refs : declare
1236 Nrefs : Nat := Xrefs.Last;
1237 -- Number of references in table. This value may get reset (reduced)
1238 -- when we eliminate duplicate reference entries.
1240 Rnums : array (0 .. Nrefs) of Nat;
1241 -- This array contains numbers of references in the Xrefs table.
1242 -- This list is sorted in output order. The extra 0'th entry is
1243 -- convenient for the call to sort. When we sort the table, we
1244 -- move the entries in Rnums around, but we do not move the
1245 -- original table entries.
1247 Curxu : Unit_Number_Type;
1248 -- Current xref unit
1250 Curru : Unit_Number_Type;
1251 -- Current reference unit for one entity
1253 Cursrc : Source_Buffer_Ptr;
1254 -- Current xref unit source text
1259 Curnam : String (1 .. Name_Buffer'Length);
1261 -- Simple name and length of current entity
1263 Curdef : Source_Ptr;
1264 -- Original source location for current entity
1267 -- Current reference location
1270 -- Entity type character
1276 -- Renaming reference
1278 Trunit : Unit_Number_Type;
1279 -- Unit number for type reference
1281 function Lt (Op1, Op2 : Natural) return Boolean;
1282 -- Comparison function for Sort call
1284 function Name_Change (X : Entity_Id) return Boolean;
1285 -- Determines if entity X has a different simple name from Curent
1287 procedure Move (From : Natural; To : Natural);
1288 -- Move procedure for Sort call
1290 package Sorting is new GNAT.Heap_Sort_G (Move, Lt);
1296 function Lt (Op1, Op2 : Natural) return Boolean is
1297 T1 : Xref_Entry renames Xrefs.Table (Rnums (Nat (Op1)));
1298 T2 : Xref_Entry renames Xrefs.Table (Rnums (Nat (Op2)));
1301 -- First test: if entity is in different unit, sort by unit
1303 if T1.Eun /= T2.Eun then
1304 return Dependency_Num (T1.Eun) < Dependency_Num (T2.Eun);
1306 -- Second test: within same unit, sort by entity Sloc
1308 elsif T1.Def /= T2.Def then
1309 return T1.Def < T2.Def;
1311 -- Third test: sort definitions ahead of references
1313 elsif T1.Loc = No_Location then
1316 elsif T2.Loc = No_Location then
1319 -- Fourth test: for same entity, sort by reference location unit
1321 elsif T1.Lun /= T2.Lun then
1322 return Dependency_Num (T1.Lun) < Dependency_Num (T2.Lun);
1324 -- Fifth test: order of location within referencing unit
1326 elsif T1.Loc /= T2.Loc then
1327 return T1.Loc < T2.Loc;
1329 -- Finally, for two locations at the same address, we prefer
1330 -- the one that does NOT have the type 'r' so that a modification
1331 -- or extension takes preference, when there are more than one
1332 -- reference at the same location.
1335 return T2.Typ = 'r';
1343 procedure Move (From : Natural; To : Natural) is
1345 Rnums (Nat (To)) := Rnums (Nat (From));
1352 -- Why a string comparison here??? Why not compare Name_Id values???
1354 function Name_Change (X : Entity_Id) return Boolean is
1356 Get_Unqualified_Name_String (Chars (X));
1358 if Name_Len /= Curlen then
1362 return Name_Buffer (1 .. Curlen) /= Curnam (1 .. Curlen);
1366 -- Start of processing for Output_Refs
1369 -- Capture the definition Sloc values. We delay doing this till now,
1370 -- since at the time the reference or definition is made, private
1371 -- types may be swapped, and the Sloc value may be incorrect. We
1372 -- also set up the pointer vector for the sort.
1374 for J in 1 .. Nrefs loop
1376 Xrefs.Table (J).Def :=
1377 Original_Location (Sloc (Xrefs.Table (J).Ent));
1380 -- Sort the references
1382 Sorting.Sort (Integer (Nrefs));
1384 -- Eliminate duplicate entries
1387 NR : constant Nat := Nrefs;
1390 -- We need this test for NR because if we force ALI file
1391 -- generation in case of errors detected, it may be the case
1392 -- that Nrefs is 0, so we should not reset it here
1397 for J in 2 .. NR loop
1398 if Xrefs.Table (Rnums (J)) /=
1399 Xrefs.Table (Rnums (Nrefs))
1402 Rnums (Nrefs) := Rnums (J);
1408 -- Initialize loop through references
1412 Curdef := No_Location;
1414 Crloc := No_Location;
1416 -- Loop to output references
1418 for Refno in 1 .. Nrefs loop
1419 Output_One_Ref : declare
1425 pragma Warnings (Off, WC);
1426 pragma Warnings (Off, Err);
1428 XE : Xref_Entry renames Xrefs.Table (Rnums (Refno));
1429 -- The current entry to be accessed
1432 -- Used to index into source buffer to get entity name
1436 -- Used for {} or <> or () for type reference
1438 procedure Check_Type_Reference
1440 List_Interface : Boolean);
1441 -- Find whether there is a meaningful type reference for
1442 -- Ent, and display it accordingly. If List_Interface is
1443 -- true, then Ent is a progenitor interface of the current
1444 -- type entity being listed. In that case list it as is,
1445 -- without looking for a type reference for it.
1447 procedure Output_Instantiation_Refs (Loc : Source_Ptr);
1448 -- Recursive procedure to output instantiation references for
1449 -- the given source ptr in [file|line[...]] form. No output
1450 -- if the given location is not a generic template reference.
1452 procedure Output_Overridden_Op (Old_E : Entity_Id);
1453 -- For a subprogram that is overriding, display information
1454 -- about the inherited operation that it overrides.
1456 --------------------------
1457 -- Check_Type_Reference --
1458 --------------------------
1460 procedure Check_Type_Reference
1462 List_Interface : Boolean)
1465 if List_Interface then
1467 -- This is a progenitor interface of the type for which
1468 -- xref information is being generated.
1475 Get_Type_Reference (Ent, Tref, Left, Right);
1478 if Present (Tref) then
1480 -- Case of standard entity, output name
1482 if Sloc (Tref) = Standard_Location then
1483 Write_Info_Char (Left);
1484 Write_Info_Name (Chars (Tref));
1485 Write_Info_Char (Right);
1487 -- Case of source entity, output location
1490 Write_Info_Char (Left);
1491 Trunit := Get_Source_Unit (Sloc (Tref));
1493 if Trunit /= Curxu then
1494 Write_Info_Nat (Dependency_Num (Trunit));
1495 Write_Info_Char ('|');
1499 (Int (Get_Logical_Line_Number (Sloc (Tref))));
1507 Ctyp := Xref_Entity_Letters (Ekind (Ent));
1510 and then Present (Full_View (Ent))
1512 Ent := Underlying_Type (Ent);
1514 if Present (Ent) then
1515 Ctyp := Xref_Entity_Letters (Ekind (Ent));
1519 Write_Info_Char (Ctyp);
1523 (Int (Get_Column_Number (Sloc (Tref))));
1525 -- If the type comes from an instantiation, add the
1526 -- corresponding info.
1528 Output_Instantiation_Refs (Sloc (Tref));
1529 Write_Info_Char (Right);
1532 end Check_Type_Reference;
1534 -------------------------------
1535 -- Output_Instantiation_Refs --
1536 -------------------------------
1538 procedure Output_Instantiation_Refs (Loc : Source_Ptr) is
1539 Iloc : constant Source_Ptr := Instantiation_Location (Loc);
1540 Lun : Unit_Number_Type;
1541 Cu : constant Unit_Number_Type := Curru;
1544 -- Nothing to do if this is not an instantiation
1546 if Iloc = No_Location then
1550 -- Output instantiation reference
1552 Write_Info_Char ('[');
1553 Lun := Get_Source_Unit (Iloc);
1555 if Lun /= Curru then
1557 Write_Info_Nat (Dependency_Num (Curru));
1558 Write_Info_Char ('|');
1561 Write_Info_Nat (Int (Get_Logical_Line_Number (Iloc)));
1563 -- Recursive call to get nested instantiations
1565 Output_Instantiation_Refs (Iloc);
1567 -- Output final ] after call to get proper nesting
1569 Write_Info_Char (']');
1572 end Output_Instantiation_Refs;
1574 --------------------------
1575 -- Output_Overridden_Op --
1576 --------------------------
1578 procedure Output_Overridden_Op (Old_E : Entity_Id) is
1582 -- The overridden operation has an implicit declaration
1583 -- at the point of derivation. What we want to display
1584 -- is the original operation, which has the actual body
1585 -- (or abstract declaration) that is being overridden.
1586 -- The overridden operation is not always set, e.g. when
1587 -- it is a predefined operator.
1592 elsif Present (Alias (Old_E)) then
1593 Op := Alias (Old_E);
1600 and then Sloc (Op) /= Standard_Location
1603 Loc : constant Source_Ptr := Sloc (Op);
1604 Par_Unit : constant Unit_Number_Type :=
1605 Get_Source_Unit (Loc);
1608 Write_Info_Char ('<');
1610 if Par_Unit /= Curxu then
1611 Write_Info_Nat (Dependency_Num (Par_Unit));
1612 Write_Info_Char ('|');
1615 Write_Info_Nat (Int (Get_Logical_Line_Number (Loc)));
1616 Write_Info_Char ('p');
1617 Write_Info_Nat (Int (Get_Column_Number (Loc)));
1618 Write_Info_Char ('>');
1621 end Output_Overridden_Op;
1623 -- Start of processing for Output_One_Ref
1627 Ctyp := Xref_Entity_Letters (Ekind (Ent));
1629 -- Skip reference if it is the only reference to an entity,
1630 -- and it is an END line reference, and the entity is not in
1631 -- the current extended source. This prevents junk entries
1632 -- consisting only of packages with END lines, where no
1633 -- entity from the package is actually referenced.
1636 and then Ent /= Curent
1637 and then (Refno = Nrefs or else
1638 Ent /= Xrefs.Table (Rnums (Refno + 1)).Ent)
1640 not In_Extended_Main_Source_Unit (Ent)
1645 -- For private type, get full view type
1648 and then Present (Full_View (XE.Ent))
1650 Ent := Underlying_Type (Ent);
1652 if Present (Ent) then
1653 Ctyp := Xref_Entity_Letters (Ekind (Ent));
1657 -- Special exception for Boolean
1659 if Ctyp = 'E' and then Is_Boolean_Type (Ent) then
1663 -- For variable reference, get corresponding type
1666 Ent := Etype (XE.Ent);
1667 Ctyp := Fold_Lower (Xref_Entity_Letters (Ekind (Ent)));
1669 -- If variable is private type, get full view type
1672 and then Present (Full_View (Etype (XE.Ent)))
1674 Ent := Underlying_Type (Etype (XE.Ent));
1676 if Present (Ent) then
1677 Ctyp := Fold_Lower (Xref_Entity_Letters (Ekind (Ent)));
1680 elsif Is_Generic_Type (Ent) then
1682 -- If the type of the entity is a generic private type,
1683 -- there is no usable full view, so retain the indication
1684 -- that this is an object.
1689 -- Special handling for access parameter
1692 K : constant Entity_Kind := Ekind (Etype (XE.Ent));
1695 if (K = E_Anonymous_Access_Type
1697 K = E_Anonymous_Access_Subprogram_Type
1699 E_Anonymous_Access_Protected_Subprogram_Type)
1700 and then Is_Formal (XE.Ent)
1704 -- Special handling for Boolean
1706 elsif Ctyp = 'e' and then Is_Boolean_Type (Ent) then
1712 -- Special handling for abstract types and operations
1714 if Is_Overloadable (XE.Ent)
1715 and then Is_Abstract_Subprogram (XE.Ent)
1718 Ctyp := 'x'; -- Abstract procedure
1720 elsif Ctyp = 'V' then
1721 Ctyp := 'y'; -- Abstract function
1724 elsif Is_Type (XE.Ent)
1725 and then Is_Abstract_Type (XE.Ent)
1727 if Is_Interface (XE.Ent) then
1730 elsif Ctyp = 'R' then
1731 Ctyp := 'H'; -- Abstract type
1735 -- Only output reference if interesting type of entity, and
1736 -- suppress self references, except for bodies that act as
1737 -- specs. Also suppress definitions of body formals (we only
1738 -- treat these as references, and the references were
1739 -- separately recorded).
1742 or else (XE.Loc = XE.Def
1745 or else not Is_Subprogram (XE.Ent)))
1746 or else (Is_Formal (XE.Ent)
1747 and then Present (Spec_Entity (XE.Ent)))
1752 -- Start new Xref section if new xref unit
1754 if XE.Eun /= Curxu then
1755 if Write_Info_Col > 1 then
1760 Cursrc := Source_Text (Source_Index (Curxu));
1762 Write_Info_Initiate ('X');
1763 Write_Info_Char (' ');
1764 Write_Info_Nat (Dependency_Num (XE.Eun));
1765 Write_Info_Char (' ');
1766 Write_Info_Name (Reference_Name (Source_Index (XE.Eun)));
1769 -- Start new Entity line if new entity. Note that we
1770 -- consider two entities the same if they have the same
1771 -- name and source location. This causes entities in
1772 -- instantiations to be treated as though they referred
1779 (Name_Change (XE.Ent) or else XE.Def /= Curdef))
1784 Get_Unqualified_Name_String (Chars (XE.Ent));
1786 Curnam (1 .. Curlen) := Name_Buffer (1 .. Curlen);
1788 if Write_Info_Col > 1 then
1792 -- Write column number information
1794 Write_Info_Nat (Int (Get_Logical_Line_Number (XE.Def)));
1795 Write_Info_Char (Ctyp);
1796 Write_Info_Nat (Int (Get_Column_Number (XE.Def)));
1798 -- Write level information
1800 Write_Level_Info : declare
1801 function Is_Visible_Generic_Entity
1802 (E : Entity_Id) return Boolean;
1803 -- Check whether E is declared in the visible part
1804 -- of a generic package. For source navigation
1805 -- purposes, treat this as a visible entity.
1807 function Is_Private_Record_Component
1808 (E : Entity_Id) return Boolean;
1809 -- Check whether E is a non-inherited component of a
1810 -- private extension. Even if the enclosing record is
1811 -- public, we want to treat the component as private
1812 -- for navigation purposes.
1814 ---------------------------------
1815 -- Is_Private_Record_Component --
1816 ---------------------------------
1818 function Is_Private_Record_Component
1819 (E : Entity_Id) return Boolean
1821 S : constant Entity_Id := Scope (E);
1824 Ekind (E) = E_Component
1825 and then Nkind (Declaration_Node (S)) =
1826 N_Private_Extension_Declaration
1827 and then Original_Record_Component (E) = E;
1828 end Is_Private_Record_Component;
1830 -------------------------------
1831 -- Is_Visible_Generic_Entity --
1832 -------------------------------
1834 function Is_Visible_Generic_Entity
1835 (E : Entity_Id) return Boolean
1840 -- The Present check here is an error defense
1842 if Present (Scope (E))
1843 and then Ekind (Scope (E)) /= E_Generic_Package
1849 while Present (Par) loop
1851 Nkind (Par) = N_Generic_Package_Declaration
1853 -- Entity is a generic formal
1858 Nkind (Parent (Par)) = N_Package_Specification
1861 Is_List_Member (Par)
1862 and then List_Containing (Par) =
1863 Visible_Declarations (Parent (Par));
1865 Par := Parent (Par);
1870 end Is_Visible_Generic_Entity;
1872 -- Start of processing for Write_Level_Info
1875 if Is_Hidden (Curent)
1876 or else Is_Private_Record_Component (Curent)
1878 Write_Info_Char (' ');
1882 or else Is_Visible_Generic_Entity (Curent)
1884 Write_Info_Char ('*');
1887 Write_Info_Char (' ');
1889 end Write_Level_Info;
1891 -- Output entity name. We use the occurrence from the
1892 -- actual source program at the definition point.
1894 P := Original_Location (Sloc (XE.Ent));
1896 -- Entity is character literal
1898 if Cursrc (P) = ''' then
1899 Write_Info_Char (Cursrc (P));
1900 Write_Info_Char (Cursrc (P + 1));
1901 Write_Info_Char (Cursrc (P + 2));
1903 -- Entity is operator symbol
1905 elsif Cursrc (P) = '"' or else Cursrc (P) = '%' then
1906 Write_Info_Char (Cursrc (P));
1911 Write_Info_Char (Cursrc (P2));
1912 exit when Cursrc (P2) = Cursrc (P);
1915 -- Entity is identifier
1919 if Is_Start_Of_Wide_Char (Cursrc, P) then
1920 Scan_Wide (Cursrc, P, WC, Err);
1921 elsif not Identifier_Char (Cursrc (P)) then
1928 -- Write out the identifier by copying the exact
1929 -- source characters used in its declaration. Note
1930 -- that this means wide characters will be in their
1931 -- original encoded form.
1934 Original_Location (Sloc (XE.Ent)) .. P - 1
1936 Write_Info_Char (Cursrc (J));
1940 -- See if we have a renaming reference
1942 if Is_Object (XE.Ent)
1943 and then Present (Renamed_Object (XE.Ent))
1945 Rref := Renamed_Object (XE.Ent);
1947 elsif Is_Overloadable (XE.Ent)
1948 and then Nkind (Parent (Declaration_Node (XE.Ent))) =
1949 N_Subprogram_Renaming_Declaration
1951 Rref := Name (Parent (Declaration_Node (XE.Ent)));
1953 elsif Ekind (XE.Ent) = E_Package
1954 and then Nkind (Declaration_Node (XE.Ent)) =
1955 N_Package_Renaming_Declaration
1957 Rref := Name (Declaration_Node (XE.Ent));
1963 if Present (Rref) then
1964 if Nkind (Rref) = N_Expanded_Name then
1965 Rref := Selector_Name (Rref);
1968 if Nkind (Rref) = N_Identifier
1969 or else Nkind (Rref) = N_Operator_Symbol
1973 -- For renamed array components, use the array name
1974 -- for the renamed entity, which reflect the fact that
1975 -- in general the whole array is aliased.
1977 elsif Nkind (Rref) = N_Indexed_Component then
1978 if Nkind (Prefix (Rref)) = N_Identifier then
1979 Rref := Prefix (Rref);
1980 elsif Nkind (Prefix (Rref)) = N_Expanded_Name then
1981 Rref := Selector_Name (Prefix (Rref));
1991 -- Write out renaming reference if we have one
1993 if Present (Rref) then
1994 Write_Info_Char ('=');
1996 (Int (Get_Logical_Line_Number (Sloc (Rref))));
1997 Write_Info_Char (':');
1999 (Int (Get_Column_Number (Sloc (Rref))));
2002 -- Indicate that the entity is in the unit of the current
2007 -- Write out information about generic parent, if entity
2010 if Is_Generic_Instance (XE.Ent) then
2012 Gen_Par : constant Entity_Id :=
2015 (Unit_Declaration_Node (XE.Ent)));
2016 Loc : constant Source_Ptr := Sloc (Gen_Par);
2017 Gen_U : constant Unit_Number_Type :=
2018 Get_Source_Unit (Loc);
2021 Write_Info_Char ('[');
2022 if Curru /= Gen_U then
2023 Write_Info_Nat (Dependency_Num (Gen_U));
2024 Write_Info_Char ('|');
2028 (Int (Get_Logical_Line_Number (Loc)));
2029 Write_Info_Char (']');
2033 -- See if we have a type reference and if so output
2035 Check_Type_Reference (XE.Ent, False);
2037 -- Additional information for types with progenitors
2039 if Is_Record_Type (XE.Ent)
2040 and then Present (Interfaces (XE.Ent))
2043 Elmt : Elmt_Id := First_Elmt (Interfaces (XE.Ent));
2045 while Present (Elmt) loop
2046 Check_Type_Reference (Node (Elmt), True);
2051 -- For array types, list index types as well.
2052 -- (This is not C, indices have distinct types).
2054 elsif Is_Array_Type (XE.Ent) then
2058 Indx := First_Index (XE.Ent);
2059 while Present (Indx) loop
2060 Check_Type_Reference
2061 (First_Subtype (Etype (Indx)), True);
2067 -- If the entity is an overriding operation, write info
2068 -- on operation that was overridden.
2070 if Is_Subprogram (XE.Ent)
2071 and then Is_Overriding_Operation (XE.Ent)
2073 Output_Overridden_Op (Overridden_Operation (XE.Ent));
2076 -- End of processing for entity output
2078 Crloc := No_Location;
2081 -- Output the reference
2083 if XE.Loc /= No_Location
2084 and then XE.Loc /= Crloc
2088 -- Start continuation if line full, else blank
2090 if Write_Info_Col > 72 then
2092 Write_Info_Initiate ('.');
2095 Write_Info_Char (' ');
2097 -- Output file number if changed
2099 if XE.Lun /= Curru then
2101 Write_Info_Nat (Dependency_Num (Curru));
2102 Write_Info_Char ('|');
2105 Write_Info_Nat (Int (Get_Logical_Line_Number (XE.Loc)));
2106 Write_Info_Char (XE.Typ);
2108 if Is_Overloadable (XE.Ent)
2109 and then Is_Imported (XE.Ent)
2110 and then XE.Typ = 'b'
2112 Output_Import_Export_Info (XE.Ent);
2115 Write_Info_Nat (Int (Get_Column_Number (XE.Loc)));
2117 Output_Instantiation_Refs (Sloc (XE.Ent));
2128 end Output_References;