This patch extends the information generated by the compiler in ALI files adding references to entities exported to foreign languages. This information can be used by cross reference tools and text editors (for example, GPS).
Tested on x86_64-pc-linux-gnu, committed on trunk 2012-06-12 Javier Miranda <mira...@adacore.com> * sem_prag.adb (Process_Convention): Generate reference to entity exported to foreign language. Needed for GPS navigation. * xref_lib.adb (Parse_Identifier_Info): Parse exported entities. * lib-xref (Output_References): Output exported entities.
Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 188437) +++ sem_prag.adb (working copy) @@ -3655,10 +3655,21 @@ Comp_Unit := Get_Source_Unit (E); Set_Convention_From_Pragma (E); - -- Treat a pragma Import as an implicit body, for GPS use + -- Treat a pragma Import as an implicit body, and pragma import + -- as implicit reference (for navigation in GPS). if Prag_Id = Pragma_Import then Generate_Reference (E, Id, 'b'); + + -- For exported entities we restrict the generation of references + -- to entities exported to foreign languages since entities + -- exported to Ada do not provide further information to GPS and + -- add undesired references to the output of the gnatxref tool. + + elsif Prag_Id = Pragma_Export + and then Convention (E) /= Convention_Ada + then + Generate_Reference (E, Id, 'i'); end if; -- Loop through the homonyms of the pragma argument's entity Index: xref_lib.adb =================================================================== --- xref_lib.adb (revision 188428) +++ xref_lib.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1998-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1998-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1105,9 +1105,10 @@ -- Imported entities might special indication as to their external -- name: - -- 5U14*Foo2 5>20 6b<c,myfoo2>22 + -- 5U14*Foo2 5>20 6b<c,myfoo2>22 # Imported entity + -- 5U14*Foo2 5>20 6i<c,myfoo2>22 # Exported entity - if R_Type = 'b' + if (R_Type = 'b' or else R_Type = 'i') and then Ali (Ptr) = '<' then while Ptr <= Ali'Last Index: lib-xref.adb =================================================================== --- lib-xref.adb (revision 188428) +++ lib-xref.adb (working copy) @@ -2441,11 +2441,13 @@ (Int (Get_Logical_Line_Number (XE.Key.Loc))); Write_Info_Char (XE.Key.Typ); - if Is_Overloadable (XE.Key.Ent) - and then Is_Imported (XE.Key.Ent) - and then XE.Key.Typ = 'b' - then - Output_Import_Export_Info (XE.Key.Ent); + if Is_Overloadable (XE.Key.Ent) then + if (Is_Imported (XE.Key.Ent) and then XE.Key.Typ = 'b') + or else + (Is_Exported (XE.Key.Ent) and then XE.Key.Typ = 'i') + then + Output_Import_Export_Info (XE.Key.Ent); + end if; end if; Write_Info_Nat (Int (Get_Column_Number (XE.Key.Loc)));