Skip to content

Commit 24b31a3

Browse files
committed
Remove useless type checks when accessing values of the 'Check' GPR package attributes
Such type checks are already preformed by LibGPR2.
1 parent 4a722ef commit 24b31a3

File tree

1 file changed

+2
-30
lines changed

1 file changed

+2
-30
lines changed

lkql_checker/src/gnatcheck-projects.adb

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ package body Gnatcheck.Projects is
185185

186186
procedure Extract_Tool_Options (My_Project : in out Arg_Project_Type) is
187187
use GPR2;
188-
use GPR2.Project.Registry.Attribute;
189188

190189
Proj : constant GPR2.Project.View.Object :=
191190
My_Project.Tree.Namespace_Root_Projects.First_Element;
@@ -205,7 +204,8 @@ package body Gnatcheck.Projects is
205204
-- information about attribute indexes.
206205

207206
function Load_Single_Attribute
208-
(Attr_Id : GPR2.Q_Attribute_Id) return String;
207+
(Attr_Id : GPR2.Q_Attribute_Id) return String
208+
is (Proj.Attribute (Attr_Id).Value.Text);
209209
-- Load the attribute designated by ``Attr_Id`` in the project ``Proj``
210210
-- as a single value, returning is as a ``String``.
211211

@@ -219,42 +219,14 @@ package body Gnatcheck.Projects is
219219
else Proj.Attribute (Attr_Id));
220220
Res : GNAT.OS_Lib.Argument_List_Access;
221221
begin
222-
if Attr.Kind /= List then
223-
Error
224-
(String (Proj.Path_Name.Simple_Name)
225-
& ": "
226-
& Image (Attr_Id)
227-
& " value must be a list");
228-
raise Parameter_Error;
229-
end if;
230-
231222
Res :=
232223
new String_List (Attr.Values.First_Index .. Attr.Values.Last_Index);
233224
for J in Attr.Values.First_Index .. Attr.Values.Last_Index loop
234225
Res (J) := new String'(Attr.Values.Element (J).Text);
235226
end loop;
236-
237227
return Res;
238228
end Load_List_Attribute;
239229

240-
function Load_Single_Attribute
241-
(Attr_Id : GPR2.Q_Attribute_Id) return String
242-
is
243-
Attr : constant GPR2.Project.Attribute.Object :=
244-
Proj.Attribute (Attr_Id);
245-
begin
246-
if Attr.Kind /= Single then
247-
Error
248-
(String (Proj.Path_Name.Simple_Name)
249-
& ": "
250-
& Image (Attr_Id)
251-
& " value must be a single value");
252-
raise Parameter_Error;
253-
end if;
254-
255-
return Attr.Value.Text;
256-
end Load_Single_Attribute;
257-
258230
begin
259231
-- Process the rule list
260232
if Proj.Has_Attribute (Rules_Attr) then

0 commit comments

Comments
 (0)