Skip to content

Commit 55fa020

Browse files
committed
Merge branch 'topic/rule_violation_tags' into 'master'
Add a "rule violation" tag to all rule violation messages See merge request eng/libadalang/langkit-query-language!388
2 parents 9644846 + 5dee04e commit 55fa020

File tree

57 files changed

+318
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+318
-307
lines changed

lkql_checker/src/gnatcheck-diagnoses.adb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ package body Gnatcheck.Diagnoses is
174174
-- boolean parameter is used to define the needed indentation level
175175

176176
function Strip_Tag (Diag : String) return String;
177-
-- Strip trailing " [-gnatxxx]", if any
177+
-- Strip trailing GNAT tag following the format " [-gnat<x>]", if any
178178

179179
----------------------------------------------------------------------
180180
-- Data structures and local routines for rule exemption mechanism --
@@ -1682,11 +1682,11 @@ package body Gnatcheck.Diagnoses is
16821682

16831683
function Preprocess_Diag (Diag : String) return String;
16841684
-- Add GPS_Prefix if Progress_Indicator_Mode is True, and remove any
1685-
-- training [-gnatwxxx].
1685+
-- trailing GNAT tag following the "[-gnat<x>]" format.
16861686

16871687
procedure Counted_Print_Diagnosis
16881688
(Position : Error_Messages_Storage.Cursor);
1689-
-- Print Diagnosis until reaching Max_Diagnoses
1689+
-- Print diagnosis until reaching Max_Diagnoses
16901690

16911691
---------------------
16921692
-- Preprocess_Diag --
@@ -3029,8 +3029,19 @@ package body Gnatcheck.Diagnoses is
30293029
(Ada.Strings.Fixed.Trim (Line_Number'Image (Sloc.Line), Left)
30303030
& ':' & Column_Str);
30313031
end Image;
3032+
3033+
Tag_String : constant String :=
3034+
(case Self.Diagnosis_Kind is
3035+
when Rule_Violation =>
3036+
(if Self.Justification /= Null_Unbounded_String
3037+
then "rule violation (exempted): "
3038+
else "rule violation: "),
3039+
when Exemption_Warning => "warning: ",
3040+
when others => "");
30323041
begin
3033-
return To_String (Self.File) & ":" & Image (Self.Sloc) & ": "
3042+
return To_String (Self.File) & ":"
3043+
& Image (Self.Sloc) & ": "
3044+
& Tag_String
30343045
& To_String (Self.Text);
30353046
end Image;
30363047

lkql_checker/src/gnatcheck-output.ads

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ package Gnatcheck.Output is
4242
-- Reports that a required file could not be found
4343

4444
procedure Error (Message : String);
45-
-- Sends into Stderr the error message in the form 'Tool_Name: Message'
45+
-- Sends ``Message`` into stderr, prefixed by "tool_name: error: ".
4646

4747
procedure Warning (Message : String);
48-
-- Same as ``Error``
48+
-- Sends ``Message`` into stderr, prefixed by "tool_name: warning: ".
4949

5050
procedure Info (Message : String);
51-
-- Sends Message into Stderr (with no tool name prefix).
51+
-- Sends ``Message`` into stderr, prefixed by "tool_name: info: ".
5252

5353
procedure Info_In_Tty (Message : String);
5454
-- Same as ``Info`` but send the message only if Stderr is a TTY. Also,

testsuite/tests/gnatcheck/absolute_output_files/test.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
no exempted violations detected
2-
main.adb:3:05: goto statement
2+
main.adb:3:05: rule violation: goto statement
33
no rule exemption problems detected
44
no language violations detected
55
no internal error detected
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
test.ads:2:12: declaration of local package
2-
test.ads:2:12: declaration of local package
1+
test.ads:2:12: rule violation: declaration of local package
2+
test.ads:2:12: rule violation: declaration of local package
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
main.adb:1:19: use clause for package
2-
main.adb:1:23: use clause
3-
main.adb:1:37: end of line comment
4-
main.adb:3:01: possible occurrence of KP U727-033 if float operation performed before first context switch on leon targets
5-
main.adb:3:11: declaration of library level subprogram
6-
main.adb:3:37: end of line comment
7-
main.adb:6:05: goto statement
8-
main.adb:6:37: end of line comment
1+
main.adb:1:19: rule violation: use clause for package
2+
main.adb:1:23: rule violation: use clause
3+
main.adb:1:37: rule violation: end of line comment
4+
main.adb:3:01: rule violation: possible occurrence of KP U727-033 if float operation performed before first context switch on leon targets
5+
main.adb:3:11: rule violation: declaration of library level subprogram
6+
main.adb:3:37: rule violation: end of line comment
7+
main.adb:6:05: rule violation: goto statement
8+
main.adb:6:37: rule violation: end of line comment

testsuite/tests/gnatcheck/check_package/rule_file_attr/test.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Without additional rule file
22
============================
33

4-
main.adb:3:04: goto statement
4+
main.adb:3:04: rule violation: goto statement
55

66
With additional rule file
77
=========================
88

99
gnatcheck: error: only one LKQL configuration file is allowed
10-
main.adb:3:04: goto statement
10+
main.adb:3:04: rule violation: goto statement
1111
>>>program returned status code 6
1212

1313
With invalid attribute value

testsuite/tests/gnatcheck/check_package/rules_attr/test.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Without additional rules
22
========================
33

4-
main.adb:4:04: goto statement
4+
main.adb:4:04: rule violation: goto statement
55

66
With additional rules
77
=====================
88

9-
main.adb:3:04: redundant null statement
10-
main.adb:4:04: goto statement
9+
main.adb:3:04: rule violation: redundant null statement
10+
main.adb:4:04: rule violation: goto statement
1111

1212
With invalid attribute value
1313
============================

testsuite/tests/gnatcheck/check_package/switches_attr/test.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Without additional switches
22
===========================
33

4-
main.adb:3:04: goto statement [goto_statements]
4+
main.adb:3:04: rule violation: goto statement [goto_statements]
55

66
With a disallowed switch
77
========================
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
main.adb:3:04: goto statement
2-
main.adb:4:04: redundant null statement
1+
main.adb:3:04: rule violation: goto statement
2+
main.adb:4:04: rule violation: redundant null statement
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
main.adb:1:01: [<PragmaNode gnat.adc:1:1-1:24>, <PragmaNode gnat.adc:2:1-2:75>, <PragmaNode gnat.adc:3:1-3:73>, <PragmaNode gnat.adc:4:1-4:25>, <PragmaNode gnat.adc:5:1-5:47>]
1+
main.adb:1:01: rule violation: [<PragmaNode gnat.adc:1:1-1:24>, <PragmaNode gnat.adc:2:1-2:75>, <PragmaNode gnat.adc:3:1-3:73>, <PragmaNode gnat.adc:4:1-4:25>, <PragmaNode gnat.adc:5:1-5:47>]
22

3-
main.adb:1:01: []
3+
main.adb:1:01: rule violation: []
44

5-
main.adb:1:01: [<PragmaNode gnat.adc:1:1-1:24>, <PragmaNode gnat.adc:2:1-2:75>, <PragmaNode gnat.adc:3:1-3:73>, <PragmaNode gnat.adc:4:1-4:25>, <PragmaNode gnat.adc:5:1-5:47>]
5+
main.adb:1:01: rule violation: [<PragmaNode gnat.adc:1:1-1:24>, <PragmaNode gnat.adc:2:1-2:75>, <PragmaNode gnat.adc:3:1-3:73>, <PragmaNode gnat.adc:4:1-4:25>, <PragmaNode gnat.adc:5:1-5:47>]
66

7-
main.adb:1:01: []
7+
main.adb:1:01: rule violation: []

0 commit comments

Comments
 (0)