[llvm-commits] [PATCH] Remove Mutating Init Members

Jakob Stoklund Olesen stoklund at 2pi.dk
Wed Jul 13 22:22:02 PDT 2011


On Jul 13, 2011, at 9:37 PM, Nick Lewycky wrote:

> David Greene wrote:
>> Here's a patch to remove members from Inits that update their state.
>> This is in preparation for making Inits const and ultimately making
>> them FoldingSetNodes.
>> 
>> Please review.  Thanks!
> 
> Hi David,
> 
> I'm not a regular contributor to TableGen, but this patch looks fine to 
> me as it seems pretty easy to verify that it's not changing behavior.

Yup.

> --- a/utils/TableGen/Record.h
> +++ b/utils/TableGen/Record.h
> @@ -594,6 +594,8 @@ class BitsInit : public Init {
>    std::vector<Init*> Bits;
>  public:
>    explicit BitsInit(unsigned Size) : Bits(Size) {}
> +  template<typename InputIterator>
> +  BitsInit(InputIterator start, InputIterator end) : Bits(start, end) {}
> 
> Any reason to take an InputIterator pair and not an ArrayRef? I realize 
> that you may have a refactoring after this one for which an ArrayRef 
> wouldn't work, but I don't know. If possible, please use an ArrayRef!

The next patch would work fine with an ArrayRef, and in fact it would allow the largish BitsInit::get method to be moved out of line.

This would also be better with the ArrayRef single element constructor:

> +  Init *NewBits[1] = { UI };
> +  return new BitsInit(NewBits, array_endof(NewBits));

/jakob





More information about the llvm-commits mailing list