[cfe-commits] [llvm-commits] [Patch] Move TargetData from Target to Support/VMCore

Chandler Carruth chandlerc at google.com
Thu Oct 4 15:55:42 PDT 2012


On Thu, Oct 4, 2012 at 3:51 PM, Villmow, Micah <Micah.Villmow at amd.com>wrote:

>  I'm curious how this could work.****
>
> ** **
>
> I have two classes.****
>
> TargetData and DataLayout.****
>
> ** **
>
> I want to point all uses of TargetData at DataLayout.****
>
> ** **
>
> typedef won't work not just because of forward declarations, but also
> because of static functions.****
>
> ** **
>
> So, I could define DataLayout as a subclass of TargetData, but once I want
> to move to DataLayout, how do I define TargetData in a way that won't
> require changes to many many locations.
>

I think you need to reverse the suggestion and instead use:

class TargetData {
  // existing code
};

class DataLayout : public TargetData {
  // some forwarding boilerplate
}

Then you can change everyone to refer to DataLayout, and then lift the
implementation of TargetData up into DataLayout.

You'll have to change folks to refer to DataLayout in o "top-down" way --
producers first.

****
>
> ** **
>
> Micah****
>
> ** **
>
> *From:* Kim Gräsman [mailto:kim.grasman at gmail.com]
> *Sent:* Thursday, October 04, 2012 1:33 PM
> *To:* Villmow, Micah
> *Cc:* Chris Lattner; Evan Cheng; llvm-commits at cs.uiuc.edu LLVM;
> cfe-commits at cs.uiuc.edu cfe; Nadav Rotem
>
> *Subject:* Re: [cfe-commits] [llvm-commits] [Patch] Move TargetData from
> Target to Support/VMCore****
>
>  ** **
>
> HI Micah,
>
>
> On Thursday, October 4, 2012, Villmow, Micah wrote:****
>
> Chris, the problem with steps #2/#3 is that plenty of clients have forward
> declarations of TargetData and the typedef won't work in this case, so I
> need to update the clients anyways.****
>
>  ****
>
> One trick I've used as an alternative to typedefs is to just derive from
> the old class, e.g.****
>
> ** **
>
>   class NewName : public TargetData {};****
>
> ** **
>
> This is forward-declarable just as well as TargetData itself.****
>
> ** **
>
> FWIW,****
>
> - Kim****
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121004/d7aeb4df/attachment.html>


More information about the cfe-commits mailing list