with empty strings. This is useful to avoid exposing entity names at binary
level but has a negative impact on the debuggability of tagged types.
+Alternatively, when pragmas ``Discard_Names`` and ``Restrictions (No_Streams)``
+simultanously apply to a tagged type, its Expanded_Name and External_Tag are
+also initialized with empty strings. In particular, both these pragmas can be
+applied as configuration pragmas to avoid exposing entity names at binary
+level for the entire parition.
+
Pragma Normalize_Scalars
========================
-- streams.
Discard_Names : constant Boolean :=
- Present (No_Tagged_Streams_Pragma (Typ))
- and then
+ (Present (No_Tagged_Streams_Pragma (Typ))
+ or else Restriction_Active (No_Streams))
+ and then
(Global_Discard_Names or else Einfo.Entities.Discard_Names (Typ));
-- The following name entries are used by Make_DT to generate a number
with Sinfo.Utils; use Sinfo.Utils;
with Snames; use Snames;
with Stand;
+with Stringt; use Stringt;
with Tbuild; use Tbuild;
with Ttypes; use Ttypes;
with Uintp; use Uintp;
Make_Raise_Program_Error (Loc,
Reason => PE_Explicit_Raise));
else
- Append_To (Stms,
- Make_Procedure_Call_Statement (Loc,
- Name => New_Occurrence_Of (RTE (RE_Put_Image_Unknown), Loc),
- Parameter_Associations => New_List
- (Make_Identifier (Loc, Name_S),
- Make_String_Literal (Loc,
- Fully_Qualified_Name_String
- (Btyp, Append_NUL => False)))));
+ declare
+ Type_Name : String_Id;
+ begin
+ -- If aspect Discard_Names is enabled the intention is to
+ -- prevent type names from leaking into object file. Instead,
+ -- we emit string that is different from the ones from the
+ -- default implementations of the Put_Image attribute.
+
+ if Global_Discard_Names or else Discard_Names (Typ) then
+ Start_String;
+ Store_String_Chars ("(DISCARDED TYPE NAME)");
+ Type_Name := End_String;
+ else
+ Type_Name :=
+ Fully_Qualified_Name_String (Btyp, Append_NUL => False);
+ end if;
+
+ Append_To (Stms,
+ Make_Procedure_Call_Statement (Loc,
+ Name => New_Occurrence_Of (RTE (RE_Put_Image_Unknown), Loc),
+ Parameter_Associations => New_List
+ (Make_Identifier (Loc, Name_S),
+ Make_String_Literal (Loc,
+ Type_Name))));
+ end;
end if;
elsif Is_Null_Record_Type (Btyp, Ignore_Privacy => True) then
with empty strings. This is useful to avoid exposing entity names at binary
level but has a negative impact on the debuggability of tagged types.
+Alternatively, when pragmas @code{Discard_Names} and @code{Restrictions (No_Streams)}
+simultanously apply to a tagged type, its Expanded_Name and External_Tag are
+also initialized with empty strings. In particular, both these pragmas can be
+applied as configuration pragmas to avoid exposing entity names at binary
+level for the entire parition.
+
@node Pragma Normalize_Scalars,Pragma Obsolescent,Pragma No_Tagged_Streams,Implementation Defined Pragmas
@anchor{gnat_rm/implementation_defined_pragmas pragma-normalize-scalars}@anchor{b0}
@section Pragma Normalize_Scalars