From 0f3f15bfa24694c2a7d300bb79cea80811dd250f Mon Sep 17 00:00:00 2001 From: Hugo Guerrier Date: Fri, 13 Sep 2024 10:46:20 +0200 Subject: [PATCH] Remove the 'Wide_Wide_Value' usage from 'Get_Exemption_Kind' Removing because exception handling in that case is not efficient. --- lkql_checker/src/gnatcheck-diagnoses.adb | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/lkql_checker/src/gnatcheck-diagnoses.adb b/lkql_checker/src/gnatcheck-diagnoses.adb index 37adb4cd3..a59683f79 100644 --- a/lkql_checker/src/gnatcheck-diagnoses.adb +++ b/lkql_checker/src/gnatcheck-diagnoses.adb @@ -1089,24 +1089,18 @@ package body Gnatcheck.Diagnoses is function Get_Exemption_Kind (Image : Wide_Wide_String) return Exemption_Kinds is - Result : Exemption_Kinds; + Norm_Image : constant Wide_Wide_String := To_Lower + (if Image (Image'First) = '"' + then Image (Image'First + 1 .. Image'Last - 1) + else Image); begin - if Image (Image'First) = '"' then - - -- Old format of Annotate pragma. We have to cut out quotation marks - - Result := - Exemption_Kinds'Wide_Wide_Value - (Image (Image'First + 1 .. Image'Last - 1)); + if Norm_Image = "exempt_on" then + return Exempt_On; + elsif Norm_Image = "exempt_off" then + return Exempt_Off; else - Result := Exemption_Kinds'Wide_Wide_Value (Image); - end if; - - return Result; - - exception - when Constraint_Error => return Not_An_Exemption; + end if; end Get_Exemption_Kind; -----------------------------