Skip to content

Commit ecee2e2

Browse files
committed
lkql_checker: make gnatcheck and gnatkp separate objects
1 parent 76c2e0e commit ecee2e2

14 files changed

+87
-17
lines changed

lkql_checker/lkql_checker.gpr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ project LKQL_Checker is
1010
for Source_Dirs use ("src");
1111
for Object_Dir use "obj/" & Build_Mode;
1212
for Exec_Dir use "bin";
13-
for Main use ("main.adb");
13+
for Main use ("gnatcheck.adb", "gnatkp.adb");
1414

1515
package Binder is
1616
case Build_Mode is
@@ -22,7 +22,6 @@ project LKQL_Checker is
2222
end Binder;
2323

2424
package Builder is
25-
for Executable ("main.adb") use "gnatcheck";
2625
for Switches ("Ada") use ("-j0");
2726
end Builder;
2827

lkql_checker/src/gnatcheck.adb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--
2+
-- Copyright (C) 2005-2025, AdaCore
3+
-- SPDX-License-Identifier: GPL-3.0-or-later
4+
--
5+
6+
with Lkql_Checker; use Lkql_Checker;
7+
8+
with Main;
9+
10+
procedure Gnatcheck is
11+
begin
12+
Main (Gnatcheck_Mode);
13+
end Gnatcheck;

lkql_checker/src/gnatcheck.ads

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--
2+
-- Copyright (C) 2005-2025, AdaCore
3+
-- SPDX-License-Identifier: GPL-3.0-or-later
4+
--
5+
6+
procedure Gnatcheck;

lkql_checker/src/gnatkp.adb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--
2+
-- Copyright (C) 2005-2025, AdaCore
3+
-- SPDX-License-Identifier: GPL-3.0-or-later
4+
--
5+
6+
with Lkql_Checker; use Lkql_Checker;
7+
8+
with Main;
9+
10+
procedure Gnatkp is
11+
begin
12+
Main (Gnatkp_Mode);
13+
end Gnatkp;

lkql_checker/src/gnatkp.ads

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--
2+
-- Copyright (C) 2005-2025, AdaCore
3+
-- SPDX-License-Identifier: GPL-3.0-or-later
4+
--
5+
6+
procedure Gnatkp;

lkql_checker/src/lkql_checker-diagnoses.adb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,7 @@ package body Lkql_Checker.Diagnoses is
16951695

16961696
procedure Print_Out_Diagnoses is
16971697
Max_Diagnoses : constant Natural :=
1698-
(if Gnatkp_Mode then 0 else Arg.Max_Diagnoses.Get);
1698+
(if Options.Mode = Gnatkp_Mode then 0 else Arg.Max_Diagnoses.Get);
16991699
Diagnoses_Reported : Natural := 0;
17001700
Limit_Exceeded : Boolean := False;
17011701

@@ -1923,7 +1923,7 @@ package body Lkql_Checker.Diagnoses is
19231923
Pragma_Name : constant Text_Type := To_Lower (El.F_Id.Text);
19241924
Pragma_Args : constant LAL.Analysis.Base_Assoc_List := El.F_Args;
19251925
Tool_Name : constant Text_Type :=
1926-
(if Gnatkp_Mode then "gnatkp" else "gnatcheck");
1926+
(if Options.Mode = Gnatkp_Mode then "gnatkp" else "gnatcheck");
19271927
begin
19281928
return
19291929
Pragma_Name in "annotate" | "gnat_annotate"
@@ -2270,7 +2270,7 @@ package body Lkql_Checker.Diagnoses is
22702270
return;
22712271
end if;
22722272

2273-
if Gnatkp_Mode then
2273+
if Options.Mode = Gnatkp_Mode then
22742274
Match (Match_Kp_Exempt_Comment, Text, Matches);
22752275
else
22762276
Match (Match_Rule_Exempt_Comment, Text, Matches);

lkql_checker/src/lkql_checker-options.ads

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ package Lkql_Checker.Options is
6969
-- tool (includes both wrong parameters and wrong combinations of correct
7070
-- parameters).
7171

72-
Gnatkp_Mode : Boolean := Executable = "gnatkp";
73-
-- Whether we are running in KP detection mode
74-
-- Set either when the executable is called gnatkp or with the debug switch
75-
-- '-dkp'
72+
Mode : Lkql_Checker_Mode := Gnatcheck_Mode;
73+
-- Set the mode of the driver, either GNATcheck or GNATkp modes.
7674

7775
Legacy : Boolean := False;
7876
-- If True, run in legacy mode, with no support for additional rule files.
@@ -679,7 +677,7 @@ package Lkql_Checker.Options is
679677
function XML_Report_File_Path return String;
680678

681679
function Ignore_Project_Switches return Boolean
682-
is (Ignore_Project_Switches_Opt.Get or Gnatkp_Mode);
680+
is (Ignore_Project_Switches_Opt.Get or Mode = Gnatkp_Mode);
683681

684682
function Source_Files_Specified return Boolean
685683
is (Source_Files.Get /= Null_Unbounded_String);

lkql_checker/src/lkql_checker-output.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ package body Lkql_Checker.Output is
432432
begin
433433
pragma Style_Checks ("M200"); -- Allow long lines
434434

435-
if Gnatkp_Mode then
435+
if Options.Mode = Gnatkp_Mode then
436436
Put_Line ("gnatkp: the GNAT known problem detector");
437437
Put_Line
438438
("usage: gnatkp -Pproject [options] [-rules [-from=file] {+Rkp_id[:param]}]");

lkql_checker/src/lkql_checker-projects.adb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,9 @@ package body Lkql_Checker.Projects is
11691169
-- If GNATcheck is in KP mode and there is a command line specified KP
11701170
-- version, we have to iterate over all implemented rules to enable
11711171
-- those which match the version.
1172-
if Gnatkp_Mode and then Arg.KP_Version.Get /= Null_Unbounded_String then
1172+
if Options.Mode = Gnatkp_Mode
1173+
and then Arg.KP_Version.Get /= Null_Unbounded_String
1174+
then
11731175
for Rule_Cursor in All_Rules.Iterate loop
11741176
declare
11751177
Id : constant Rule_Id := Rule_Map.Key (Rule_Cursor);
@@ -1209,7 +1211,8 @@ package body Lkql_Checker.Projects is
12091211
Active_Rule_Present := not All_Rule_Instances.Is_Empty;
12101212

12111213
if not (Active_Rule_Present or else Analyze_Compiler_Output) then
1212-
if Gnatkp_Mode and then Arg.KP_Version.Get /= Null_Unbounded_String
1214+
if Options.Mode = Gnatkp_Mode
1215+
and then Arg.KP_Version.Get /= Null_Unbounded_String
12131216
then
12141217
Error ("no rule for the given kp-version");
12151218
No_Detectors_For_KP_Version := True;

lkql_checker/src/lkql_checker-rules-rule_table.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ package body Lkql_Checker.Rules.Rule_Table is
15561556
Set : Rule_Sets.Set;
15571557

15581558
begin
1559-
if Gnatkp_Mode then
1559+
if Options.Mode = Gnatkp_Mode then
15601560
Print ("gnatkp currently implements the following detectors:");
15611561

15621562
if Arg.KP_Version.Get /= Null_Unbounded_String then

0 commit comments

Comments
 (0)