Commit fb95bfcc by Eric Botcazou Committed by Pierre-Marie de Rodat

[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
parent 5da54433
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
......
......@@ -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;
---------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment