[llvm-commits] [PATCH] Bug 889: clean up dodgy casts between Value** and Constant**

Chris Lattner clattner at apple.com
Thu Jan 13 13:47:01 PST 2011


On Jan 12, 2011, at 7:54 AM, Jay Foad wrote:

> http://llvm.org/bugs/show_bug.cgi?id=889
> 
> This bug is about removing virtual methods from Value and its subclasses.

looks great to me!

-Chris

> 
> While playing with fixes for this bug, I found a few C-style casts
> from Value** to Constant** or vice versa. This works at the moment,
> because a static_cast from Constant* to Value* doesn't have to adjust
> the "this" pointer, but it's not safe in general. In particular, it
> won't work if Constant has virtual methods but Value doesn't.
> 
> The reason for the casts' existence is that there are various methods
> to do with creating getElementPtrs which take either an array of
> Values or an array of Constants, but there isn't much consistency --
> some methods can only take an array of Values, and some can only take
> an array of Constants.
> 
> This patch ensures that there are two overloads for each such method:
> one taking an array of Values, and one taking an array of Constants.
> By calling the appropriate version in each case, we can avoid the
> casts.
> 
> Tested with "make check". OK to commit?
> 
> Thanks,
> Jay.
> <fix-dodgy-casts>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list