From: Viljar Indus <in...@adacore.com> Boolean attributes should have the value true or false without any quotes.
gcc/ada/ChangeLog: * diagnostics-json_utils.adb: Add new method Write_Boolean_Attribute. * diagnostics-json_utils.ads: Likewise. * diagnostics-sarif_emitter.adb (Print_Invocations): print the executionSuccesful property value without extra quotes. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/diagnostics-json_utils.adb | 11 +++++++++++ gcc/ada/diagnostics-json_utils.ads | 10 +++++++++- gcc/ada/diagnostics-sarif_emitter.adb | 4 +--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/gcc/ada/diagnostics-json_utils.adb b/gcc/ada/diagnostics-json_utils.adb index 30263b0b3ca..a05a097012c 100644 --- a/gcc/ada/diagnostics-json_utils.adb +++ b/gcc/ada/diagnostics-json_utils.adb @@ -64,6 +64,17 @@ package body Diagnostics.JSON_Utils is end if; end NL_And_Indent; + ----------------------------- + -- Write_Boolean_Attribute -- + ----------------------------- + + procedure Write_Boolean_Attribute (Name : String; Value : Boolean) is + + begin + Write_Str ("""" & Name & """" & ": "); + Write_Str (if Value then "true" else "false"); + end Write_Boolean_Attribute; + ------------------------- -- Write_Int_Attribute -- ------------------------- diff --git a/gcc/ada/diagnostics-json_utils.ads b/gcc/ada/diagnostics-json_utils.ads index 1fc6c0e315d..f496b7acbb8 100644 --- a/gcc/ada/diagnostics-json_utils.ads +++ b/gcc/ada/diagnostics-json_utils.ads @@ -49,6 +49,11 @@ package Diagnostics.JSON_Utils is procedure NL_And_Indent; -- Print a new line + procedure Write_Boolean_Attribute (Name : String; Value : Boolean); + -- Write a JSON attribute with a boolean value. + -- + -- The value is either 'true' or 'false' without any quotes + procedure Write_Int_Attribute (Name : String; Value : Int); procedure Write_JSON_Escaped_String (Str : String); @@ -62,6 +67,9 @@ package Diagnostics.JSON_Utils is -- we choose to use the UTF-8 representation instead. procedure Write_String_Attribute (Name : String; Value : String); - -- Write a JSON attribute with a string value + -- Write a JSON attribute with a string value. + -- + -- The Value is surrounded by double quotes ("") and the special characters + -- within the string are escaped. end Diagnostics.JSON_Utils; diff --git a/gcc/ada/diagnostics-sarif_emitter.adb b/gcc/ada/diagnostics-sarif_emitter.adb index f0be97d1a1e..bdab412befd 100644 --- a/gcc/ada/diagnostics-sarif_emitter.adb +++ b/gcc/ada/diagnostics-sarif_emitter.adb @@ -632,9 +632,7 @@ package body Diagnostics.SARIF_Emitter is -- Print executionSuccessful - Write_String_Attribute - ("executionSuccessful", - (if Compilation_Errors then "false" else "true")); + Write_Boolean_Attribute ("executionSuccessful", Compilation_Errors); End_Block; NL_And_Indent; -- 2.43.0