[cfe-dev] Finding a particular constructor

Richard Trieu rtrieu at google.com
Thu Oct 10 14:38:46 PDT 2013


Call getConstructor() on your CXXConstructExpr to get the
CXXConstructorDecl that matches your function.  Then iterate over the
parameters till you find the one called "x".  Get the index of the
parameter and use getArg(index) on CXXConstructExpr to get the argument
corresponding to "x".


On Wed, Oct 9, 2013 at 2:42 AM, Jesper Eskilson <jesper.eskilson at iar.com>wrote:

> Hi,
>
> I have a class with a large number of constructors which differ only
> slightly. I'd like to be able to distinguish these by looking at the names
> of the arguments, but I cannot seem to find them.
>
> class A {
> public:
>      A(int x);
>      A(int x, float y);
>      A(double w, int x, char *z);
>      ...
> }
>
> I'd like to be able to (for example) look at a particular CXXConstructExpr
> and get the value of "x", whichever position "x" may have.
>
> Where should I be looking?
>
> --
> *Jesper Eskilson* /Development Engineer/
> IAR Systems AB
> Box 23051, Strandbodgatan 1
> SE-750 23 Uppsala, SWEDEN
> E-mail: jesper.eskilson at iar.com <mailto:jesper.eskilson at iar.**com<jesper.eskilson at iar.com>>
> Website: www.iar.com
> <http://www.iar.com> Twitter: www.twitter.com/iarsystems <
> http://www.twitter.com/**iarsystems <http://www.twitter.com/iarsystems>>
>
> ______________________________**_________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/**mailman/listinfo/cfe-dev<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/20131010/5a4ebafc/attachment.html>


More information about the cfe-dev mailing list