[llvm-commits] [PATCH] Bug 5207: make APInt set(), clear() and flip() return void

Chris Lattner clattner at apple.com
Mon Nov 29 15:11:43 PST 2010


On Nov 29, 2010, at 2:51 AM, Jay Foad wrote:

> http://llvm.org/bugs/show_bug.cgi?id=5207
> 
> The bug says, among other things, that APInt methods "that update in
> place should return void to make it really clear that they do not
> return a new APInt". The attached patch does this for the methods
> set(), clear() and flip(). It passes "make check". I don't think any
> changes are needed in cfe/trunk/ or llvm-gcc-4.2/trunk/.
> 
> This does make some code more long-winded, e.g.:
> 
>   static APInt getMaxValue(unsigned numBits) {
> -    return APInt(numBits, 0).set();
> +    APInt API(numBits, 0);
> +    API.set();
> +    return API;
>   }
> 
> Do you still think it's a good idea? If so, OK to commit?

Looks great to me, please commit.  I'd also suggest renaming the methods to "setAllBits()" "clearAllBits" "flipAllBits" etc.  Thanks for working on this Jay!

-Chris



More information about the llvm-commits mailing list