[cfe-dev] Iterating over the constructors of a class
Miguel Aguilar
miguel.aguilar at ice.rwth-aachen.de
Mon Feb 4 05:35:27 PST 2013
Hi,
I want to check the initializers of the constructor of a class. For that
purpose I tried two aproaches: 1) Using the method
VisitCXXConstructorDecl and 2) VisitCXXRecordDecl and then use the
CXXRecordDecl::ctor_iterator. However, only when I use the approach 1) I
can see that the constructor actually has initializers.
The original code of the ctor is:
PC::PC(const Id& n) :
ProcessNetwork(n),
prod( id("prod"), fifo),
cons( id("cons"), fifo),
fifo( id("fifo"))
{ }
I am printing the name of the ctors, the number of initializers and the
body of the ctor.
The output using 1) is:
Ctor name: PC
Initializers: 0
{
}
Ctor name: PC
Initializers: 0
<NULL>
The output using 2) is:
Ctor name: PC
Initializers: 0
{
}
Ctor name: PC
Initializers: 4
{
}
Any idea why I am not getting the right output when I use the
CXXRecordDecl::ctor_iterator.
Thanks,
Miguel
More information about the cfe-dev
mailing list