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]

Re: How to extract types of variables and its uid?


On Thu, Apr 9, 2015 at 12:41 PM, Swati Rathi <swatirathi@cse.iitb.ac.in> wrote:
>
> The variables are declared as you have mentioned.
>
> IStream *var1;
> IStream *var2;
>
> Also, var1 and var2 are declared in different functions.

Works for me.

class IStream;
void foo (void) { IStream *var1; }
void bar (void) { IStream *var2; }

> g++ -S t.C -fdump-tree-gimple-uid
> cat t.C.004t.gimple
void foo() ()
{
  struct IStreamD.2324 * var1D.2327;


}


void bar() ()
{
  struct IStreamD.2324 * var2D.2330;


}

thus both TYPE_NAMEs have the same DECL_UID 2324.
Their type, even the pointer type have the same TYPE_UID as well
as seen in a debugging session looking at the functions BLOCK
tree before gimplification.

You must be doing sth wrong.

Richard.

>
>
> On Thursday 09 April 2015 03:30 PM, Richard Biener wrote:
>>
>> On Thu, Apr 9, 2015 at 11:57 AM, Swati Rathi <swatirathi@cse.iitb.ac.in>
>> wrote:
>>>
>>> We want to store all the types associated with the class objects or
>>> pointer
>>> to a class in a program.
>>>
>>> Consider two variables var1 and var2 declared in different functions as
>>> below.
>>>      class IStream *var1;
>>>      class IStream *var2;
>>>
>>> We are extracting its type as below :
>>>      tree type1 = TREE_TYPE (TREE_TYPE (var1));
>>>      tree type2 = TREE_TYPE (TREE_TYPE (var2));
>>>
>>> TREE_CODE (type1) and TREE_CODE (type2) is RECORD_TYPE.
>>> We wish to record the type struct IStream.
>>>
>>> However, when we print TYPE_UID (type1) and TYPE_UID (type2), it is
>>> different.
>>>      TYPE_UID = 4326, tree_type : struct IStream
>>>      TYPE_UID = 7421, tree_type : struct IStream
>>>
>>> Using TYPE_UID (TYPE_MAIN_VARIANT (type1)) and TYPE_UID
>>> (TYPE_MAIN_VARIANT
>>> (type2)) also gives the same result.
>>>
>>> We wish to avoid duplicate entries of the same type.
>>> How to extract types and uid?
>>
>> Doesn't it work with
>>
>> class IStream;
>>
>> IStream *var1;
>> IStream *var2;
>>
>> ?
>>
>>> Regards,
>>> Swati
>>>
>


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