-- The contract of an ignored Ghost subprogram does not need expansion,
-- because the subprogram and all calls to it will be removed.
- elsif Is_Ignored_Ghost_Entity (Subp_Id) then
+ elsif Is_Ignored_Ghost_Entity_In_Codegen (Subp_Id) then
return;
-- No action needed for helpers and indirect-call wrapper built to
end if;
if Policy_In_Effect (Name_Assert) = Name_Check
- and then not Predicates_Ignored (Etype (Discr))
+ and then not Predicates_Ignored_In_Codegen (Etype (Discr))
then
Prepend_To (Res, Make_Predicate_Check (Typ, Val));
end if;
-- the subtype.
if not No_Exception_Handlers_Set
- and then not Predicates_Ignored (Typ)
+ and then not Predicates_Ignored_In_Codegen (Typ)
then
Append_To (Lst,
Make_Case_Statement_Alternative (Loc,
if Compile_Time_Known_Value (Expr)
and then Has_Predicates (Etype (Expr))
- and then not Predicates_Ignored (Etype (Expr))
+ and then not Predicates_Ignored_In_Codegen (Etype (Expr))
and then not Is_OK_Static_Expression (Expr)
then
Rewrite (N,
-- generated case statements).
if Validity_Check_Default
- and then not Predicates_Ignored (Etype (Expr))
+ and then not Predicates_Ignored_In_Codegen (Etype (Expr))
then
-- Recognize the simple case where Expr is an object reference
-- and the case statement is directly preceded by an
-- predicate, and there is no Others choice, Constraint_Error
-- must be raised (RM 4.5.7 (21/3) and 5.4 (13)).
- if Predicates_Ignored (Etype (Expr)) then
+ if Predicates_Ignored_In_Codegen (Etype (Expr)) then
declare
Except : constant Node_Id :=
Make_Raise_Constraint_Error (Loc,
-- the current subprogram is called.
if Is_Subprogram (Subp)
- and then not Is_Ignored_Ghost_Entity (Subp)
+ and then not Is_Ignored_Ghost_Entity_In_Codegen (Subp)
and then Same_Or_Aliased_Subprograms (Subp, Current_Scope)
then
Check_Subprogram_Variant;
elsif (not Needs_Secondary_Stack (R_Type)
and then not Is_Secondary_Stack_Thunk (Scope_Id))
- or else Is_Ignored_Ghost_Entity (Scope_Id)
+ or else Is_Ignored_Ghost_Entity_In_Codegen (Scope_Id)
then
-- Mutable records with variable-length components are not returned
-- on the sec-stack, so we need to make sure that the back end will
-- Do not inspect an ignored Ghost package body because all
-- code found within will not appear in the final tree.
- if Is_Ignored_Ghost_Entity (Defining_Entity (Decl)) then
+ if Is_Ignored_Ghost_Entity_In_Codegen (Defining_Entity (Decl)) then
null;
elsif Ekind (Corresponding_Spec (Decl)) /= E_Generic_Package then
-- Ignored Ghost types do not need any cleanup actions because
-- they will not appear in the final tree.
- if Is_Ignored_Ghost_Entity (Typ) then
+ if Is_Ignored_Ghost_Entity_In_Codegen (Typ) then
null;
elsif Is_Tagged_Type (Typ)
-- Ignored Ghost objects do not need any cleanup actions
-- because they will not appear in the final tree.
- elsif Is_Ignored_Ghost_Entity (Obj_Id) then
+ elsif Is_Ignored_Ghost_Entity_In_Codegen (Obj_Id) then
null;
-- Conversely, if one of the above cases created a Master_Node,
-- Freeze nodes for ignored Ghost types do not need cleanup
-- actions because they will never appear in the final tree.
- if Is_Ignored_Ghost_Entity (Typ) then
+ if Is_Ignored_Ghost_Entity_In_Codegen (Typ) then
null;
elsif (Is_Access_Object_Type (Typ)
-- Do not inspect an ignored Ghost package because all code
-- found within will not appear in the final tree.
- if Is_Ignored_Ghost_Entity (Pack_Id) then
+ if Is_Ignored_Ghost_Entity_In_Codegen (Pack_Id) then
null;
elsif Ekind (Pack_Id) /= E_Generic_Package then
-- Ignored Ghost objects do not need any cleanup actions because
-- they will not appear in the final tree.
- if Is_Ignored_Ghost_Entity (Obj_Id) then
+ if Is_Ignored_Ghost_Entity_In_Codegen (Obj_Id) then
return;
end if;
-- by a missing activation chain entity; also skip generating it when
-- it is a ghost entity.
- if No (Chain) or else Is_Ignored_Ghost_Entity (Chain) then
+ if No (Chain) or else Is_Ignored_Ghost_Entity_In_Codegen (Chain) then
return;
-- The availability of the activation chain entity does not ensure
-- Skip ignored Ghost subprograms as those will be removed
-- from the executable.
- and then not Is_Ignored_Ghost_Entity (E)
+ and then not Is_Ignored_Ghost_Entity_In_Codegen (E)
then
pragma Assert
(UI_To_Int (DT_Position (Prim)) <= Nb_Prim);
-- Ignored Ghost types do not need any cleanup actions because
-- they will not appear in the final tree.
- if Is_Ignored_Ghost_Entity (Typ) then
+ if Is_Ignored_Ghost_Entity_In_Codegen (Typ) then
null;
elsif Is_Tagged_Type (Typ)
-- Ignored Ghost objects do not need any cleanup actions because
-- they will not appear in the final tree.
- elsif Is_Ignored_Ghost_Entity (Obj_Id) then
+ elsif Is_Ignored_Ghost_Entity_In_Codegen (Obj_Id) then
null;
-- Conversely, if one of the above cases created a Master_Node,
-- Freeze nodes for ignored Ghost types do not need cleanup
-- actions because they will never appear in the final tree.
- if Is_Ignored_Ghost_Entity (Typ) then
+ if Is_Ignored_Ghost_Entity_In_Codegen (Typ) then
null;
elsif ((Is_Access_Object_Type (Typ)
-- Do not inspect an ignored Ghost package because all code found
-- within will not appear in the final tree.
- if Is_Ignored_Ghost_Entity (Pack_Id) then
+ if Is_Ignored_Ghost_Entity_In_Codegen (Pack_Id) then
null;
elsif Ekind (Pack_Id) /= E_Generic_Package
-- Do not inspect an ignored Ghost package body because all code
-- found within will not appear in the final tree.
- if Is_Ignored_Ghost_Entity (Defining_Entity (Decl)) then
+ if Is_Ignored_Ghost_Entity_In_Codegen (Defining_Entity (Decl)) then
null;
elsif Ekind (Corresponding_Spec (Decl)) /= E_Generic_Package
-- Declaring too big an array in disabled ghost code is OK
- if Is_Array_Type (Typ) and then not Is_Ignored_Ghost_Entity (E) then
+ if Is_Array_Type (Typ)
+ and then not Is_Ignored_Ghost_Entity_In_Codegen (E)
+ then
Check_Large_Modular_Array (Typ);
end if;
end Freeze_Object_Declaration;
return
Nkind (N) = N_Compilation_Unit
- and then Is_Ignored_Ghost_Entity
+ and then Is_Ignored_Ghost_Entity_In_Codegen
(Defining_Entity (Ultimate_Original_Node (Unit (N))));
end Is_Ignored_Ghost_Unit;
-- Inherit the "ghostness" of the generic unit, but the current Ghost
-- policy is the relevant one for the instantiation.
- elsif Is_Checked_Ghost_Entity (Gen_Id)
- or else Is_Ignored_Ghost_Entity (Gen_Id)
- then
+ elsif Is_Ghost_Entity (Gen_Id) then
Policy := Ghost_Policy_In_Effect (Gen_Id);
if Policy = No_Name then
if Present (Nam)
and then Is_Entity_Name (Nam)
and then Present (Entity (Nam))
- and then Is_Ignored_Ghost_Entity (Entity (Nam))
+ and then Is_Ignored_Ghost_Entity_In_Codegen (Entity (Nam))
then
Set_Is_Ignored_Ghost_Node (N);
Record_Ignored_Ghost_Node (N);
E : constant Subprogram_Kind_Id := Inlined.Table (Index).Name;
begin
- if Is_Called (E) and then not Is_Ignored_Ghost_Entity (E) then
+ if Is_Called (E)
+ and then not Is_Ignored_Ghost_Entity_In_Codegen (E)
+ then
Add_Inlined_Subprogram (E);
end if;
end;
if Present (Ent)
and then Nkind (Declaration_Node (Ent)) not in N_Renaming_Declaration
- and then not Is_Ignored_Ghost_Entity (Ent)
+ and then not Sem_Util.Is_Ignored_Ghost_Entity_In_Codegen (Ent)
then
-- If entity is a subprogram and we are listing mechanisms,
-- then we need to list mechanisms for this entity. We skip this
-- No checked needed for ignored ghost units
- or else Is_Ignored_Ghost_Entity (Spec_Id)
+ or else Is_Ignored_Ghost_Entity_In_Codegen (Spec_Id)
)
then
-- This is a case where we only need the entity for checking to
if Class_Present (Aspect)
and then A_Id in Aspect_Pre | Aspect_Post
and then Is_Subprogram (E)
- and then not Is_Ignored_Ghost_Entity (E)
+ and then not Is_Ignored_Ghost_Entity_In_Codegen (E)
then
if A_Id = Aspect_Pre then
if Is_Ignored_In_Codegen (Aspect) then
-- private type from a library unit, otherwise premature freezing of
-- the private type will occur.
- elsif not Analyzed (Next_Decl) and then Is_Body (Next_Decl)
+ elsif not Analyzed (Next_Decl)
+ and then Is_Body (Next_Decl)
and then ((Nkind (Next_Decl) /= N_Subprogram_Body
- or else not Was_Expression_Function (Next_Decl))
- or else (not Is_Ignored_Ghost_Entity (Current_Scope)
- and then not Contains_Lib_Incomplete_Type
- (Current_Scope)))
+ or else not Was_Expression_Function (Next_Decl))
+ or else (not Is_Ignored_Ghost_Entity_In_Codegen
+ (Current_Scope)
+ and then not Contains_Lib_Incomplete_Type
+ (Current_Scope)))
then
-- When a controlled type is frozen, the expander generates stream
-- and controlled-type support routines. If the freeze is caused
-- Ghost subprogram.
if Inside_A_Generic then
- Set_Has_Completion (Def_Id, not Is_Ignored_Ghost_Entity (Def_Id));
+ Set_Has_Completion
+ (Def_Id, not Is_Ignored_Ghost_Entity_In_Codegen (Def_Id));
Push_Scope (Def_Id);
Install_Formals (Def_Id);
Preanalyze_And_Resolve_Spec_Expression (Expr, Typ);
and then Serious_Errors_Detected = 0
and then (Expander_Active
or else Operating_Mode = Check_Semantics
- or else Is_Ignored_Ghost_Entity (Spec_Id))
+ or else Is_Ignored_Ghost_Entity_In_Codegen (Spec_Id))
then
-- The body generated for an expression function that is not a
-- completion is a freeze point neither for the profile nor for
(Id : Entity_Id) return Extended_Ghost_Mode
is
begin
- return To_Ghost_Mode (Is_Ignored_Ghost_Entity (Id));
+ return To_Ghost_Mode (Is_Ignored_Ghost_Entity_In_Codegen (Id));
end Ghost_Mode_Of_Entity;
------------------------
-- checkable, the case of calling an immediately containing
-- subprogram is easy to catch.
- if not Is_Ignored_Ghost_Entity (Nam) then
+ if not Is_Ignored_Ghost_Entity_In_Codegen (Nam) then
Check_Restriction (No_Recursion, N);
end if;
and then Ekind (Nam) in E_Function | E_Subprogram_Type
and then Requires_Transient_Scope (Etype (Nam))
and then not Is_Intrinsic_Subprogram (Nam)
- and then not Is_Ignored_Ghost_Entity (Nam)
+ and then not Is_Ignored_Ghost_Entity_In_Codegen (Nam)
and then not Is_Build_In_Place_Function (Nam)
and then not Is_Inlinable_Expression_Function (Nam)
and then not (Is_Inlined (Nam)
begin
return
Present (Predicate_Function (Typ))
- and then (GNATprove_Mode
- or else (not Predicates_Ignored (Typ)
- and then not Predicate_Checks_Suppressed (Empty)));
+ and then not Predicates_Ignored_In_Codegen (Typ)
+ and then not Predicate_Checks_Suppressed (Empty);
end Predicate_Enabled;
----------------------------------
return Empty;
end Predicate_Failure_Expression;
+ -----------------------------------
+ -- Predicates_Ignored_In_Codegen --
+ -----------------------------------
+
+ function Predicates_Ignored_In_Codegen (N : Node_Id) return Boolean is
+ begin
+ return
+ Predicates_Ignored (N)
+ and then not CodePeer_Mode
+ and then not GNATprove_Mode;
+ end Predicates_Ignored_In_Codegen;
+
----------------------------------
-- Predicate_Tests_On_Arguments --
----------------------------------
-- Nothing to do for an ignored Ghost entity because the entity will be
-- eliminated from the tree.
- elsif Is_Ignored_Ghost_Entity (T) then
+ elsif Is_Ignored_Ghost_Entity_In_Codegen (T) then
return;
-- Nothing to do if entity comes from a predefined file. Library files
function Is_Ignored_Ghost_Entity_In_Codegen (N : Node_Id) return Boolean;
-- True if N Is_Ignored_Ghost_Entity and GNATProve_mode and Codepeer_Mode
-- are not active.
+ --
+ -- See Is_Ignored_In_Codegen for instructions on when this function should
+ -- be used.
function Is_Ignored_Ghost_Pragma_In_Codegen (N : Node_Id) return Boolean;
-- True if N Is_Ignored_Ghost_Pragma and GNATProve_mode and Codepeer_Mode
-- are not active.
+ --
+ -- See Is_Ignored_In_Codegen for instructions on when this function should
+ -- be used.
function Is_Ignored_In_Codegen (N : Node_Id) return Boolean;
-- True if N Is_Ignored and GNATProve_mode and Codepeer_Mode are not
-- active.
+ --
+ -- Tools like GNATProve and Codepeer that use the frontend to get the
+ -- representation of the source code along with all of the code generated
+ -- for assertions. This includes even the ones that are ignored. The
+ -- frontend normally avoids the generation of such assertions and ghost
+ -- code if marked as ignored. However we should still enable the generation
+ -- when working in one of those tool modes. In most cases this means that
+ -- we should ignore the fact the given node is marked as ignored and behave
+ -- as if it was not. This involves checking attributes such as Is_Ignored
+ -- along with these tool modes.
+ --
+ -- This function (and similar _In_Codegen functions) behaves as a wrapper
+ -- for such conditions. We should use this functions in scenarios where we
+ -- would normally stop the code generation for such ignored nodes. For
+ -- example in the expander where we normally transform non-ignored nodes.
+ -- Not doing so may lead to a partially expanded tree for those tools.
+ --
+ -- On the other hand we should use these attributes directly when
+ -- propagating the Is_Ignored or other similar property related values
+ -- between nodes. Additionally we should be using the original attributes
+ -- when checking for the compatibility of the checked/ignored properties
+ -- between nodes.
function Is_EVF_Expression (N : Node_Id) return Boolean;
-- Determine whether node N denotes a reference to a formal parameter of
-- returns the result of recursing on the ancestor subtype.
-- Otherwise, returns Empty.
+ function Predicates_Ignored_In_Codegen (N : Node_Id) return Boolean;
+ -- True if N Predicates_Ignored is set and GNATProve_mode and Codepeer_Mode
+ -- are not active.
+ --
+ -- See Is_Ignored_In_Codegen for instructions on when this function should
+ -- be used.
+
function Predicate_Function_Needs_Membership_Parameter (Typ : Entity_Id)
return Boolean is
(Present (Predicate_Failure_Expression (Typ, Inherited_OK => True)));