Konstantin Tokarev wrote:
04.10.2012, 21:10, "Yang Chen" <[email protected]>:
OK, I see the reason that I disabled templates here. RemoveBaseClass
works in a naive way:
  - put all members of a base class to one of its directly derived class;
  - remove the base class;
  - if the base class has more directly derived classes, then the
previously selected derived class becomes the new base class for those;

Then let's say we have code like below:

class A {}
class B : A {}
class C : A {}

After the transformation, we will have:
class B {}
class C : B {}

Now if B is a template class, RemoveBaseClass will generate incompilable
code like this:

template <class T> class B {};
class C : public B {};

Note that this is just a design choice because RemoveBaseClass doesn't
have sufficient analysis on class hierarchies. If a base class A have a
single derived class, it should be remove even if the derived class is a
template. I will add it into my TODO.

Have you seen my test case? It deals with quite different situation:

class A {};
template <class T> class B : A {};

and pass should eliminate A.

And AFAIU, CXXRD in code represents B, not A. Experiment proves it.

Yes, I did and tried your patch. Applying your patch did remove A, but it could introduce other incompilable code during reduction, e.g.,

class A {};
template <class T> class B: A{};
class C : A {};

will be transformed to

template <class T> class B {};
class C : B {};

- Yang

Reply via email to