Next:Statements for C and C++, Previous:Classes, Up:C and C++ Trees [Contents][Index]
A function is represented by aFUNCTION_DECL node. A set ofoverloaded functions is sometimes represented by anOVERLOAD node.
AnOVERLOAD node is not a declaration, so none of the‘DECL_’ macros should be used on anOVERLOAD. AnOVERLOAD node is similar to aTREE_LIST. UseOVL_CURRENT to get the function associated with anOVERLOAD node; useOVL_NEXT to get the nextOVERLOAD node in the list of overloaded functions. The macrosOVL_CURRENT andOVL_NEXT are actually polymorphic; you canuse them to work withFUNCTION_DECL nodes as well as withoverloads. In the case of aFUNCTION_DECL,OVL_CURRENTwill always return the function itself, andOVL_NEXT will alwaysbeNULL_TREE.
To determine the scope of a function, you can use theDECL_CONTEXT macro. This macro will return the class(either aRECORD_TYPE or aUNION_TYPE) or namespace (aNAMESPACE_DECL) of which the function is a member. For a virtualfunction, this macro returns the class in which the function wasactually defined, not the base class in which the virtual declarationoccurred.
If a friend function is defined in a class scope, theDECL_FRIEND_CONTEXT macro can be used to determine the class inwhich it was defined. For example, in
class C { friend void f() {} };theDECL_CONTEXT forf will be theglobal_namespace, but theDECL_FRIEND_CONTEXT will be theRECORD_TYPE forC.
The following macros and functions can be used on aFUNCTION_DECL:
DECL_MAIN_P ¶This predicate holds for a function that is the program entry point::code.
DECL_LOCAL_FUNCTION_P ¶This predicate holds if the function was declared at block scope, eventhough it has a global scope.
DECL_ANTICIPATED ¶This predicate holds if the function is a built-in function but itsprototype is not yet explicitly declared.
DECL_EXTERN_C_FUNCTION_P ¶This predicate holds if the function is declared as an‘extern "C"’ function.
DECL_LINKONCE_P ¶This macro holds if multiple copies of this function may be emitted invarious translation units. It is the responsibility of the linker tomerge the various copies. Template instantiations are the most commonexample of functions for whichDECL_LINKONCE_P holds; G++instantiates needed templates in all translation units which require them,and then relies on the linker to remove duplicate instantiations.
FIXME: This macro is not yet implemented.
DECL_FUNCTION_MEMBER_P ¶This macro holds if the function is a member of a class, rather than amember of a namespace.
DECL_STATIC_FUNCTION_P ¶This predicate holds if the function a static member function.
DECL_NONSTATIC_MEMBER_FUNCTION_P ¶This macro holds for a non-static member function.
DECL_CONST_MEMFUNC_P ¶This predicate holds for aconst-member function.
DECL_VOLATILE_MEMFUNC_P ¶This predicate holds for avolatile-member function.
DECL_CONSTRUCTOR_P ¶This macro holds if the function is a constructor.
DECL_NONCONVERTING_P ¶This predicate holds if the constructor is a non-converting constructor.
DECL_COMPLETE_CONSTRUCTOR_P ¶This predicate holds for a function which is a constructor for an objectof a complete type.
DECL_BASE_CONSTRUCTOR_P ¶This predicate holds for a function which is a constructor for a baseclass sub-object.
DECL_COPY_CONSTRUCTOR_P ¶This predicate holds for a function which is a copy-constructor.
DECL_DESTRUCTOR_P ¶This macro holds if the function is a destructor.
DECL_COMPLETE_DESTRUCTOR_P ¶This predicate holds if the function is the destructor for an object acomplete type.
DECL_OVERLOADED_OPERATOR_P ¶This macro holds if the function is an overloaded operator.
DECL_CONV_FN_P ¶This macro holds if the function is a type-conversion operator.
DECL_GLOBAL_CTOR_P ¶This predicate holds if the function is a file-scope initializationfunction.
DECL_GLOBAL_DTOR_P ¶This predicate holds if the function is a file-scope finalizationfunction.
DECL_THUNK_P ¶This predicate holds if the function is a thunk.
These functions represent stub code that adjusts thethis pointerand then jumps to another function. When the jumped-to functionreturns, control is transferred directly to the caller, withoutreturning to the thunk. The first parameter to the thunk is always thethis pointer; the thunk should addTHUNK_DELTA to thisvalue. (TheTHUNK_DELTA is anint, not anINTEGER_CST.)
Then, ifTHUNK_VCALL_OFFSET (anINTEGER_CST) is nonzerothe adjustedthis pointer must be adjusted again. The completecalculation is given by the following pseudo-code:
this += THUNK_DELTAif (THUNK_VCALL_OFFSET) this += (*((ptrdiff_t **) this))[THUNK_VCALL_OFFSET]
Finally, the thunk should jump to the location givenbyDECL_INITIAL; this will always be an expression for theaddress of a function.
DECL_NON_THUNK_FUNCTION_P ¶This predicate holds if the function isnot a thunk function.
GLOBAL_INIT_PRIORITY ¶If eitherDECL_GLOBAL_CTOR_P orDECL_GLOBAL_DTOR_P holds,then this gives the initialization priority for the function. Thelinker will arrange that all functions for whichDECL_GLOBAL_CTOR_P holds are run in increasing order of prioritybeforemain is called. When the program exits, all functions forwhichDECL_GLOBAL_DTOR_P holds are run in the reverse order.
TYPE_RAISES_EXCEPTIONS ¶This macro returns the list of exceptions that a (member-)function canraise. The returned list, if nonNULL, is comprised of nodeswhoseTREE_VALUE represents a type.
TYPE_NOTHROW_P ¶This predicate holds when the exception-specification of its argumentsis of the form ‘()’.
DECL_ARRAY_DELETE_OPERATOR_P ¶This predicate holds if the function an overloadedoperator delete[].
Next:Statements for C and C++, Previous:Classes, Up:C and C++ Trees [Contents][Index]