1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1998-2020, 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
;
47 with GNAT
.Heap_Sort_G
;
50 package body Lib
.Xref
is
56 package Deferred_References
is new Table
.Table
(
57 Table_Component_Type
=> Deferred_Reference_Entry
,
58 Table_Index_Type
=> Int
,
61 Table_Increment
=> 200,
62 Table_Name
=> "Name_Deferred_References");
64 -- The Xref table is used to record references. The Loc field is set
65 -- to No_Location for a definition entry.
67 subtype Xref_Entry_Number
is Int
;
69 type Xref_Key
is record
70 -- These are the components of Xref_Entry that participate in hash
74 -- Entity referenced (E parameter to Generate_Reference)
77 -- Location of reference (Original_Location (Sloc field of N parameter
78 -- to Generate_Reference)). Set to No_Location for the case of a
79 -- defining occurrence.
82 -- Reference type (Typ param to Generate_Reference)
84 Eun
: Unit_Number_Type
;
85 -- Unit number corresponding to Ent
87 Lun
: Unit_Number_Type
;
88 -- Unit number corresponding to Loc. Value is undefined and not
89 -- referenced if Loc is set to No_Location.
91 -- The following components are only used for SPARK cross-references
93 Ref_Scope
: Entity_Id
;
94 -- Entity of the closest subprogram or package enclosing the reference
96 Ent_Scope
: Entity_Id
;
97 -- Entity of the closest subprogram or package enclosing the definition,
98 -- which should be located in the same file as the definition itself.
101 type Xref_Entry
is record
104 Ent_Scope_File
: Unit_Number_Type
;
105 -- File for entity Ent_Scope
108 -- Original source location for entity being referenced. Note that these
109 -- values are used only during the output process, they are not set when
110 -- the entries are originally built. This is because private entities
111 -- can be swapped when the initial call is made.
113 HTable_Next
: Xref_Entry_Number
;
114 -- For use only by Static_HTable
117 package Xrefs
is new Table
.Table
(
118 Table_Component_Type
=> Xref_Entry
,
119 Table_Index_Type
=> Xref_Entry_Number
,
120 Table_Low_Bound
=> 1,
121 Table_Initial
=> Alloc
.Xrefs_Initial
,
122 Table_Increment
=> Alloc
.Xrefs_Increment
,
123 Table_Name
=> "Xrefs");
129 -- We keep a set of xref entries, in order to avoid inserting duplicate
130 -- entries into the above Xrefs table. An entry is in Xref_Set if and only
131 -- if it is in Xrefs.
133 Num_Buckets
: constant := 2**16;
135 subtype Header_Num
is Integer range 0 .. Num_Buckets
- 1;
136 type Null_Type
is null record;
137 pragma Unreferenced
(Null_Type
);
139 function Hash
(F
: Xref_Entry_Number
) return Header_Num
;
141 function Equal
(F1
, F2
: Xref_Entry_Number
) return Boolean;
143 procedure HT_Set_Next
(E
: Xref_Entry_Number
; Next
: Xref_Entry_Number
);
145 function HT_Next
(E
: Xref_Entry_Number
) return Xref_Entry_Number
;
147 function Get_Key
(E
: Xref_Entry_Number
) return Xref_Entry_Number
;
149 pragma Inline
(Hash
, Equal
, HT_Set_Next
, HT_Next
, Get_Key
);
151 package Xref_Set
is new GNAT
.HTable
.Static_HTable
(
153 Element
=> Xref_Entry
,
154 Elmt_Ptr
=> Xref_Entry_Number
,
156 Set_Next
=> HT_Set_Next
,
158 Key
=> Xref_Entry_Number
,
163 -----------------------------
164 -- SPARK Xrefs Information --
165 -----------------------------
167 package body SPARK_Specific
is separate;
169 ------------------------
170 -- Local Subprograms --
171 ------------------------
173 procedure Add_Entry
(Key
: Xref_Key
; Ent_Scope_File
: Unit_Number_Type
);
174 -- Add an entry to the tables of Xref_Entries, avoiding duplicates
176 procedure Generate_Prim_Op_References
(Typ
: Entity_Id
);
177 -- For a tagged type, generate implicit references to its primitive
178 -- operations, for source navigation. This is done right before emitting
179 -- cross-reference information rather than at the freeze point of the type
180 -- in order to handle late bodies that are primitive operations.
182 function Lt
(T1
, T2
: Xref_Entry
) return Boolean;
183 -- Order cross-references
189 procedure Add_Entry
(Key
: Xref_Key
; Ent_Scope_File
: Unit_Number_Type
) is
191 Xrefs
.Increment_Last
; -- tentative
192 Xrefs
.Table
(Xrefs
.Last
).Key
:= Key
;
194 -- Set the entry in Xref_Set, and if newly set, keep the above
195 -- tentative increment.
197 if Xref_Set
.Set_If_Not_Present
(Xrefs
.Last
) then
198 Xrefs
.Table
(Xrefs
.Last
).Ent_Scope_File
:= Ent_Scope_File
;
199 -- Leave Def and HTable_Next uninitialized
201 Set_Has_Xref_Entry
(Key
.Ent
);
203 -- It was already in Xref_Set, so throw away the tentatively-added entry
206 Xrefs
.Decrement_Last
;
210 ---------------------
211 -- Defer_Reference --
212 ---------------------
214 procedure Defer_Reference
(Deferred_Reference
: Deferred_Reference_Entry
) is
216 -- If Get_Ignore_Errors, then we are in Preanalyze_Without_Errors, and
217 -- we should not record cross references, because that will cause
218 -- duplicates when we call Analyze.
220 if not Get_Ignore_Errors
then
221 Deferred_References
.Append
(Deferred_Reference
);
229 function Equal
(F1
, F2
: Xref_Entry_Number
) return Boolean is
230 Result
: constant Boolean :=
231 Xrefs
.Table
(F1
).Key
= Xrefs
.Table
(F2
).Key
;
236 -------------------------
237 -- Generate_Definition --
238 -------------------------
240 procedure Generate_Definition
(E
: Entity_Id
) is
242 pragma Assert
(Nkind
(E
) in N_Entity
);
244 -- Note that we do not test Xref_Entity_Letters here. It is too early
245 -- to do so, since we are often called before the entity is fully
246 -- constructed, so that the Ekind is still E_Void.
250 -- Definition must come from source
252 -- We make an exception for subprogram child units that have no spec.
253 -- For these we generate a subprogram declaration for library use,
254 -- and the corresponding entity does not come from source.
255 -- Nevertheless, all references will be attached to it and we have
256 -- to treat is as coming from user code.
258 and then (Comes_From_Source
(E
) or else Is_Child_Unit
(E
))
260 -- And must have a reasonable source location that is not
261 -- within an instance (all entities in instances are ignored)
263 and then Sloc
(E
) > No_Location
264 and then Instantiation_Location
(Sloc
(E
)) = No_Location
266 -- And must be a non-internal name from the main source unit
268 and then In_Extended_Main_Source_Unit
(E
)
269 and then not Is_Internal_Name
(Chars
(E
))
275 Eun
=> Get_Source_Unit
(Original_Location
(Sloc
(E
))),
279 Ent_Scope_File
=> No_Unit
);
281 if In_Inlined_Body
then
285 end Generate_Definition
;
287 ---------------------------------
288 -- Generate_Operator_Reference --
289 ---------------------------------
291 procedure Generate_Operator_Reference
296 if not In_Extended_Main_Source_Unit
(N
) then
300 -- If the operator is not a Standard operator, then we generate a real
301 -- reference to the user defined operator.
303 if Sloc
(Entity
(N
)) /= Standard_Location
then
304 Generate_Reference
(Entity
(N
), N
);
306 -- A reference to an implicit inequality operator is also a reference
307 -- to the user-defined equality.
309 if Nkind
(N
) = N_Op_Ne
310 and then not Comes_From_Source
(Entity
(N
))
311 and then Present
(Corresponding_Equality
(Entity
(N
)))
313 Generate_Reference
(Corresponding_Equality
(Entity
(N
)), N
);
316 -- For the case of Standard operators, we mark the result type as
317 -- referenced. This ensures that in the case where we are using a
318 -- derived operator, we mark an entity of the unit that implicitly
319 -- defines this operator as used. Otherwise we may think that no entity
320 -- of the unit is used. The actual entity marked as referenced is the
321 -- first subtype, which is the relevant user defined entity.
323 -- Note: we only do this for operators that come from source. The
324 -- generated code sometimes reaches for entities that do not need to be
325 -- explicitly visible (for example, when we expand the code for
326 -- comparing two record objects, the fields of the record may not be
329 elsif Comes_From_Source
(N
) then
330 Set_Referenced
(First_Subtype
(T
));
332 end Generate_Operator_Reference
;
334 ---------------------------------
335 -- Generate_Prim_Op_References --
336 ---------------------------------
338 procedure Generate_Prim_Op_References
(Typ
: Entity_Id
) is
341 Prim_List
: Elist_Id
;
344 -- Handle subtypes of synchronized types
346 if Ekind
(Typ
) = E_Protected_Subtype
347 or else Ekind
(Typ
) = E_Task_Subtype
349 Base_T
:= Etype
(Typ
);
354 -- References to primitive operations are only relevant for tagged types
356 if not Is_Tagged_Type
(Base_T
)
357 or else Is_Class_Wide_Type
(Base_T
)
362 -- Ada 2005 (AI-345): For synchronized types generate reference to the
363 -- wrapper that allow us to dispatch calls through their implemented
364 -- abstract interface types.
366 -- The check for Present here is to protect against previously reported
369 Prim_List
:= Primitive_Operations
(Base_T
);
371 if No
(Prim_List
) then
375 Prim
:= First_Elmt
(Prim_List
);
376 while Present
(Prim
) loop
378 -- If the operation is derived, get the original for cross-reference
379 -- reference purposes (it is the original for which we want the xref
380 -- and for which the comes_from_source test must be performed).
383 (Typ
, Ultimate_Alias
(Node
(Prim
)), 'p', Set_Ref
=> False);
386 end Generate_Prim_Op_References
;
388 ------------------------
389 -- Generate_Reference --
390 ------------------------
392 procedure Generate_Reference
395 Typ
: Character := 'r';
396 Set_Ref
: Boolean := True;
397 Force
: Boolean := False)
399 Actual_Typ
: Character := Typ
;
403 Ent_Scope
: Entity_Id
;
408 Ref_Scope
: Entity_Id
;
410 function Get_Through_Renamings
(E
: Entity_Id
) return Entity_Id
;
411 -- Get the enclosing entity through renamings, which may come from
412 -- source or from the translation of generic instantiations.
414 function Is_On_LHS
(Node
: Node_Id
) return Boolean;
415 -- Used to check if a node is on the left hand side of an assignment.
416 -- The following cases are handled:
418 -- Variable Node is a direct descendant of left hand side of an
419 -- assignment statement.
421 -- Prefix Of an indexed or selected component that is present in
422 -- a subtree rooted by an assignment statement. There is
423 -- no restriction of nesting of components, thus cases
424 -- such as A.B (C).D are handled properly. However a prefix
425 -- of a dereference (either implicit or explicit) is never
426 -- considered as on a LHS.
428 -- Out param Same as above cases, but OUT parameter
430 function OK_To_Set_Referenced
return Boolean;
431 -- Returns True if the Referenced flag can be set. There are a few
432 -- exceptions where we do not want to set this flag, see body for
433 -- details of these exceptional cases.
435 ---------------------------
436 -- Get_Through_Renamings --
437 ---------------------------
439 function Get_Through_Renamings
(E
: Entity_Id
) return Entity_Id
is
443 -- For subprograms we just need to check once if they are have a
444 -- Renamed_Entity, because Renamed_Entity is set transitively.
446 when Subprogram_Kind
=>
448 Renamed
: constant Entity_Id
:= Renamed_Entity
(E
);
451 if Present
(Renamed
) then
458 -- For objects we need to repeatedly call Renamed_Object, because
459 -- it is not transitive.
463 Obj
: Entity_Id
:= E
;
467 pragma Assert
(Present
(Obj
));
470 Renamed
: constant Entity_Id
:= Renamed_Object
(Obj
);
473 if Present
(Renamed
) then
474 Obj
:= Get_Enclosing_Object
(Renamed
);
476 -- The renamed expression denotes a non-object,
477 -- e.g. function call, slicing of a function call,
478 -- pointer dereference, etc.
494 end Get_Through_Renamings
;
500 -- ??? There are several routines here and there that perform a similar
501 -- (but subtly different) computation, which should be factored:
504 -- Sem_Util.May_Be_Lvalue
505 -- Sem_Util.Known_To_Be_Assigned
506 -- Exp_Ch2.Expand_Entry_Parameter.In_Assignment_Context
507 -- Exp_Smem.Is_Out_Actual
509 function Is_On_LHS
(Node
: Node_Id
) return Boolean is
515 -- Only identifiers are considered, is this necessary???
517 if Nkind
(Node
) /= N_Identifier
then
521 -- Immediate return if appeared as OUT parameter
523 if Kind
= E_Out_Parameter
then
527 -- Search for assignment statement subtree root
534 if K
= N_Assignment_Statement
then
537 -- Check whether the parent is a component and the current node is
538 -- its prefix, but return False if the current node has an access
539 -- type, as in that case the selected or indexed component is an
540 -- implicit dereference, and the LHS is the designated object, not
541 -- the access object.
543 -- ??? case of a slice assignment?
545 elsif (K
= N_Selected_Component
or else K
= N_Indexed_Component
)
546 and then Prefix
(P
) = N
548 -- Check for access type. First a special test, In some cases
549 -- this is called too early (see comments in Find_Direct_Name),
550 -- at a point where the tree is not fully typed yet. In that
551 -- case we may lack an Etype for N, and we can't check the
552 -- Etype. For now, we always return False in such a case,
553 -- but this is clearly not right in all cases ???
555 if No
(Etype
(N
)) then
558 elsif Is_Access_Type
(Etype
(N
)) then
561 -- Access type case dealt with, keep going
567 -- All other cases, definitely not on left side
575 ---------------------------
576 -- OK_To_Set_Referenced --
577 ---------------------------
579 function OK_To_Set_Referenced
return Boolean is
583 -- A reference from a pragma Unreferenced or pragma Unmodified or
584 -- pragma Warnings does not cause the Referenced flag to be set.
585 -- This avoids silly warnings about things being referenced and
586 -- not assigned when the only reference is from the pragma.
588 if Nkind
(N
) = N_Identifier
then
591 if Nkind
(P
) = N_Pragma_Argument_Association
then
594 if Nkind
(P
) = N_Pragma
then
595 if Pragma_Name_Unmapped
(P
) in Name_Warnings
603 -- A reference to a formal in a named parameter association does
604 -- not make the formal referenced. Formals that are unused in the
605 -- subprogram body are properly flagged as such, even if calls
606 -- elsewhere use named notation.
608 elsif Nkind
(P
) = N_Parameter_Association
609 and then N
= Selector_Name
(P
)
616 end OK_To_Set_Referenced
;
618 -- Start of processing for Generate_Reference
621 -- If Get_Ignore_Errors, then we are in Preanalyze_Without_Errors, and
622 -- we should not record cross references, because that will cause
623 -- duplicates when we call Analyze.
625 if Get_Ignore_Errors
then
629 -- May happen in case of severe errors
631 if Nkind
(E
) not in N_Entity
then
635 Find_Actual
(N
, Formal
, Call
);
637 if Present
(Formal
) then
638 Kind
:= Ekind
(Formal
);
643 -- Check for obsolescent reference to package ASCII. GNAT treats this
644 -- element of annex J specially since in practice, programs make a lot
645 -- of use of this feature, so we don't include it in the set of features
646 -- diagnosed when Warn_On_Obsolescent_Features mode is set. However we
647 -- are required to note it as a violation of the RM defined restriction.
649 if E
= Standard_ASCII
then
650 Check_Restriction
(No_Obsolescent_Features
, N
);
653 -- Check for reference to entity marked with Is_Obsolescent
655 -- Note that we always allow obsolescent references in the compiler
656 -- itself and the run time, since we assume that we know what we are
657 -- doing in such cases. For example the calls in Ada.Characters.Handling
658 -- to its own obsolescent subprograms are just fine.
660 -- In any case we only generate warnings if we are in the extended main
661 -- source unit, and the entity itself is not in the extended main source
662 -- unit, since we assume the source unit itself knows what is going on
663 -- (and for sure we do not want silly warnings, e.g. on the end line of
664 -- an obsolescent procedure body).
666 if Is_Obsolescent
(E
)
667 and then not GNAT_Mode
668 and then not In_Extended_Main_Source_Unit
(E
)
669 and then In_Extended_Main_Source_Unit
(N
)
671 Check_Restriction
(No_Obsolescent_Features
, N
);
673 if Warn_On_Obsolescent_Feature
then
674 Output_Obsolescent_Entity_Warnings
(N
, E
);
678 -- Warn if reference to Ada 2005 entity not in Ada 2005 mode. We only
679 -- detect real explicit references (modifications and references).
681 if Comes_From_Source
(N
)
682 and then Is_Ada_2005_Only
(E
)
683 and then Ada_Version
< Ada_2005
684 and then Warn_On_Ada_2005_Compatibility
685 and then (Typ
= 'm' or else Typ
= 'r' or else Typ
= 's')
687 Error_Msg_NE
("& is only defined in Ada 2005?y?", N
, E
);
690 -- Warn if reference to Ada 2012 entity not in Ada 2012 mode. We only
691 -- detect real explicit references (modifications and references).
693 if Comes_From_Source
(N
)
694 and then Is_Ada_2012_Only
(E
)
695 and then Ada_Version
< Ada_2012
696 and then Warn_On_Ada_2012_Compatibility
697 and then (Typ
= 'm' or else Typ
= 'r')
699 Error_Msg_NE
("& is only defined in Ada 2012?y?", N
, E
);
702 -- Do not generate references if we are within a postcondition sub-
703 -- program, because the reference does not comes from source, and the
704 -- preanalysis of the aspect has already created an entry for the ALI
705 -- file at the proper source location.
707 if Chars
(Current_Scope
) = Name_uPostconditions
then
711 -- Never collect references if not in main source unit. However, we omit
712 -- this test if Typ is 'e' or 'k', since these entries are structural,
713 -- and it is useful to have them in units that reference packages as
714 -- well as units that define packages. We also omit the test for the
715 -- case of 'p' since we want to include inherited primitive operations
716 -- from other packages.
718 -- We also omit this test is this is a body reference for a subprogram
719 -- instantiation. In this case the reference is to the generic body,
720 -- which clearly need not be in the main unit containing the instance.
721 -- For the same reason we accept an implicit reference generated for
722 -- a default in an instance.
724 -- We also set the referenced flag in a generic package that is not in
725 -- then main source unit, when the variable is of a formal private type,
726 -- to warn in the instance if the corresponding type is not a fully
729 if not In_Extended_Main_Source_Unit
(N
) then
735 or else (Typ
= 'b' and then Is_Generic_Instance
(E
))
737 -- Allow the generation of references to reads, writes and calls
738 -- in SPARK mode when the related context comes from an instance.
742 and then In_Extended_Main_Code_Unit
(N
)
743 and then (Typ
= 'm' or else Typ
= 'r' or else Typ
= 's'))
747 elsif In_Instance_Body
748 and then In_Extended_Main_Code_Unit
(N
)
749 and then Is_Generic_Type
(Etype
(E
))
754 elsif Inside_A_Generic
755 and then Is_Generic_Type
(Etype
(E
))
765 -- For reference type p, the entity must be in main source unit
767 if Typ
= 'p' and then not In_Extended_Main_Source_Unit
(E
) then
771 -- Unless the reference is forced, we ignore references where the
772 -- reference itself does not come from source.
774 if not Force
and then not Comes_From_Source
(N
) then
778 -- Deal with setting entity as referenced, unless suppressed. Note that
779 -- we still do Set_Referenced on entities that do not come from source.
780 -- This situation arises when we have a source reference to a derived
781 -- operation, where the derived operation itself does not come from
782 -- source, but we still want to mark it as referenced, since we really
783 -- are referencing an entity in the corresponding package (this avoids
784 -- wrong complaints that the package contains no referenced entities).
788 -- Assignable object appearing on left side of assignment or as
792 and then Is_On_LHS
(N
)
793 and then Ekind
(E
) /= E_In_Out_Parameter
795 -- For objects that are renamings, just set as simply referenced
796 -- we do not try to do assignment type tracking in this case.
798 if Present
(Renamed_Object
(E
)) then
801 -- Out parameter case
803 elsif Kind
= E_Out_Parameter
then
805 -- If warning mode for all out parameters is set, or this is
806 -- the only warning parameter, then we want to mark this for
807 -- later warning logic by setting Referenced_As_Out_Parameter
809 if Warn_On_Modified_As_Out_Parameter
(Formal
) then
810 Set_Referenced_As_Out_Parameter
(E
, True);
811 Set_Referenced_As_LHS
(E
, False);
813 -- For OUT parameter not covered by the above cases, we simply
814 -- regard it as a normal reference (in this case we do not
815 -- want any of the warning machinery for out parameters).
821 -- For the left hand of an assignment case, we do nothing here.
822 -- The processing for Analyze_Assignment will set the
823 -- Referenced_As_LHS flag.
829 -- Check for a reference in a pragma that should not count as a
830 -- making the variable referenced for warning purposes.
832 elsif Is_Non_Significant_Pragma_Reference
(N
) then
835 -- A reference in an attribute definition clause does not count as a
836 -- reference except for the case of Address. The reason that 'Address
837 -- is an exception is that it creates an alias through which the
838 -- variable may be referenced.
840 elsif Nkind
(Parent
(N
)) = N_Attribute_Definition_Clause
841 and then Chars
(Parent
(N
)) /= Name_Address
842 and then N
= Name
(Parent
(N
))
846 -- Constant completion does not count as a reference
849 and then Ekind
(E
) = E_Constant
853 -- Record representation clause does not count as a reference
855 elsif Nkind
(N
) = N_Identifier
856 and then Nkind
(Parent
(N
)) = N_Record_Representation_Clause
860 -- Discriminants do not need to produce a reference to record type
863 and then Nkind
(Parent
(N
)) = N_Discriminant_Specification
870 -- Special processing for IN OUT parameters, where we have an
871 -- implicit assignment to a simple variable.
873 if Kind
= E_In_Out_Parameter
874 and then Is_Assignable
(E
)
876 -- For sure this counts as a normal read reference
879 Set_Last_Assignment
(E
, Empty
);
881 -- We count it as being referenced as an out parameter if the
882 -- option is set to warn on all out parameters, except that we
883 -- have a special exclusion for an intrinsic subprogram, which
884 -- is most likely an instantiation of Unchecked_Deallocation
885 -- which we do not want to consider as an assignment since it
886 -- generates false positives. We also exclude the case of an
887 -- IN OUT parameter if the name of the procedure is Free,
888 -- since we suspect similar semantics.
890 if Warn_On_All_Unread_Out_Parameters
891 and then Is_Entity_Name
(Name
(Call
))
892 and then not Is_Intrinsic_Subprogram
(Entity
(Name
(Call
)))
893 and then Chars
(Name
(Call
)) /= Name_Free
895 Set_Referenced_As_Out_Parameter
(E
, True);
896 Set_Referenced_As_LHS
(E
, False);
899 -- Don't count a recursive reference within a subprogram as a
900 -- reference (that allows detection of a recursive subprogram
901 -- whose only references are recursive calls as unreferenced).
903 elsif Is_Subprogram
(E
)
904 and then E
= Nearest_Dynamic_Scope
(Current_Scope
)
908 -- Any other occurrence counts as referencing the entity
910 elsif OK_To_Set_Referenced
then
913 -- If variable, this is an OK reference after an assignment
914 -- so we can clear the Last_Assignment indication.
916 if Is_Assignable
(E
) then
917 Set_Last_Assignment
(E
, Empty
);
922 -- Check for pragma Unreferenced given and reference is within
923 -- this source unit (occasion for possible warning to be issued).
924 -- Note that the entity may be marked as unreferenced by pragma
927 if Has_Unreferenced
(E
)
928 and then In_Same_Extended_Unit
(E
, N
)
930 -- A reference as a named parameter in a call does not count as a
931 -- violation of pragma Unreferenced for this purpose...
933 if Nkind
(N
) = N_Identifier
934 and then Nkind
(Parent
(N
)) = N_Parameter_Association
935 and then Selector_Name
(Parent
(N
)) = N
939 -- ... Neither does a reference to a variable on the left side of
942 elsif Is_On_LHS
(N
) then
945 -- Do not consider F'Result as a violation of pragma Unreferenced
946 -- since the attribute acts as an anonymous alias of the function
947 -- result and not as a real reference to the function.
949 elsif Ekind
(E
) in E_Function | E_Generic_Function
950 and then Is_Entity_Name
(N
)
951 and then Is_Attribute_Result
(Parent
(N
))
955 -- No warning if the reference is in a call that does not come
956 -- from source (e.g. a call to a controlled type primitive).
958 elsif not Comes_From_Source
(Parent
(N
))
959 and then Nkind
(Parent
(N
)) = N_Procedure_Call_Statement
963 -- For entry formals, we want to place the warning message on the
964 -- corresponding entity in the accept statement. The current scope
965 -- is the body of the accept, so we find the formal whose name
966 -- matches that of the entry formal (there is no link between the
967 -- two entities, and the one in the accept statement is only used
968 -- for conformance checking).
970 elsif Ekind
(Scope
(E
)) = E_Entry
then
975 BE
:= First_Entity
(Current_Scope
);
976 while Present
(BE
) loop
977 if Chars
(BE
) = Chars
(E
) then
978 if Has_Pragma_Unused
(E
) then
979 Error_Msg_NE
-- CODEFIX
980 ("??pragma Unused given for&!", N
, BE
);
982 Error_Msg_NE
-- CODEFIX
983 ("??pragma Unreferenced given for&!", N
, BE
);
992 -- Here we issue the warning, since this is a real reference
994 elsif Has_Pragma_Unused
(E
) then
995 Error_Msg_NE
-- CODEFIX
996 ("??pragma Unused given for&!", N
, E
);
998 Error_Msg_NE
-- CODEFIX
999 ("??pragma Unreferenced given for&!", N
, E
);
1003 -- If this is a subprogram instance, mark as well the internal
1004 -- subprogram in the wrapper package, which may be a visible
1005 -- compilation unit.
1007 if Is_Overloadable
(E
)
1008 and then Is_Generic_Instance
(E
)
1009 and then Present
(Alias
(E
))
1011 Set_Referenced
(Alias
(E
));
1015 -- Generate reference if all conditions are met:
1018 -- Cross referencing must be active
1022 -- The entity must be one for which we collect references
1024 and then Xref_Entity_Letters
(Ekind
(E
)) /= ' '
1026 -- Both Sloc values must be set to something sensible
1028 and then Sloc
(E
) > No_Location
1029 and then Sloc
(N
) > No_Location
1031 -- Ignore references from within an instance. The only exceptions to
1032 -- this are default subprograms, for which we generate an implicit
1033 -- reference and compilations in SPARK mode.
1036 (Instantiation_Location
(Sloc
(N
)) = No_Location
1038 or else GNATprove_Mode
)
1040 -- Ignore dummy references
1044 if Nkind
(N
) in N_Identifier
1045 | N_Defining_Identifier
1046 | N_Defining_Operator_Symbol
1048 | N_Defining_Character_Literal
1050 or else (Nkind
(N
) = N_Character_Literal
1051 and then Sloc
(Entity
(N
)) /= Standard_Location
)
1055 elsif Nkind
(N
) in N_Expanded_Name | N_Selected_Component
then
1056 Nod
:= Selector_Name
(N
);
1062 -- Normal case of source entity comes from source
1064 if Comes_From_Source
(E
) then
1067 -- Because a declaration may be generated for a subprogram body
1068 -- without declaration in GNATprove mode, for inlining, some
1069 -- parameters may end up being marked as not coming from source
1070 -- although they are. Take these into account specially.
1072 elsif GNATprove_Mode
and then Is_Formal
(E
) then
1075 -- Entity does not come from source, but is a derived subprogram and
1076 -- the derived subprogram comes from source (after one or more
1077 -- derivations) in which case the reference is to parent subprogram.
1079 elsif Is_Overloadable
(E
)
1080 and then Present
(Alias
(E
))
1083 while not Comes_From_Source
(Ent
) loop
1084 if No
(Alias
(Ent
)) then
1091 -- The internally created defining entity for a child subprogram
1092 -- that has no previous spec has valid references.
1094 elsif Is_Overloadable
(E
)
1095 and then Is_Child_Unit
(E
)
1099 -- Ditto for the formals of such a subprogram
1101 elsif Is_Overloadable
(Scope
(E
))
1102 and then Is_Child_Unit
(Scope
(E
))
1106 -- Record components of discriminated subtypes or derived types must
1107 -- be treated as references to the original component.
1109 elsif Ekind
(E
) = E_Component
1110 and then Comes_From_Source
(Original_Record_Component
(E
))
1112 Ent
:= Original_Record_Component
(E
);
1114 -- If this is an expanded reference to a discriminant, recover the
1115 -- original discriminant, which gets the reference.
1117 elsif Ekind
(E
) = E_In_Parameter
1118 and then Present
(Discriminal_Link
(E
))
1120 Ent
:= Discriminal_Link
(E
);
1121 Set_Referenced
(Ent
);
1123 -- Ignore reference to any other entity that is not from source
1129 -- In SPARK mode, consider the underlying entity renamed instead of
1130 -- the renaming, which is needed to compute a valid set of effects
1131 -- (reads, writes) for the enclosing subprogram.
1133 if GNATprove_Mode
then
1134 Ent
:= Get_Through_Renamings
(Ent
);
1136 -- If no enclosing object, then it could be a reference to any
1137 -- location not tracked individually, like heap-allocated data.
1138 -- Conservatively approximate this possibility by generating a
1139 -- dereference, and return.
1142 if Actual_Typ
= 'w' then
1143 SPARK_Specific
.Generate_Dereference
(Nod
, 'r');
1144 SPARK_Specific
.Generate_Dereference
(Nod
, 'w');
1146 SPARK_Specific
.Generate_Dereference
(Nod
, 'r');
1153 -- Record reference to entity
1156 and then Is_Subprogram
(Nod
)
1157 and then Present
(Overridden_Operation
(Nod
))
1162 -- Comment needed here for special SPARK code ???
1164 if GNATprove_Mode
then
1166 -- Ignore references to an entity which is a Part_Of single
1167 -- concurrent object. Ideally we would prefer to add it as a
1168 -- reference to the corresponding concurrent type, but it is quite
1169 -- difficult (as such references are not currently added even for)
1170 -- reads/writes of private protected components) and not worth the
1173 if Ekind
(Ent
) in E_Abstract_State | E_Constant | E_Variable
1174 and then Present
(Encapsulating_State
(Ent
))
1175 and then Is_Single_Concurrent_Object
(Encapsulating_State
(Ent
))
1184 SPARK_Specific
.Enclosing_Subprogram_Or_Library_Package
(Nod
);
1186 SPARK_Specific
.Enclosing_Subprogram_Or_Library_Package
(Ent
);
1188 -- Since we are reaching through renamings in SPARK mode, we may
1189 -- end up with standard constants. Ignore those.
1191 if Sloc
(Ent_Scope
) <= Standard_Location
1192 or else Def
<= Standard_Location
1201 Eun
=> Get_Top_Level_Code_Unit
(Def
),
1202 Lun
=> Get_Top_Level_Code_Unit
(Ref
),
1203 Ref_Scope
=> Ref_Scope
,
1204 Ent_Scope
=> Ent_Scope
),
1205 Ent_Scope_File
=> Get_Top_Level_Code_Unit
(Ent
));
1208 Ref
:= Original_Location
(Sloc
(Nod
));
1209 Def
:= Original_Location
(Sloc
(Ent
));
1211 -- If this is an operator symbol, skip the initial quote for
1212 -- navigation purposes. This is not done for the end label,
1213 -- where we want the actual position after the closing quote.
1218 elsif Nkind
(N
) = N_Defining_Operator_Symbol
1219 or else Nkind
(Nod
) = N_Operator_Symbol
1228 Eun
=> Get_Source_Unit
(Def
),
1229 Lun
=> Get_Source_Unit
(Ref
),
1231 Ent_Scope
=> Empty
),
1232 Ent_Scope_File
=> No_Unit
);
1234 -- Generate reference to the first private entity
1237 and then Comes_From_Source
(E
)
1238 and then Nkind
(Ent
) = N_Defining_Identifier
1239 and then (Is_Package_Or_Generic_Package
(Ent
)
1240 or else Is_Concurrent_Type
(Ent
))
1241 and then Present
(First_Private_Entity
(E
))
1242 and then In_Extended_Main_Source_Unit
(N
)
1244 -- Handle case in which the full-view and partial-view of the
1245 -- first private entity are swapped.
1248 First_Private
: Entity_Id
:= First_Private_Entity
(E
);
1251 if Is_Private_Type
(First_Private
)
1252 and then Present
(Full_View
(First_Private
))
1254 First_Private
:= Full_View
(First_Private
);
1259 Loc
=> Sloc
(First_Private
),
1261 Eun
=> Get_Source_Unit
(Def
),
1262 Lun
=> Get_Source_Unit
(Ref
),
1264 Ent_Scope
=> Empty
),
1265 Ent_Scope_File
=> No_Unit
);
1270 end Generate_Reference
;
1272 -----------------------------------
1273 -- Generate_Reference_To_Formals --
1274 -----------------------------------
1276 procedure Generate_Reference_To_Formals
(E
: Entity_Id
) is
1280 if Is_Generic_Subprogram
(E
) then
1281 Formal
:= First_Entity
(E
);
1283 while Present
(Formal
)
1284 and then not Is_Formal
(Formal
)
1286 Next_Entity
(Formal
);
1289 elsif Ekind
(E
) in Access_Subprogram_Kind
then
1290 Formal
:= First_Formal
(Designated_Type
(E
));
1293 Formal
:= First_Formal
(E
);
1296 while Present
(Formal
) loop
1297 if Ekind
(Formal
) = E_In_Parameter
then
1299 if Nkind
(Parameter_Type
(Parent
(Formal
))) = N_Access_Definition
1301 Generate_Reference
(E
, Formal
, '^', False);
1303 Generate_Reference
(E
, Formal
, '>', False);
1306 elsif Ekind
(Formal
) = E_In_Out_Parameter
then
1307 Generate_Reference
(E
, Formal
, '=', False);
1310 Generate_Reference
(E
, Formal
, '<', False);
1313 Next_Formal
(Formal
);
1315 end Generate_Reference_To_Formals
;
1317 -------------------------------------------
1318 -- Generate_Reference_To_Generic_Formals --
1319 -------------------------------------------
1321 procedure Generate_Reference_To_Generic_Formals
(E
: Entity_Id
) is
1325 Formal
:= First_Entity
(E
);
1326 while Present
(Formal
) loop
1327 if Comes_From_Source
(Formal
) then
1328 Generate_Reference
(E
, Formal
, 'z', False);
1331 Next_Entity
(Formal
);
1333 end Generate_Reference_To_Generic_Formals
;
1339 function Get_Key
(E
: Xref_Entry_Number
) return Xref_Entry_Number
is
1344 ----------------------------
1345 -- Has_Deferred_Reference --
1346 ----------------------------
1348 function Has_Deferred_Reference
(Ent
: Entity_Id
) return Boolean is
1350 for J
in Deferred_References
.First
.. Deferred_References
.Last
loop
1351 if Deferred_References
.Table
(J
).E
= Ent
then
1357 end Has_Deferred_Reference
;
1363 function Hash
(F
: Xref_Entry_Number
) return Header_Num
is
1364 -- It is unlikely to have two references to the same entity at the same
1365 -- source location, so the hash function depends only on the Ent and Loc
1368 XE
: Xref_Entry
renames Xrefs
.Table
(F
);
1369 type M
is mod 2**32;
1371 H
: constant M
:= M
(XE
.Key
.Ent
) + 2 ** 7 * M
(abs XE
.Key
.Loc
);
1372 -- It would be more natural to write:
1374 -- H : constant M := M'Mod (XE.Key.Ent) + 2**7 * M'Mod (XE.Key.Loc);
1376 -- But we can't use M'Mod, because it prevents bootstrapping with older
1377 -- compilers. Loc can be negative, so we do "abs" before converting.
1378 -- One day this can be cleaned up ???
1381 return Header_Num
(H
mod Num_Buckets
);
1388 procedure HT_Set_Next
(E
: Xref_Entry_Number
; Next
: Xref_Entry_Number
) is
1390 Xrefs
.Table
(E
).HTable_Next
:= Next
;
1397 function HT_Next
(E
: Xref_Entry_Number
) return Xref_Entry_Number
is
1399 return Xrefs
.Table
(E
).HTable_Next
;
1406 procedure Initialize
is
1415 function Lt
(T1
, T2
: Xref_Entry
) return Boolean is
1417 -- First test: if entity is in different unit, sort by unit
1419 if T1
.Key
.Eun
/= T2
.Key
.Eun
then
1420 return Dependency_Num
(T1
.Key
.Eun
) < Dependency_Num
(T2
.Key
.Eun
);
1422 -- Second test: within same unit, sort by entity Sloc
1424 elsif T1
.Def
/= T2
.Def
then
1425 return T1
.Def
< T2
.Def
;
1427 -- Third test: sort definitions ahead of references
1429 elsif T1
.Key
.Loc
= No_Location
then
1432 elsif T2
.Key
.Loc
= No_Location
then
1435 -- Fourth test: for same entity, sort by reference location unit
1437 elsif T1
.Key
.Lun
/= T2
.Key
.Lun
then
1438 return Dependency_Num
(T1
.Key
.Lun
) < Dependency_Num
(T2
.Key
.Lun
);
1440 -- Fifth test: order of location within referencing unit
1442 elsif T1
.Key
.Loc
/= T2
.Key
.Loc
then
1443 return T1
.Key
.Loc
< T2
.Key
.Loc
;
1445 -- Finally, for two locations at the same address, we prefer
1446 -- the one that does NOT have the type 'r' so that a modification
1447 -- or extension takes preference, when there are more than one
1448 -- reference at the same location. As a result, in the case of
1449 -- entities that are in-out actuals, the read reference follows
1450 -- the modify reference.
1453 return T2
.Key
.Typ
= 'r';
1457 -----------------------
1458 -- Output_References --
1459 -----------------------
1461 procedure Output_References
is
1463 procedure Get_Type_Reference
1465 Tref
: out Entity_Id
;
1466 Left
: out Character;
1467 Right
: out Character);
1468 -- Given an Entity_Id Ent, determines whether a type reference is
1469 -- required. If so, Tref is set to the entity for the type reference
1470 -- and Left and Right are set to the left/right brackets to be output
1471 -- for the reference. If no type reference is required, then Tref is
1472 -- set to Empty, and Left/Right are set to space.
1474 procedure Output_Import_Export_Info
(Ent
: Entity_Id
);
1475 -- Output language and external name information for an interfaced
1476 -- entity, using the format <language, external_name>.
1478 ------------------------
1479 -- Get_Type_Reference --
1480 ------------------------
1482 procedure Get_Type_Reference
1484 Tref
: out Entity_Id
;
1485 Left
: out Character;
1486 Right
: out Character)
1491 -- See if we have a type reference
1500 -- Processing for types
1502 if Is_Type
(Tref
) then
1504 -- Case of base type
1506 if Base_Type
(Tref
) = Tref
then
1508 -- If derived, then get first subtype
1510 if Tref
/= Etype
(Tref
) then
1511 Tref
:= First_Subtype
(Etype
(Tref
));
1513 -- Set brackets for derived type, but don't override
1514 -- pointer case since the fact that something is a
1515 -- pointer is more important.
1522 -- If the completion of a private type is itself a derived
1523 -- type, we need the parent of the full view.
1525 elsif Is_Private_Type
(Tref
)
1526 and then Present
(Full_View
(Tref
))
1527 and then Etype
(Full_View
(Tref
)) /= Full_View
(Tref
)
1529 Tref
:= Etype
(Full_View
(Tref
));
1536 -- If non-derived pointer, get directly designated type.
1537 -- If the type has a full view, all references are on the
1538 -- partial view that is seen first.
1540 elsif Is_Access_Type
(Tref
) then
1541 Tref
:= Directly_Designated_Type
(Tref
);
1545 elsif Is_Private_Type
(Tref
)
1546 and then Present
(Full_View
(Tref
))
1548 if Is_Access_Type
(Full_View
(Tref
)) then
1549 Tref
:= Directly_Designated_Type
(Full_View
(Tref
));
1553 -- If the full view is an array type, we also retrieve
1554 -- the corresponding component type, because the ali
1555 -- entry already indicates that this is an array.
1557 elsif Is_Array_Type
(Full_View
(Tref
)) then
1558 Tref
:= Component_Type
(Full_View
(Tref
));
1563 -- If non-derived array, get component type. Skip component
1564 -- type for case of String or Wide_String, saves worthwhile
1567 elsif Is_Array_Type
(Tref
)
1568 and then Tref
/= Standard_String
1569 and then Tref
/= Standard_Wide_String
1571 Tref
:= Component_Type
(Tref
);
1575 -- For other non-derived base types, nothing
1581 -- For a subtype, go to ancestor subtype
1584 Tref
:= Ancestor_Subtype
(Tref
);
1586 -- If no ancestor subtype, go to base type
1589 Tref
:= Base_Type
(Sav
);
1593 -- For objects, functions, enum literals, just get type from
1596 elsif Is_Object
(Tref
)
1597 or else Ekind
(Tref
) = E_Enumeration_Literal
1598 or else Ekind
(Tref
) = E_Function
1599 or else Ekind
(Tref
) = E_Operator
1601 Tref
:= Etype
(Tref
);
1603 -- Another special case: an object of a classwide type
1604 -- initialized with a tag-indeterminate call gets a subtype
1605 -- of the classwide type during expansion. See if the original
1606 -- type in the declaration is named, and return it instead
1607 -- of going to the root type. The expression may be a class-
1608 -- wide function call whose result is on the secondary stack,
1609 -- which forces the declaration to be rewritten as a renaming,
1610 -- so examine the source declaration.
1612 if Ekind
(Tref
) = E_Class_Wide_Subtype
then
1614 Decl
: constant Node_Id
:= Original_Node
(Parent
(Ent
));
1616 if Nkind
(Decl
) = N_Object_Declaration
1617 and then Is_Entity_Name
1618 (Original_Node
(Object_Definition
(Decl
)))
1621 Entity
(Original_Node
(Object_Definition
(Decl
)));
1625 -- For a function that returns a class-wide type, Tref is
1628 elsif Is_Overloadable
(Ent
)
1629 and then Is_Class_Wide_Type
(Tref
)
1634 -- For anything else, exit
1640 -- Exit if no type reference, or we are stuck in some loop trying
1641 -- to find the type reference, or if the type is standard void
1642 -- type (the latter is an implementation artifact that should not
1643 -- show up in the generated cross-references).
1647 or else Tref
= Standard_Void_Type
;
1649 -- If we have a usable type reference, return, otherwise keep
1650 -- looking for something useful (we are looking for something
1651 -- that either comes from source or standard)
1653 if Sloc
(Tref
) = Standard_Location
1654 or else Comes_From_Source
(Tref
)
1656 -- If the reference is a subtype created for a generic actual,
1657 -- go actual directly, the inner subtype is not user visible.
1659 if Nkind
(Parent
(Tref
)) = N_Subtype_Declaration
1660 and then not Comes_From_Source
(Parent
(Tref
))
1662 (Is_Wrapper_Package
(Scope
(Tref
))
1663 or else Is_Generic_Instance
(Scope
(Tref
)))
1665 Tref
:= First_Subtype
(Base_Type
(Tref
));
1672 -- If we fall through the loop, no type reference
1677 end Get_Type_Reference
;
1679 -------------------------------
1680 -- Output_Import_Export_Info --
1681 -------------------------------
1683 procedure Output_Import_Export_Info
(Ent
: Entity_Id
) is
1684 Language_Name
: Name_Id
;
1685 Conv
: constant Convention_Id
:= Convention
(Ent
);
1688 -- Generate language name from convention
1690 if Conv
= Convention_C
or else Conv
in Convention_C_Variadic
then
1691 Language_Name
:= Name_C
;
1693 elsif Conv
= Convention_CPP
then
1694 Language_Name
:= Name_CPP
;
1696 elsif Conv
= Convention_Ada
then
1697 Language_Name
:= Name_Ada
;
1700 -- For the moment we ignore all other cases ???
1705 Write_Info_Char
('<');
1706 Get_Unqualified_Name_String
(Language_Name
);
1708 for J
in 1 .. Name_Len
loop
1709 Write_Info_Char
(Name_Buffer
(J
));
1712 if Present
(Interface_Name
(Ent
)) then
1713 Write_Info_Char
(',');
1714 String_To_Name_Buffer
(Strval
(Interface_Name
(Ent
)));
1716 for J
in 1 .. Name_Len
loop
1717 Write_Info_Char
(Name_Buffer
(J
));
1721 Write_Info_Char
('>');
1722 end Output_Import_Export_Info
;
1724 -- Start of processing for Output_References
1727 -- First we add references to the primitive operations of tagged types
1728 -- declared in the main unit.
1730 Handle_Prim_Ops
: declare
1734 for J
in 1 .. Xrefs
.Last
loop
1735 Ent
:= Xrefs
.Table
(J
).Key
.Ent
;
1738 and then Is_Tagged_Type
(Ent
)
1739 and then Is_Base_Type
(Ent
)
1740 and then In_Extended_Main_Source_Unit
(Ent
)
1742 Generate_Prim_Op_References
(Ent
);
1745 end Handle_Prim_Ops
;
1747 -- Before we go ahead and output the references we have a problem
1748 -- that needs dealing with. So far we have captured things that are
1749 -- definitely referenced by the main unit, or defined in the main
1750 -- unit. That's because we don't want to clutter up the ali file
1751 -- for this unit with definition lines for entities in other units
1752 -- that are not referenced.
1754 -- But there is a glitch. We may reference an entity in another unit,
1755 -- and it may have a type reference to an entity that is not directly
1756 -- referenced in the main unit, which may mean that there is no xref
1757 -- entry for this entity yet in the list of references.
1759 -- If we don't do something about this, we will end with an orphan type
1760 -- reference, i.e. it will point to an entity that does not appear
1761 -- within the generated references in the ali file. That is not good for
1762 -- tools using the xref information.
1764 -- To fix this, we go through the references adding definition entries
1765 -- for any unreferenced entities that can be referenced in a type
1766 -- reference. There is a recursion problem here, and that is dealt with
1767 -- by making sure that this traversal also traverses any entries that
1768 -- get added by the traversal.
1770 Handle_Orphan_Type_References
: declare
1776 pragma Warnings
(Off
, L
);
1777 pragma Warnings
(Off
, R
);
1779 procedure New_Entry
(E
: Entity_Id
);
1780 -- Make an additional entry into the Xref table for a type entity
1781 -- that is related to the current entity (parent, type ancestor,
1782 -- progenitor, etc.).
1788 procedure New_Entry
(E
: Entity_Id
) is
1790 pragma Assert
(Present
(E
));
1792 if not Has_Xref_Entry
(Implementation_Base_Type
(E
))
1793 and then Sloc
(E
) > No_Location
1798 Typ
=> Character'First,
1799 Eun
=> Get_Source_Unit
(Original_Location
(Sloc
(E
))),
1802 Ent_Scope
=> Empty
),
1803 Ent_Scope_File
=> No_Unit
);
1807 -- Start of processing for Handle_Orphan_Type_References
1810 -- Note that this is not a for loop for a very good reason. The
1811 -- processing of items in the table can add new items to the table,
1812 -- and they must be processed as well.
1815 while J
<= Xrefs
.Last
loop
1816 Ent
:= Xrefs
.Table
(J
).Key
.Ent
;
1818 -- Do not generate reference information for an ignored Ghost
1819 -- entity because neither the entity nor its references will
1820 -- appear in the final tree.
1822 if Is_Ignored_Ghost_Entity
(Ent
) then
1823 goto Orphan_Continue
;
1826 Get_Type_Reference
(Ent
, Tref
, L
, R
);
1829 and then not Has_Xref_Entry
(Tref
)
1830 and then Sloc
(Tref
) > No_Location
1834 if Is_Record_Type
(Ent
)
1835 and then Present
(Interfaces
(Ent
))
1837 -- Add an entry for each one of the given interfaces
1838 -- implemented by type Ent.
1841 Elmt
: Elmt_Id
:= First_Elmt
(Interfaces
(Ent
));
1843 while Present
(Elmt
) loop
1844 New_Entry
(Node
(Elmt
));
1851 -- Collect inherited primitive operations that may be declared in
1852 -- another unit and have no visible reference in the current one.
1855 and then Is_Tagged_Type
(Ent
)
1856 and then Is_Derived_Type
(Ent
)
1857 and then Is_Base_Type
(Ent
)
1858 and then In_Extended_Main_Source_Unit
(Ent
)
1861 Op_List
: constant Elist_Id
:= Primitive_Operations
(Ent
);
1865 function Parent_Op
(E
: Entity_Id
) return Entity_Id
;
1866 -- Find original operation, which may be inherited through
1867 -- several derivations.
1869 function Parent_Op
(E
: Entity_Id
) return Entity_Id
is
1870 Orig_Op
: constant Entity_Id
:= Alias
(E
);
1873 if No
(Orig_Op
) then
1876 elsif not Comes_From_Source
(E
)
1877 and then not Has_Xref_Entry
(Orig_Op
)
1878 and then Comes_From_Source
(Orig_Op
)
1882 return Parent_Op
(Orig_Op
);
1887 Op
:= First_Elmt
(Op_List
);
1888 while Present
(Op
) loop
1889 Prim
:= Parent_Op
(Node
(Op
));
1891 if Present
(Prim
) then
1895 Typ
=> Character'First,
1896 Eun
=> Get_Source_Unit
(Sloc
(Prim
)),
1899 Ent_Scope
=> Empty
),
1900 Ent_Scope_File
=> No_Unit
);
1911 end Handle_Orphan_Type_References
;
1913 -- Now we have all the references, including those for any embedded type
1914 -- references, so we can sort them, and output them.
1916 Output_Refs
: declare
1917 Nrefs
: constant Nat
:= Xrefs
.Last
;
1918 -- Number of references in table
1920 Rnums
: array (0 .. Nrefs
) of Nat
;
1921 -- This array contains numbers of references in the Xrefs table.
1922 -- This list is sorted in output order. The extra 0'th entry is
1923 -- convenient for the call to sort. When we sort the table, we
1924 -- move the entries in Rnums around, but we do not move the
1925 -- original table entries.
1927 Curxu
: Unit_Number_Type
;
1928 -- Current xref unit
1930 Curru
: Unit_Number_Type
;
1931 -- Current reference unit for one entity
1936 Curnam
: String (1 .. Name_Buffer
'Length);
1938 -- Simple name and length of current entity
1940 Curdef
: Source_Ptr
;
1941 -- Original source location for current entity
1944 -- Current reference location
1947 -- Entity type character
1950 -- reference kind of previous reference
1956 -- Renaming reference
1958 Trunit
: Unit_Number_Type
;
1959 -- Unit number for type reference
1961 function Lt
(Op1
, Op2
: Natural) return Boolean;
1962 -- Comparison function for Sort call
1964 function Name_Change
(X
: Entity_Id
) return Boolean;
1965 -- Determines if entity X has a different simple name from Curent
1967 procedure Move
(From
: Natural; To
: Natural);
1968 -- Move procedure for Sort call
1970 package Sorting
is new GNAT
.Heap_Sort_G
(Move
, Lt
);
1976 function Lt
(Op1
, Op2
: Natural) return Boolean is
1977 T1
: Xref_Entry
renames Xrefs
.Table
(Rnums
(Nat
(Op1
)));
1978 T2
: Xref_Entry
renames Xrefs
.Table
(Rnums
(Nat
(Op2
)));
1988 procedure Move
(From
: Natural; To
: Natural) is
1990 Rnums
(Nat
(To
)) := Rnums
(Nat
(From
));
1997 -- Why a string comparison here??? Why not compare Name_Id values???
1999 function Name_Change
(X
: Entity_Id
) return Boolean is
2001 Get_Unqualified_Name_String
(Chars
(X
));
2003 if Name_Len
/= Curlen
then
2006 return Name_Buffer
(1 .. Curlen
) /= Curnam
(1 .. Curlen
);
2010 -- Start of processing for Output_Refs
2013 -- Capture the definition Sloc values. We delay doing this till now,
2014 -- since at the time the reference or definition is made, private
2015 -- types may be swapped, and the Sloc value may be incorrect. We
2016 -- also set up the pointer vector for the sort.
2018 -- For user-defined operators we need to skip the initial quote and
2019 -- point to the first character of the name, for navigation purposes.
2021 for J
in 1 .. Nrefs
loop
2023 E
: constant Entity_Id
:= Xrefs
.Table
(J
).Key
.Ent
;
2024 Loc
: constant Source_Ptr
:= Original_Location
(Sloc
(E
));
2029 if Nkind
(E
) = N_Defining_Operator_Symbol
then
2030 Xrefs
.Table
(J
).Def
:= Loc
+ 1;
2032 Xrefs
.Table
(J
).Def
:= Loc
;
2037 -- Sort the references
2039 Sorting
.Sort
(Integer (Nrefs
));
2041 -- Initialize loop through references
2045 Curdef
:= No_Location
;
2047 Crloc
:= No_Location
;
2050 -- Loop to output references
2052 for Refno
in 1 .. Nrefs
loop
2053 Output_One_Ref
: declare
2056 XE
: Xref_Entry
renames Xrefs
.Table
(Rnums
(Refno
));
2057 -- The current entry to be accessed
2061 -- Used for {} or <> or () for type reference
2063 procedure Check_Type_Reference
2065 List_Interface
: Boolean;
2066 Is_Component
: Boolean := False);
2067 -- Find whether there is a meaningful type reference for
2068 -- Ent, and display it accordingly. If List_Interface is
2069 -- true, then Ent is a progenitor interface of the current
2070 -- type entity being listed. In that case list it as is,
2071 -- without looking for a type reference for it. Flag is also
2072 -- used for index types of an array type, where the caller
2073 -- supplies the intended type reference. Is_Component serves
2074 -- the same purpose, to display the component type of a
2075 -- derived array type, for which only the parent type has
2076 -- ben displayed so far.
2078 procedure Output_Instantiation_Refs
(Loc
: Source_Ptr
);
2079 -- Recursive procedure to output instantiation references for
2080 -- the given source ptr in [file|line[...]] form. No output
2081 -- if the given location is not a generic template reference.
2083 procedure Output_Overridden_Op
(Old_E
: Entity_Id
);
2084 -- For a subprogram that is overriding, display information
2085 -- about the inherited operation that it overrides.
2087 --------------------------
2088 -- Check_Type_Reference --
2089 --------------------------
2091 procedure Check_Type_Reference
2093 List_Interface
: Boolean;
2094 Is_Component
: Boolean := False)
2097 if List_Interface
then
2099 -- This is a progenitor interface of the type for which
2100 -- xref information is being generated.
2106 -- The following is not documented in lib-xref.ads ???
2108 elsif Is_Component
then
2114 Get_Type_Reference
(Ent
, Tref
, Left
, Right
);
2117 if Present
(Tref
) then
2119 -- Case of standard entity, output name
2121 if Sloc
(Tref
) = Standard_Location
then
2122 Write_Info_Char
(Left
);
2123 Write_Info_Name
(Chars
(Tref
));
2124 Write_Info_Char
(Right
);
2126 -- Case of source entity, output location
2129 Write_Info_Char
(Left
);
2130 Trunit
:= Get_Source_Unit
(Sloc
(Tref
));
2132 if Trunit
/= Curxu
then
2133 Write_Info_Nat
(Dependency_Num
(Trunit
));
2134 Write_Info_Char
('|');
2138 (Int
(Get_Logical_Line_Number
(Sloc
(Tref
))));
2146 Ctyp
:= Xref_Entity_Letters
(Ekind
(Ent
));
2149 and then Present
(Full_View
(Ent
))
2151 Ent
:= Underlying_Type
(Ent
);
2153 if Present
(Ent
) then
2154 Ctyp
:= Xref_Entity_Letters
(Ekind
(Ent
));
2158 Write_Info_Char
(Ctyp
);
2162 (Int
(Get_Column_Number
(Sloc
(Tref
))));
2164 -- If the type comes from an instantiation, add the
2165 -- corresponding info.
2167 Output_Instantiation_Refs
(Sloc
(Tref
));
2168 Write_Info_Char
(Right
);
2171 end Check_Type_Reference
;
2173 -------------------------------
2174 -- Output_Instantiation_Refs --
2175 -------------------------------
2177 procedure Output_Instantiation_Refs
(Loc
: Source_Ptr
) is
2178 Iloc
: constant Source_Ptr
:= Instantiation_Location
(Loc
);
2179 Lun
: Unit_Number_Type
;
2180 Cu
: constant Unit_Number_Type
:= Curru
;
2183 -- Nothing to do if this is not an instantiation
2185 if Iloc
= No_Location
then
2189 -- Output instantiation reference
2191 Write_Info_Char
('[');
2192 Lun
:= Get_Source_Unit
(Iloc
);
2194 if Lun
/= Curru
then
2196 Write_Info_Nat
(Dependency_Num
(Curru
));
2197 Write_Info_Char
('|');
2200 Write_Info_Nat
(Int
(Get_Logical_Line_Number
(Iloc
)));
2202 -- Recursive call to get nested instantiations
2204 Output_Instantiation_Refs
(Iloc
);
2206 -- Output final ] after call to get proper nesting
2208 Write_Info_Char
(']');
2211 end Output_Instantiation_Refs
;
2213 --------------------------
2214 -- Output_Overridden_Op --
2215 --------------------------
2217 procedure Output_Overridden_Op
(Old_E
: Entity_Id
) is
2221 -- The overridden operation has an implicit declaration
2222 -- at the point of derivation. What we want to display
2223 -- is the original operation, which has the actual body
2224 -- (or abstract declaration) that is being overridden.
2225 -- The overridden operation is not always set, e.g. when
2226 -- it is a predefined operator.
2231 -- Follow alias chain if one is present
2233 elsif Present
(Alias
(Old_E
)) then
2235 -- The subprogram may have been implicitly inherited
2236 -- through several levels of derivation, so find the
2237 -- ultimate (source) ancestor.
2239 Op
:= Ultimate_Alias
(Old_E
);
2241 -- Normal case of no alias present. We omit generated
2242 -- primitives like tagged equality, that have no source
2250 and then Sloc
(Op
) /= Standard_Location
2251 and then Comes_From_Source
(Op
)
2254 Loc
: constant Source_Ptr
:= Sloc
(Op
);
2255 Par_Unit
: constant Unit_Number_Type
:=
2256 Get_Source_Unit
(Loc
);
2259 Write_Info_Char
('<');
2261 if Par_Unit
/= Curxu
then
2262 Write_Info_Nat
(Dependency_Num
(Par_Unit
));
2263 Write_Info_Char
('|');
2266 Write_Info_Nat
(Int
(Get_Logical_Line_Number
(Loc
)));
2267 Write_Info_Char
('p');
2268 Write_Info_Nat
(Int
(Get_Column_Number
(Loc
)));
2269 Write_Info_Char
('>');
2272 end Output_Overridden_Op
;
2274 -- Start of processing for Output_One_Ref
2279 -- Do not generate reference information for an ignored Ghost
2280 -- entity because neither the entity nor its references will
2281 -- appear in the final tree.
2283 if Is_Ignored_Ghost_Entity
(Ent
) then
2287 Ctyp
:= Xref_Entity_Letters
(Ekind
(Ent
));
2289 -- Skip reference if it is the only reference to an entity,
2290 -- and it is an END line reference, and the entity is not in
2291 -- the current extended source. This prevents junk entries
2292 -- consisting only of packages with END lines, where no
2293 -- entity from the package is actually referenced.
2296 and then Ent
/= Curent
2297 and then (Refno
= Nrefs
2299 Ent
/= Xrefs
.Table
(Rnums
(Refno
+ 1)).Key
.Ent
)
2300 and then not In_Extended_Main_Source_Unit
(Ent
)
2305 -- For private type, get full view type
2308 and then Present
(Full_View
(XE
.Key
.Ent
))
2310 Ent
:= Underlying_Type
(Ent
);
2312 if Present
(Ent
) then
2313 Ctyp
:= Xref_Entity_Letters
(Ekind
(Ent
));
2317 -- Special exception for Boolean
2319 if Ctyp
= 'E' and then Is_Boolean_Type
(Ent
) then
2323 -- For variable reference, get corresponding type
2326 Ent
:= Etype
(XE
.Key
.Ent
);
2327 Ctyp
:= Fold_Lower
(Xref_Entity_Letters
(Ekind
(Ent
)));
2329 -- If variable is private type, get full view type
2332 and then Present
(Full_View
(Etype
(XE
.Key
.Ent
)))
2334 Ent
:= Underlying_Type
(Etype
(XE
.Key
.Ent
));
2336 if Present
(Ent
) then
2337 Ctyp
:= Fold_Lower
(Xref_Entity_Letters
(Ekind
(Ent
)));
2340 elsif Is_Generic_Type
(Ent
) then
2342 -- If the type of the entity is a generic private type,
2343 -- there is no usable full view, so retain the indication
2344 -- that this is an object.
2349 -- Special handling for access parameters and objects and
2350 -- components of an anonymous access type.
2352 if Ekind
(Etype
(XE
.Key
.Ent
)) in
2353 E_Anonymous_Access_Type
2354 | E_Anonymous_Access_Subprogram_Type
2355 | E_Anonymous_Access_Protected_Subprogram_Type
2357 if Is_Formal
(XE
.Key
.Ent
)
2359 Ekind
(XE
.Key
.Ent
) in
2360 E_Variable | E_Constant | E_Component
2365 -- Special handling for Boolean
2367 elsif Ctyp
= 'e' and then Is_Boolean_Type
(Ent
) then
2372 -- Special handling for abstract types and operations
2374 if Is_Overloadable
(XE
.Key
.Ent
)
2375 and then Is_Abstract_Subprogram
(XE
.Key
.Ent
)
2378 Ctyp
:= 'x'; -- Abstract procedure
2380 elsif Ctyp
= 'V' then
2381 Ctyp
:= 'y'; -- Abstract function
2384 elsif Is_Type
(XE
.Key
.Ent
)
2385 and then Is_Abstract_Type
(XE
.Key
.Ent
)
2387 if Is_Interface
(XE
.Key
.Ent
) then
2390 elsif Ctyp
= 'R' then
2391 Ctyp
:= 'H'; -- Abstract type
2395 -- Only output reference if interesting type of entity
2399 -- Suppress references to object definitions, used for local
2402 or else XE
.Key
.Typ
= 'D'
2403 or else XE
.Key
.Typ
= 'I'
2405 -- Suppress self references, except for bodies that act as
2408 or else (XE
.Key
.Loc
= XE
.Def
2411 or else not Is_Subprogram
(XE
.Key
.Ent
)))
2413 -- Also suppress definitions of body formals (we only
2414 -- treat these as references, and the references were
2415 -- separately recorded).
2417 or else (Is_Formal
(XE
.Key
.Ent
)
2418 and then Present
(Spec_Entity
(XE
.Key
.Ent
)))
2423 -- Start new Xref section if new xref unit
2425 if XE
.Key
.Eun
/= Curxu
then
2426 if Write_Info_Col
> 1 then
2430 Curxu
:= XE
.Key
.Eun
;
2432 Write_Info_Initiate
('X');
2433 Write_Info_Char
(' ');
2434 Write_Info_Nat
(Dependency_Num
(XE
.Key
.Eun
));
2435 Write_Info_Char
(' ');
2437 (Reference_Name
(Source_Index
(XE
.Key
.Eun
)));
2440 -- Start new Entity line if new entity. Note that we
2441 -- consider two entities the same if they have the same
2442 -- name and source location. This causes entities in
2443 -- instantiations to be treated as though they referred
2448 (XE
.Key
.Ent
/= Curent
2450 (Name_Change
(XE
.Key
.Ent
) or else XE
.Def
/= Curdef
))
2452 Curent
:= XE
.Key
.Ent
;
2455 Get_Unqualified_Name_String
(Chars
(XE
.Key
.Ent
));
2457 Curnam
(1 .. Curlen
) := Name_Buffer
(1 .. Curlen
);
2459 if Write_Info_Col
> 1 then
2463 -- Write column number information
2465 Write_Info_Nat
(Int
(Get_Logical_Line_Number
(XE
.Def
)));
2466 Write_Info_Char
(Ctyp
);
2467 Write_Info_Nat
(Int
(Get_Column_Number
(XE
.Def
)));
2469 -- Write level information
2471 Write_Level_Info
: declare
2472 function Is_Visible_Generic_Entity
2473 (E
: Entity_Id
) return Boolean;
2474 -- Check whether E is declared in the visible part
2475 -- of a generic package. For source navigation
2476 -- purposes, treat this as a visible entity.
2478 function Is_Private_Record_Component
2479 (E
: Entity_Id
) return Boolean;
2480 -- Check whether E is a non-inherited component of a
2481 -- private extension. Even if the enclosing record is
2482 -- public, we want to treat the component as private
2483 -- for navigation purposes.
2485 ---------------------------------
2486 -- Is_Private_Record_Component --
2487 ---------------------------------
2489 function Is_Private_Record_Component
2490 (E
: Entity_Id
) return Boolean
2492 S
: constant Entity_Id
:= Scope
(E
);
2495 Ekind
(E
) = E_Component
2496 and then Nkind
(Declaration_Node
(S
)) =
2497 N_Private_Extension_Declaration
2498 and then Original_Record_Component
(E
) = E
;
2499 end Is_Private_Record_Component
;
2501 -------------------------------
2502 -- Is_Visible_Generic_Entity --
2503 -------------------------------
2505 function Is_Visible_Generic_Entity
2506 (E
: Entity_Id
) return Boolean
2511 -- The Present check here is an error defense
2513 if Present
(Scope
(E
))
2514 and then Ekind
(Scope
(E
)) /= E_Generic_Package
2520 while Present
(Par
) loop
2522 Nkind
(Par
) = N_Generic_Package_Declaration
2524 -- Entity is a generic formal
2529 Nkind
(Parent
(Par
)) = N_Package_Specification
2532 Is_List_Member
(Par
)
2533 and then List_Containing
(Par
) =
2534 Visible_Declarations
(Parent
(Par
));
2536 Par
:= Parent
(Par
);
2541 end Is_Visible_Generic_Entity
;
2543 -- Start of processing for Write_Level_Info
2546 if Is_Hidden
(Curent
)
2547 or else Is_Private_Record_Component
(Curent
)
2549 Write_Info_Char
(' ');
2553 or else Is_Visible_Generic_Entity
(Curent
)
2555 Write_Info_Char
('*');
2558 Write_Info_Char
(' ');
2560 end Write_Level_Info
;
2562 -- Output entity name. We use the occurrence from the
2563 -- actual source program at the definition point.
2566 Ent_Name
: constant String :=
2567 Exact_Source_Name
(Sloc
(XE
.Key
.Ent
));
2569 for C
in Ent_Name
'Range loop
2570 Write_Info_Char
(Ent_Name
(C
));
2574 -- See if we have a renaming reference
2576 if Is_Object
(XE
.Key
.Ent
)
2577 and then Present
(Renamed_Object
(XE
.Key
.Ent
))
2579 Rref
:= Renamed_Object
(XE
.Key
.Ent
);
2581 elsif Is_Overloadable
(XE
.Key
.Ent
)
2582 and then Nkind
(Parent
(Declaration_Node
(XE
.Key
.Ent
)))
2583 = N_Subprogram_Renaming_Declaration
2585 Rref
:= Name
(Parent
(Declaration_Node
(XE
.Key
.Ent
)));
2587 elsif Ekind
(XE
.Key
.Ent
) = E_Package
2588 and then Nkind
(Declaration_Node
(XE
.Key
.Ent
)) =
2589 N_Package_Renaming_Declaration
2591 Rref
:= Name
(Declaration_Node
(XE
.Key
.Ent
));
2597 if Present
(Rref
) then
2598 if Nkind
(Rref
) = N_Expanded_Name
then
2599 Rref
:= Selector_Name
(Rref
);
2602 if Nkind
(Rref
) = N_Identifier
2603 or else Nkind
(Rref
) = N_Operator_Symbol
2607 -- For renamed array components, use the array name
2608 -- for the renamed entity, which reflect the fact that
2609 -- in general the whole array is aliased.
2611 elsif Nkind
(Rref
) = N_Indexed_Component
then
2612 if Nkind
(Prefix
(Rref
)) = N_Identifier
then
2613 Rref
:= Prefix
(Rref
);
2614 elsif Nkind
(Prefix
(Rref
)) = N_Expanded_Name
then
2615 Rref
:= Selector_Name
(Prefix
(Rref
));
2625 -- Write out renaming reference if we have one
2627 if Present
(Rref
) then
2628 Write_Info_Char
('=');
2630 (Int
(Get_Logical_Line_Number
(Sloc
(Rref
))));
2631 Write_Info_Char
(':');
2633 (Int
(Get_Column_Number
(Sloc
(Rref
))));
2636 -- Indicate that the entity is in the unit of the current
2641 -- Write out information about generic parent, if entity
2644 if Is_Generic_Instance
(XE
.Key
.Ent
) then
2646 Gen_Par
: constant Entity_Id
:=
2649 (Unit_Declaration_Node
2651 Loc
: constant Source_Ptr
:= Sloc
(Gen_Par
);
2652 Gen_U
: constant Unit_Number_Type
:=
2653 Get_Source_Unit
(Loc
);
2656 Write_Info_Char
('[');
2658 if Curru
/= Gen_U
then
2659 Write_Info_Nat
(Dependency_Num
(Gen_U
));
2660 Write_Info_Char
('|');
2664 (Int
(Get_Logical_Line_Number
(Loc
)));
2665 Write_Info_Char
(']');
2669 -- See if we have a type reference and if so output
2671 Check_Type_Reference
(XE
.Key
.Ent
, False);
2673 -- Additional information for types with progenitors,
2674 -- including synchronized tagged types.
2677 Typ
: constant Entity_Id
:= XE
.Key
.Ent
;
2681 if Is_Record_Type
(Typ
)
2682 and then Present
(Interfaces
(Typ
))
2684 Elmt
:= First_Elmt
(Interfaces
(Typ
));
2686 elsif Is_Concurrent_Type
(Typ
)
2687 and then Present
(Corresponding_Record_Type
(Typ
))
2689 Interfaces
(Corresponding_Record_Type
(Typ
)))
2693 Interfaces
(Corresponding_Record_Type
(Typ
)));
2699 while Present
(Elmt
) loop
2700 Check_Type_Reference
(Node
(Elmt
), True);
2705 -- For array types, list index types as well. (This is
2706 -- not C, indexes have distinct types).
2708 if Is_Array_Type
(XE
.Key
.Ent
) then
2710 A_Typ
: constant Entity_Id
:= XE
.Key
.Ent
;
2714 -- If this is a derived array type, we have
2715 -- output the parent type, so add the component
2718 if Is_Derived_Type
(A_Typ
) then
2719 Check_Type_Reference
2720 (Component_Type
(A_Typ
), False, True);
2723 -- Add references to index types.
2725 Indx
:= First_Index
(XE
.Key
.Ent
);
2726 while Present
(Indx
) loop
2727 Check_Type_Reference
2728 (First_Subtype
(Etype
(Indx
)), True);
2734 -- If the entity is an overriding operation, write info
2735 -- on operation that was overridden.
2737 if Is_Subprogram
(XE
.Key
.Ent
)
2738 and then Present
(Overridden_Operation
(XE
.Key
.Ent
))
2740 Output_Overridden_Op
2741 (Overridden_Operation
(XE
.Key
.Ent
));
2744 -- End of processing for entity output
2746 Crloc
:= No_Location
;
2749 -- Output the reference if it is not as the same location
2750 -- as the previous one, or it is a read-reference that
2751 -- indicates that the entity is an in-out actual in a call.
2753 if XE
.Key
.Loc
/= No_Location
2755 (XE
.Key
.Loc
/= Crloc
2756 or else (Prevt
= 'm' and then XE
.Key
.Typ
= 'r'))
2758 Crloc
:= XE
.Key
.Loc
;
2759 Prevt
:= XE
.Key
.Typ
;
2761 -- Start continuation if line full, else blank
2763 if Write_Info_Col
> 72 then
2765 Write_Info_Initiate
('.');
2768 Write_Info_Char
(' ');
2770 -- Output file number if changed
2772 if XE
.Key
.Lun
/= Curru
then
2773 Curru
:= XE
.Key
.Lun
;
2774 Write_Info_Nat
(Dependency_Num
(Curru
));
2775 Write_Info_Char
('|');
2779 (Int
(Get_Logical_Line_Number
(XE
.Key
.Loc
)));
2780 Write_Info_Char
(XE
.Key
.Typ
);
2782 if Is_Overloadable
(XE
.Key
.Ent
) then
2783 if (Is_Imported
(XE
.Key
.Ent
) and then XE
.Key
.Typ
= 'b')
2785 (Is_Exported
(XE
.Key
.Ent
) and then XE
.Key
.Typ
= 'i')
2787 Output_Import_Export_Info
(XE
.Key
.Ent
);
2791 Write_Info_Nat
(Int
(Get_Column_Number
(XE
.Key
.Loc
)));
2793 Output_Instantiation_Refs
(Sloc
(XE
.Key
.Ent
));
2804 end Output_References
;
2806 ---------------------------------
2807 -- Process_Deferred_References --
2808 ---------------------------------
2810 procedure Process_Deferred_References
is
2812 for J
in Deferred_References
.First
.. Deferred_References
.Last
loop
2814 D
: Deferred_Reference_Entry
renames Deferred_References
.Table
(J
);
2817 case Is_LHS
(D
.N
) is
2819 Generate_Reference
(D
.E
, D
.N
, 'm');
2822 Generate_Reference
(D
.E
, D
.N
, 'r');
2824 -- Not clear if Unknown can occur at this stage, but if it
2825 -- does we will treat it as a normal reference.
2828 Generate_Reference
(D
.E
, D
.N
, 'r');
2833 -- Clear processed entries from table
2835 Deferred_References
.Init
;
2836 end Process_Deferred_References
;
2838 -- Start of elaboration for Lib.Xref
2841 -- Reset is necessary because Elmt_Ptr does not default to Null_Ptr,
2842 -- because it's not an access type.