diff --git a/gcc/ada/diagnostics-json_utils.adb b/gcc/ada/diagnostics-json_utils.adb index 30263b0b3ca6ba8bf9b332c0cf972a1654d7f6c1..a05a097012c4ed6cd9d1338cefcba9a7d78f8f1b 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 1fc6c0e315d6e5caeeff5ab3e3b98da8f73dc685..f496b7acbb81047f1483f0eed1be94ab3d54ef91 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 f0be97d1a1ea7c0953ed775dc93b6bc804896306..bdab412befd827cabac606e676fbd2cefbe48429 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;