[cfe-dev] Get the global variables (members) of a given C++ class

Miguel Aguilar miguel.aguilar at ice.rwth-aachen.de
Wed Jan 23 02:11:56 PST 2013


Hi Jordan,

Thanks for the reply, RecordDecl is exactly what I wanted to use. 
However as I am using a type derived from a template I am getting the 
following output:

OutPort<int>

Is there any way to get the name of type (OutPort) and the parameter of 
the template (int), independently?

Thanks,

Miguel

On 01/22/2013 06:27 PM, Jordan Rose wrote:
> On Jan 22, 2013, at 4:21 , Miguel Aguilar<miguel.aguilar at ice.rwth-aachen.de>  wrote:
>
>> Hi,
>>
>> I am wondering if for a given c++ class record (CXXRecordDecl) is possible to walk through the global variables (members).
>>
>>
>> For example:
>>
>> class Consumer : public Process
>> {
>> public:
>>   Consumer(const Id&  n, In<int>&  i);
>>   const char* type() const;
>>   void main();
>>
>> private:
>>   InPort<int>  in;
>> };
>>
>>
>> Here I would like to parse the member  "InPort<int>  in;" in order to get the type and the name of the variable.
>
> I think you want RecordDecl's inherited field_begin and field_end.




More information about the cfe-dev mailing list