Names of Ghost entities are now prefixed by "___ghost_" (three leading underscores) to make it possible to independently check the presence of ghost code in an object file or an executable.
Tested on x86_64-pc-linux-gnu, committed on trunk 2017-04-27 Yannick Moy <m...@adacore.com> * exp_dbug.adb, exp_dbug.ads (Get_External_Name): Prefix ghost entities with special prefix.
Index: exp_dbug.adb =================================================================== --- exp_dbug.adb (revision 247293) +++ exp_dbug.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1996-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 1996-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -892,6 +892,27 @@ Add_Str_To_Name_Buffer (Suffix); end if; + -- Add a special prefix to distinguish Ghost entities. In Ignored Ghost + -- mode, these entities should not leak in the "living" space and they + -- should be removed by the compiler in a post-processing pass. Thus, + -- the prefix allows anyone to check that the final executable indeed + -- does not contain such entities, in such a case. Do not insert this + -- prefix for compilation units, whose name is used as a basis for the + -- name of the generated elaboration procedure and (when appropriate) + -- the executable produced. Only insert this prefix once, for Ghost + -- entities declared inside other Ghost entities. Three leading + -- underscores are used so that "___ghost_" is a unique substring of + -- names produced for Ghost entities, while "__ghost_" can appear in + -- names of entities inside a child/local package called "Ghost". + + if Is_Ghost_Entity (E) + and then not Is_Compilation_Unit (E) + and then (Name_Len < 9 + or else Name_Buffer (1 .. 9) /= "___ghost_") + then + Insert_Str_In_Name_Buffer ("___ghost_", 1); + end if; + Name_Buffer (Name_Len + 1) := ASCII.NUL; end Get_External_Name; Index: exp_dbug.ads =================================================================== --- exp_dbug.ads (revision 247293) +++ exp_dbug.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1996-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 1996-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -76,6 +76,12 @@ -- qualification for such entities. In particular this means that direct -- local variables of a procedure are not qualified. + -- For Ghost entities, the encoding adds a prefix "___ghost_" to aid the + -- detection of leaks of Ignored Ghost entities in the "living" space. + -- Ignored Ghost entities and any code associated with them should be + -- removed by the compiler in a post-processing pass. As a result, + -- object files should not contain any occurrences of this prefix. + -- As an example of the local name convention, consider a procedure V.W -- with a local variable X, and a nested block Y containing an entity Z. -- The fully qualified names of the entities X and Z are: