aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorViljar Indus <indus@adacore.com>2024-11-26 14:10:46 +0200
committerMarc Poulhiès <dkm@gcc.gnu.org>2025-01-06 10:14:47 +0100
commitd47596b4bb71179edbd1811aa0ddffda903c08c3 (patch)
treeb0fbcd8ff5a012cca283cd63dff20a9a3b60ca0e /gcc
parentb4c9ba204b6c9fd59ef25e810431a3fc2027e4ef (diff)
downloadgcc-d47596b4bb71179edbd1811aa0ddffda903c08c3.zip
gcc-d47596b4bb71179edbd1811aa0ddffda903c08c3.tar.gz
gcc-d47596b4bb71179edbd1811aa0ddffda903c08c3.tar.bz2
ada: Fix printing boolean attributes in the SARIF report
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/diagnostics-json_utils.adb11
-rw-r--r--gcc/ada/diagnostics-json_utils.ads10
-rw-r--r--gcc/ada/diagnostics-sarif_emitter.adb4
3 files changed, 21 insertions, 4 deletions
diff --git a/gcc/ada/diagnostics-json_utils.adb b/gcc/ada/diagnostics-json_utils.adb
index 30263b0..a05a097 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 1fc6c0e..f496b7a 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 f0be97d..bdab412 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;