Reklama
Reklama
Chapter 8: Trees: The intermediate representation used by the C and C++ front ends 67
CLASSTYPE_HAS_MUTABLE
TYPE_HAS_MUTABLE_P
These predicates hold for a class-type having a mutable data member.
CLASSTYPE_NON_POD_P
This predicate holds only for class-types that are not PODs.
TYPE_HAS_NEW_OPERATOR
This predicate holds for a class-type that defines operator new.
TYPE_HAS_ARRAY_NEW_OPERATOR
This predicate holds for a class-type for which operator new[] is defined.
TYPE_OVERLOADS_CALL_EXPR
This predicate holds for class-type for which the function call operator() is overloaded.
TYPE_OVERLOADS_ARRAY_REF
This predicate holds for a class-type that overloads operator[]
TYPE_OVERLOADS_ARROW
This predicate holds for a class-type for which operator-> is overloaded.
8.5 Declarations
This section covers the various kinds of declarations that appear in the internal representation, except for declarations of functions (represented by FUNCTION_DECL nodes), which are described in Section 8.6 [Functions], page 69.
Some macros can be used with any kind of declaration. These include:
DECL_NAME
This macro returns an IDENTIFIER_NODE giving the name of the entity.
TREE_TYPE
This macro returns the type of the entity declared.
TREE_FILENAME
This macro returns the name of the file in which the entity was declared, as a char*. For an entity declared implicitly by the compiler (like __builtin_ memcpy
), this will be the string "<internal>".
TREE_LINENO
This macro returns the line number at which the entity was declared, as an int
.
DECL_ARTIFICIAL
This predicate holds if the declaration was implicitly generated by the compiler.
For example, this predicate will hold of an implicitly declared member function, or of the TYPE_DECL implicitly generated for a class type. Recall that in C++ code like: struct S {}; is roughly equivalent to C code like: struct S {}; typedef struct S S;
68 GNU Compiler Collection (GCC) Internals
The implicitly generated typedef declaration is represented by a TYPE_DECL for which DECL_ARTIFICIAL holds.
DECL_NAMESPACE_SCOPE_P
This predicate holds if the entity was declared at a namespace scope.
DECL_CLASS_SCOPE_P
This predicate holds if the entity was declared at a class scope.
DECL_FUNCTION_SCOPE_P
This predicate holds if the entity was declared inside a function body.
The various kinds of declarations include:
LABEL_DECL
These nodes are used to represent labels in function bodies. For more information, see Section 8.6 [Functions], page 69. These nodes only appear in block scopes.
CONST_DECL
These nodes are used to represent enumeration constants. The value of the constant is given by DECL_INITIAL which will be an INTEGER_CST with the same type as the TREE_TYPE of the CONST_DECL, i.e., an ENUMERAL_TYPE.
RESULT_DECL
These nodes represent the value returned by a function. When a value is assigned to a RESULT_DECL, that indicates that the value should be returned, via bitwise copy, by the function. You can use DECL_SIZE and DECL_ALIGN on a
RESULT_DECL
, just as with a VAR_DECL.
TYPE_DECL
These nodes represent typedef declarations. The TREE_TYPE is the type declared to have the name given by DECL_NAME. In some cases, there is no associated name.
VAR_DECL
These nodes represent variables with namespace or block scope, as well as static data members. The DECL_SIZE and DECL_ALIGN are analogous to TYPE_SIZE and TYPE_ALIGN. For a declaration, you should always use the DECL_SIZE and
DECL_ALIGN rather than the TYPE_SIZE and TYPE_ALIGN given by the TREE_
TYPE
, since special attributes may have been applied to the variable to give it a particular size and alignment. You may use the predicates DECL_THIS_STATIC or DECL_THIS_EXTERN to test whether the storage class specifiers static or extern were used to declare a variable.
If this variable is initialized (but does not require a constructor), the DECL_
INITIAL will be an expression for the initializer. The initializer should be evaluated, and a bitwise copy into the variable performed. If the DECL_INITIAL is the error_mark_node, there is an initializer, but it is given by an explicit statement later in the code; no bitwise copy is required.
GCC provides an extension that allows either automatic variables, or global variables, to be placed in particular registers. This extension is being used for
Stáhnout
Reklama