Thanks for taking the time to look at the patch. I'll try to answer your questions:
Q: Will there ever be a case when section_ is null so that we need to generate a new one?
A: Yes, if you don't check for null, you'll get an NPE.
Q: And if we generate a new one, will that one be reused later?
A: That depends on where setSpecialRegister is called. Sometimes it will be reused, but other times a new Section will be allocated regardless.
Q: or will a new one be allocated and section_ replaced without
freeing the old one?
A: No, I actually don't think that will
happen. As far as I can tell, the only place where section_ is
assigned without verifying that it is null or that the
previous value has been freed, is in Statement's constructor and init methods.
Q: Should we instead have used the holdability of the statement,
since this section can now be used for other statements than the
set special register statement?
A: Possibly. But my impression is that the Section stored in the
section_ variable is reused only when you don't care about the
type of Section. In the case where the holdability of the Section
actually matters, a separate Section, with the proper
holdability, is kept in a local variable (newSection), and this
variable is transfered to the section_ variable after its
previous value is freed. I could be wrong about this, though.
I like your idea about using a separate member variable for
tracking the Section used in setSpecialRegister and I agree that
it more closely mimics the old behavior. The only reason for not
choosing that option from the beginning was that I did not see
any other method that did its own Section management like that.