[cfe-dev] Get the global variables (members) of a given C++ class
Hiren Patel
hdpatel at uwaterloo.ca
Thu Jan 24 05:05:40 PST 2013
Hi Miguel,
I did something similar where I wanted to get the class/type names of a variable declared using templates. I had class data members that looked like:
sc_in< sc_int<32> > value;
I used RecursiveASTVisitor to visit the Type class. This code may provide some guidance: https://github.com/hdpatel/systemc-clang/blob/revamp/src/FindTemplateTypes.h
Hope it helps.
--
Hiren
On 2013-01-23, at 5:11 AM, Miguel Aguilar wrote:
> 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.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130124/da4ce226/attachment.html>
More information about the cfe-dev
mailing list