Alfa cross references should only contain 'call' references for operators.
Filter out unwanted references which are otherwise generated on intrinsic
operator.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-31  Yannick Moy  <m...@adacore.com>

        * lib-xref-alfa.adb (Add_Alfa_Xrefs): Do not take into account read
        reference to operator in Alfa xrefs.

Index: lib-xref-alfa.adb
===================================================================
--- lib-xref-alfa.adb   (revision 178358)
+++ lib-xref-alfa.adb   (working copy)
@@ -576,6 +576,11 @@
       Eliminate_Before_Sort : declare
          NR : Nat;
 
+         function Is_Alfa_Reference
+           (E   : Entity_Id;
+            Typ : Character) return Boolean;
+         --  Return whether the reference is adequate for this entity
+
          function Is_Alfa_Scope (E : Entity_Id) return Boolean;
          --  Return whether the entity or reference scope is adequate
 
@@ -583,6 +588,25 @@
          --  Return True if E is a global constant for which we should ignore
          --  reads in Alfa.
 
+         -----------------------
+         -- Is_Alfa_Reference --
+         -----------------------
+
+         function Is_Alfa_Reference
+           (E   : Entity_Id;
+            Typ : Character) return Boolean is
+         begin
+            --  The only references of interest on callable entities are calls.
+            --  On non-callable entities, the only references of interest are
+            --  reads and writes.
+
+            if Ekind (E) in Overloadable_Kind then
+               return Typ = 's';
+            else
+               return Typ = 'r' or else Typ = 'm';
+            end if;
+         end Is_Alfa_Reference;
+
          -------------------
          -- Is_Alfa_Scope --
          -------------------
@@ -617,6 +641,8 @@
               and then Is_Alfa_Scope (Xrefs.Table (Rnums (J)).Ent_Scope)
               and then Is_Alfa_Scope (Xrefs.Table (Rnums (J)).Ref_Scope)
               and then not Is_Global_Constant (Xrefs.Table (Rnums (J)).Ent)
+              and then Is_Alfa_Reference (Xrefs.Table (Rnums (J)).Ent,
+                                          Xrefs.Table (Rnums (J)).Typ)
             then
                Nrefs         := Nrefs + 1;
                Rnums (Nrefs) := Rnums (J);

Reply via email to