This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Identifying a pointer to a structure


We are implementing points-to analysis in GCC 4.7.2 and need to distinguish between
pointers to scalars and the pointers to structures. This distinction by using the TYPE (TREE_TYPE)
hierarchy of the tree node of the pointer. We have two questions:

(a) Is it sufficient to check for the presence of RECORD_TYPE in type hierarchy?
(b) Is it safe to assume that the RECORD_TYPE always appears as a leaf node in
    the type description of any pointer to structure?

As an example, the tree nodes of a pointer to an integer (y) and a pointer to a structure (f)
below. It seems to support our hunch.

For example, the tree node of y which is a pointer to an integer is as follows:

<var_decl 0x405c8ea0 y
    type <pointer_type 0x40524a80
        type <integer_type 0x40524360 int public SI
            size <integer_cst 0x40514578 constant 32>
            unit size <integer_cst 0x40514594 constant 4>
            align 32 symtab 0 alias set 3 canonical type 0x40524360 precision 32 min <integer_cst 0x405148a4 -2147483648> max <integer_cst 0x405148c0 2147483647>
            pointer_to_this <pointer_type 0x40524a80>>
        unsigned SI
        size <integer_cst 0x40514578 constant 32>
        unit size <integer_cst 0x40514594 constant 4>
        align 32 symtab 0 alias set 2 canonical type 0x40524a80
        pointer_to_this <pointer_type 0x405cf300>>
    used static unsigned SI file struct0.c line 15 col 11
    size <integer_cst 0x40514578 type <integer_type 0x40524060 bitsizetype> constant 32>
    unit size <integer_cst 0x40514594 type <integer_type 0x40524000 sizetype> constant 4>
    align 32 context <translation_unit_decl 0x40529804 D.2319>
    (mem/f/c:SI (symbol_ref:SI ("y") [flags 0x2]  <var_decl 0x405c8ea0 y>) [2 y+0 S4 A32])>
_
_ Similarly, the tree node of f which is a pointer to a structure is as follows:

<var_decl 0x405c8f60 f
    type <pointer_type 0x405cf1e0
        type <*record_type* 0x405cf060 list BLK
            size <integer_cst 0x40514c08 constant 96>
            unit size <integer_cst 0x40514c24 constant 12>
            align 32 symtab 0 alias set 4 canonical type 0x405cf060 fields <field_decl 0x405220b8 val> context <translation_unit_decl 0x40529804 D.2319>
            pointer_to_this <pointer_type 0x405cf1e0> chain <type_decl 0x40529870 list>>
        public unsigned SI
        size <integer_cst 0x40514578 constant 32>
        unit size <integer_cst 0x40514594 constant 4>
        align 32 symtab 0 alias set 2 canonical type 0x405cf1e0
        pointer_to_this <pointer_type 0x405cf5a0>>
    used static unsigned SI file struct0.c line 14 col 25
    size <integer_cst 0x40514578 type <integer_type 0x40524060 bitsizetype> constant 32>
    unit size <integer_cst 0x40514594 type <integer_type 0x40524000 sizetype> constant 4>
    align 32 context <translation_unit_decl 0x40529804 D.2319>
    (mem/f/c:SI (symbol_ref:SI ("f") [flags 0x2]  <var_decl 0x405c8f60 f>) [2 f+0 S4 A32])>

Thanks and regards,

Uday Khedker.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]