[cfe-dev] CXXCtorInitializer different for templated and non templated code

Lukas Vogel lukedirtwalkerdev at gmail.com
Sun Aug 11 10:16:18 PDT 2013


Hi,

I recently found out that for the following sample:

class Pair {

  int a,b;

public:

  Pair(int f,int s){

    a=f;

    b=s;

  }

};


template <class T> class A : public Pair {

  A(int f, int s) : Pair(f,s){}

};


Clang produces a ParenListExpr as init expression for the Pair(f,s) call.


However if the class A has no template parameter i.e. just class A: public Pair{

Clang produces a CXXConstructExpr as init expression .


Why does it matter if there is a template argument for the CXXCtorInitializer ?


Thanks for your answers.

Cheers,

Lukas


PS: complete dumps of both samples:

non-templated:

    |-CXXCtorInitializer 'class Pair'

    | |-CXXConstructExpr 0x1aeb940 <col:21, col:29> 'class Pair' 'void
(int, int)'

    | | |-ImplicitCastExpr 0x1aeb910 <col:26> 'int' <LValueToRValue>

    | | | `-DeclRefExpr 0x1aeb4d8 <col:26> 'int' lvalue ParmVar
0x1aeb2c0 'f' 'int'

    | | `-ImplicitCastExpr 0x1aeb928 <col:28> 'int' <LValueToRValue>

    | |   `-DeclRefExpr 0x1aeb500 <col:28> 'int' lvalue ParmVar
0x1aeb330 's' 'int'



templated:


      |-CXXCtorInitializer 'class Pair'

      | |-ParenListExpr 0x2bff7e8 <col:25, col:29> 'NULL TYPE'

      | | |-DeclRefExpr 0x2bff798 <col:26> 'int' lvalue ParmVar
0x2bff580 'f' 'int'

      | | `-DeclRefExpr 0x2bff7c0 <col:28> 'int' lvalue ParmVar
0x2bff5f0 's' 'int'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130811/732cc9d9/attachment.html>


More information about the cfe-dev mailing list