diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2019-07-09 07:54:24 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-09 07:54:24 +0000 |
commit | fb95bfcc8138378d4e5786c67f5eb49b84a54683 (patch) | |
tree | e1dcf002e74e595f3daed2460abe9c1866529992 | |
parent | 5da544339b2b3b3d00d3dd5b91c06d2d09a386b2 (diff) | |
download | gcc-fb95bfcc8138378d4e5786c67f5eb49b84a54683.zip gcc-fb95bfcc8138378d4e5786c67f5eb49b84a54683.tar.gz gcc-fb95bfcc8138378d4e5786c67f5eb49b84a54683.tar.bz2 |
[Ada] Missing escape of the double quote in JSON output
In Ada, the name of operators contains a pair of double quotes, which
need to be properly escaped when the name appears in the JSON output of
-gnatR.
The change also ensures that formal parameters are not listed in the
layout information, since this information is not back-annotated for
them.
2019-07-09 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* repinfo.adb (List_Entities): Disregard formals altogether.
(List_Name): Properly escape the double quote in the JSON
output.
From-SVN: r273279
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/repinfo.adb | 24 |
2 files changed, 21 insertions, 9 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index e5aba8b..1dd1d70 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-07-09 Eric Botcazou <ebotcazou@adacore.com> + + * repinfo.adb (List_Entities): Disregard formals altogether. + (List_Name): Properly escape the double quote in the JSON + output. + 2019-07-09 Javier Miranda <miranda@adacore.com> * exp_util.adb (Remove_Side_Effects): Preserve the diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index 75da2b6..1ba7e11 100644 --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -525,9 +525,6 @@ package body Repinfo is List_Entities (E, Bytes_Big_Endian, True); - elsif Is_Formal (E) and then In_Subprogram then - null; - elsif Ekind_In (E, E_Entry, E_Entry_Family, E_Subprogram_Type) @@ -560,12 +557,10 @@ package body Repinfo is List_Type_Info (E); end if; - elsif Ekind_In (E, E_Variable, E_Constant) then - if List_Representation_Info >= 2 then - List_Object_Info (E); - end if; + -- Note that formals are not annotated so we skip them here - elsif Ekind (E) = E_Loop_Parameter or else Is_Formal (E) then + elsif Ekind_In (E, E_Variable, E_Constant, E_Loop_Parameter) + then if List_Representation_Info >= 2 then List_Object_Info (E); end if; @@ -899,6 +894,8 @@ package body Repinfo is --------------- procedure List_Name (Ent : Entity_Id) is + C : Character; + begin -- List the qualified name recursively, except -- at compilation unit level in default mode. @@ -914,7 +911,16 @@ package body Repinfo is Get_Unqualified_Decoded_Name_String (Chars (Ent)); Set_Casing (Unit_Casing); - Write_Str (Name_Buffer (1 .. Name_Len)); + + -- The name of operators needs to be properly escaped for JSON + + for J in 1 .. Name_Len loop + C := Name_Buffer (J); + if C = '"' and then List_Representation_Info_To_JSON then + Write_Char ('\'); + end if; + Write_Char (C); + end loop; end List_Name; --------------------- |