Identify destructor/constructor
Mark Mitchell
mark@codesourcery.com
Wed Aug 11 21:09:00 GMT 2004
James E Wilson wrote:
> Revital Eres wrote:
>
>> How can I identify that a function is a destructor/constructor
>> like __base_dtor or __comp_dtor?
>
>
> Just grepping in the gcc/cp directory, I find DECL_CONSTRUCTOR_P and
> DECL_DESTRUCTOR_P defined in cp-tree.h. However, these will only work
> in the C++ front end.
>
> Checking the constructor/destructor attribute code in c-common.c, I
> see flags DECL_STATIC_CONSTRUCTOR and DECL_STATIC_DESTRUCTOR. These
> should be usable in the middle end, though I don't know if C++ code
> will set them. I didn't check. I suspect not. You might have to fix
> this if you need this info.
It doesn't set them because they don't mean the same thing. The C++
DECL_CONSTRUCTOR_P is a class consturctor; DECL_STATIC_CONSTRUCTOR is
something like C++'s magic file-scope initialization routines or C's
"__attribute__((constructor))" functions.
--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com
More information about the Gcc
mailing list