aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/backend_utils.adb
diff options
context:
space:
mode:
authorViljar Indus <indus@adacore.com>2024-06-18 15:34:32 +0300
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-09-05 10:10:12 +0200
commitd143b9fa817759ddc041365d988dacdadafddc22 (patch)
treef73ab20daa183437f68d74f9c23aefcc035036cc /gcc/ada/backend_utils.adb
parent47a30d6981db282a4a0e74cf02ff60a3eb0c14cf (diff)
downloadgcc-d143b9fa817759ddc041365d988dacdadafddc22.zip
gcc-d143b9fa817759ddc041365d988dacdadafddc22.tar.gz
gcc-d143b9fa817759ddc041365d988dacdadafddc22.tar.bz2
ada: Integrate new diagnostics in the frontend
Integrate diagnostic messages using the new implementation to the codebase. New diagnostic implementation uses GNAT.Lists as a building block. Tampering checks that were initially implemented for those lists are not critical for this implementation and they lead to overly complex code. Add a generic parameter Tampering_Checks to control whether the tempering checks should be applied for the lists. Make tampering checks conditional for GNAT.Lists gcc/ada/ * par-endh.adb: add call to new diagnostic for end loop errors. * sem_ch13.adb: add call to new diagnostic for default iterator error and record representation being too late. * sem_ch4.adb: Add new diagnostic for wrong operands. * sem_ch9.adb: Add new diagnostic for a Lock_Free warning. * libgnat/g-lists.adb (Ensure_Unlocked): Make checks for tampering conditional. * libgnat/g-lists.ads: Add parameter Tampering_Checks to control whether tampering checks should be executed. * backend_utils.adb: Add new gcc switches '-fdiagnostics-format=sarif-file' and '-fdiagnostics-format=sarif-stderr'. * debug.adb: document -gnatd_D switch. * diagnostics-brief_emitter.adb: New package for displaying diagnostic messages in a compact manner. * diagnostics-brief_emitter.ads: Same as above. * diagnostics-constructors.adb: New pacakge for providing simpler constructor methods for new diagnostic objects. * diagnostics-constructors.ads: Same as above. * diagnostics-converter.adb: New package for converting old Error_Msg_Object-s to Diagnostic_Types. * diagnostics-converter.ads: Same as above. * diagnostics-json_utils.adb: Package for utility methods related to emitting JSON. * diagnostics-json_utils.ads: Same as above. * diagnostics-pretty_emitter.adb: New package for displaying diagnostic messages in a more elaborate manner. * diagnostics-pretty_emitter.ads: Same as above. * diagnostics-repository.adb: New package for collecting all created error messages. * diagnostics-repository.ads: Same as above. * diagnostics-sarif_emitter.adb: New pacakge for converting all of the diagnostics into a report in the SARIF format. * diagnostics-sarif_emitter.ads: Same as above. * diagnostics-switch_repository.adb: New package containing the definitions for all of the warninging switches. * diagnostics-switch_repository.ads: Same as above. * diagnostics-utils.adb: Contains various utility methods for the diagnostic pacakges. * diagnostics-utils.ads: Same as above. * diagnostics.adb: Contains the definitions and common functions for all the new diagnostics objects. * diagnostics.ads: Same as above. * errout.adb: Relocate the old implementations for brief and pretty printing the diagnostic messages and the entrypoint to the new implementation if a debug switch is used. * errout.ads: Improve documentation. Make Set_Msg_Text publicly available. * opt.ads: Add the flag SARIF_File which controls whether the diagnostic messages should be printed to a file in the SARIF format. Add the flag SARIF_Output to control whether the diagnostic messages should be printed to std-err in the SARIF format. * gcc-interface/Make-lang.in: Add new pacakages to the object list. * gcc-interface/Makefile.in: Add new pacakages to the object list.
Diffstat (limited to 'gcc/ada/backend_utils.adb')
-rw-r--r--gcc/ada/backend_utils.adb15
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/ada/backend_utils.adb b/gcc/ada/backend_utils.adb
index 3591cd1..f734a06 100644
--- a/gcc/ada/backend_utils.adb
+++ b/gcc/ada/backend_utils.adb
@@ -65,6 +65,21 @@ package body Backend_Utils is
elsif Switch_Chars (First .. Last) = "fdiagnostics-format=json" then
Opt.JSON_Output := True;
+ -- Back end switch -fdiagnostics-format=sarif-file tells the frontend
+ -- to output its error and warning messages in the sarif format. The
+ -- messages from gnat are written to a file <source_file>.gnat.sarif.
+
+ elsif Switch_Chars (First .. Last) = "fdiagnostics-format=sarif-file"
+ then
+ Opt.SARIF_File := True;
+
+ -- Back end switch -fdiagnostics-format=sarif-stderr tells the frontend
+ -- to output its error and warning messages in the sarif format.
+
+ elsif Switch_Chars (First .. Last) = "fdiagnostics-format=sarif-stderr"
+ then
+ Opt.SARIF_Output := True;
+
-- Back-end switch -fno-inline also sets the front end flags to entirely
-- inhibit all inlining. So we store it and set the appropriate
-- flags.