diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-18 10:48:33 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-18 10:48:33 +0000 |
commit | 582f02f41fc95911fa17ee46823814d6cdad61a5 (patch) | |
tree | 2c662c1707d15631c783d9d9a863a520b4ba13c7 /gcc/ada | |
parent | c175273ca62fb80a836f098794d4cfd64c517dec (diff) | |
download | gcc-582f02f41fc95911fa17ee46823814d6cdad61a5.tar.gz |
2016-04-18 Bob Duff <duff@adacore.com>
* sinput.ads, sinput.adb (Build_Location_String): Take a
parameter instead of using a global variable. The function
version no longer destroys the Name_Buffer.
* stringt.ads, stringt.adb (String_From_Name_Buffer): Take a
parameter, which defaults to the Global_Name_Buffer, so some
calls can avoid the global.
* exp_ch11.adb, exp_intr.adb: Use new interfaces above
to avoid using globals. All but one call to Build_Location_String
avoids the global. Only one call to String_From_Name_Buffer
avoids it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235126 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/ada/exp_ch11.adb | 14 | ||||
-rw-r--r-- | gcc/ada/exp_intr.adb | 2 | ||||
-rw-r--r-- | gcc/ada/sinput.adb | 28 | ||||
-rw-r--r-- | gcc/ada/sinput.ads | 15 | ||||
-rw-r--r-- | gcc/ada/stringt.adb | 12 | ||||
-rw-r--r-- | gcc/ada/stringt.ads | 10 |
7 files changed, 49 insertions, 45 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 143a6a10309..1fc22a7e12a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,16 @@ +2016-04-18 Bob Duff <duff@adacore.com> + + * sinput.ads, sinput.adb (Build_Location_String): Take a + parameter instead of using a global variable. The function + version no longer destroys the Name_Buffer. + * stringt.ads, stringt.adb (String_From_Name_Buffer): Take a + parameter, which defaults to the Global_Name_Buffer, so some + calls can avoid the global. + * exp_ch11.adb, exp_intr.adb: Use new interfaces above + to avoid using globals. All but one call to Build_Location_String + avoids the global. Only one call to String_From_Name_Buffer + avoids it. + 2016-04-18 Hristian Kirtchev <kirtchev@adacore.com> * namet.adb, namet.ads, exp_unst.adb: Minor reformatting. diff --git a/gcc/ada/exp_ch11.adb b/gcc/ada/exp_ch11.adb index 89dd350ffba..653007c63c6 100644 --- a/gcc/ada/exp_ch11.adb +++ b/gcc/ada/exp_ch11.adb @@ -1658,10 +1658,10 @@ package body Exp_Ch11 is if Present (Name (N)) then declare Id : Entity_Id := Entity (Name (N)); + Buf : Bounded_String; begin - Name_Len := 0; - Build_Location_String (Loc); + Build_Location_String (Buf, Loc); -- If the exception is a renaming, use the exception that it -- renames (which might be a predefined exception, e.g.). @@ -1679,19 +1679,17 @@ package body Exp_Ch11 is -- Suppress_Exception_Locations is set for this unit. if Opt.Exception_Locations_Suppressed then - Name_Len := 1; - else - Name_Len := Name_Len + 1; + Buf.Length := 0; end if; - Name_Buffer (Name_Len) := ASCII.NUL; + Append (Buf, ASCII.NUL); end if; if Opt.Exception_Locations_Suppressed then - Name_Len := 0; + Buf.Length := 0; end if; - Str := String_From_Name_Buffer; + Str := String_From_Name_Buffer (Buf); -- Convert raise to call to the Raise_Exception routine diff --git a/gcc/ada/exp_intr.adb b/gcc/ada/exp_intr.adb index f0307821c08..8b2d1f2bdb7 100644 --- a/gcc/ada/exp_intr.adb +++ b/gcc/ada/exp_intr.adb @@ -145,7 +145,7 @@ package body Exp_Intr is (Reference_Name (Get_Source_File_Index (Loc))); when Name_Source_Location => - Build_Location_String (Loc); + Build_Location_String (Global_Name_Buffer, Loc); when Name_Enclosing_Entity => diff --git a/gcc/ada/sinput.adb b/gcc/ada/sinput.adb index 1c8232d1c83..0800f3196a6 100644 --- a/gcc/ada/sinput.adb +++ b/gcc/ada/sinput.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2015, 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- -- @@ -221,33 +221,31 @@ package body Sinput is -- Build_Location_String -- --------------------------- - procedure Build_Location_String (Loc : Source_Ptr) is - Ptr : Source_Ptr; + procedure Build_Location_String + (Buf : in out Bounded_String; + Loc : Source_Ptr) + is + Ptr : Source_Ptr := Loc; begin -- Loop through instantiations - Ptr := Loc; loop - Get_Name_String_And_Append - (Reference_Name (Get_Source_File_Index (Ptr))); - Add_Char_To_Name_Buffer (':'); - Add_Nat_To_Name_Buffer (Nat (Get_Logical_Line_Number (Ptr))); + Append (Buf, Reference_Name (Get_Source_File_Index (Ptr))); + Append (Buf, ':'); + Append (Buf, Nat (Get_Logical_Line_Number (Ptr))); Ptr := Instantiation_Location (Ptr); exit when Ptr = No_Location; - Add_Str_To_Name_Buffer (" instantiated at "); + Append (Buf, " instantiated at "); end loop; - - Name_Buffer (Name_Len + 1) := NUL; - return; end Build_Location_String; function Build_Location_String (Loc : Source_Ptr) return String is + Buf : Bounded_String; begin - Name_Len := 0; - Build_Location_String (Loc); - return Name_Buffer (1 .. Name_Len); + Build_Location_String (Buf, Loc); + return +Buf; end Build_Location_String; ------------------- diff --git a/gcc/ada/sinput.ads b/gcc/ada/sinput.ads index f1a27245afc..18bc1b1efdb 100644 --- a/gcc/ada/sinput.ads +++ b/gcc/ada/sinput.ads @@ -536,18 +536,17 @@ package Sinput is -- The caller has checked that a Line_Terminator character precedes P so -- that there definitely is a previous line in the source buffer. - procedure Build_Location_String (Loc : Source_Ptr); + procedure Build_Location_String + (Buf : in out Bounded_String; + Loc : Source_Ptr); -- This function builds a string literal of the form "name:line", where -- name is the file name corresponding to Loc, and line is the line number. - -- In the event that instantiations are involved, additional suffixes of - -- the same form are appended after the separating string " instantiated at - -- ". The returned string is appended to the Name_Buffer, terminated by - -- ASCII.NUL, with Name_Length indicating the length not including the - -- terminating Nul. + -- If instantiations are involved, additional suffixes of the same form are + -- appended after the separating string " instantiated at ". The returned + -- string is appended to Buf. function Build_Location_String (Loc : Source_Ptr) return String; - -- Functional form returning a string, which does not include a terminating - -- null character. The contents of Name_Buffer is destroyed. + -- Functional form returning a String procedure Check_For_BOM; -- Check if the current source starts with a BOM. Scan_Ptr needs to be at diff --git a/gcc/ada/stringt.adb b/gcc/ada/stringt.adb index 5a0c89c7d04..b4d85629908 100644 --- a/gcc/ada/stringt.adb +++ b/gcc/ada/stringt.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2015, 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- -- @@ -30,7 +30,6 @@ ------------------------------------------------------------------------------ with Alloc; -with Namet; use Namet; with Output; use Output; with Table; @@ -307,14 +306,11 @@ package body Stringt is -- String_From_Name_Buffer -- ----------------------------- - function String_From_Name_Buffer return String_Id is + function String_From_Name_Buffer + (Buf : Bounded_String := Global_Name_Buffer) return String_Id is begin Start_String; - - for J in 1 .. Name_Len loop - Store_String_Char (Get_Char_Code (Name_Buffer (J))); - end loop; - + Store_String_Chars (+Buf); return End_String; end String_From_Name_Buffer; diff --git a/gcc/ada/stringt.ads b/gcc/ada/stringt.ads index 92b74e2c049..c48f2b9def8 100644 --- a/gcc/ada/stringt.ads +++ b/gcc/ada/stringt.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2015, 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- -- @@ -29,6 +29,7 @@ -- -- ------------------------------------------------------------------------------ +with Namet; use Namet; with System; use System; with Types; use Types; @@ -131,10 +132,9 @@ package Stringt is function String_Chars_Address return System.Address; -- Return address of String_Chars table (used by Back_End call to Gigi) - function String_From_Name_Buffer return String_Id; - -- Given a name stored in Namet.Name_Buffer (length in Namet.Name_Len), - -- returns a string of the corresponding value. The value in Name_Buffer - -- is unchanged, and the cases of letters are unchanged. + function String_From_Name_Buffer + (Buf : Bounded_String := Global_Name_Buffer) return String_Id; + -- Given a name stored in Buf, returns a string of the corresponding value. function Strings_Address return System.Address; -- Return address of Strings table (used by Back_End call to Gigi) |