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

Jay Foad jay.foad at gmail.com
Mon Nov 29 02:51:03 PST 2010


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?

Thanks,
Jay.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: setclearflip.diff
Type: text/x-patch
Size: 6129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101129/dac9005a/attachment.bin>


More information about the llvm-commits mailing list