This results in significant deduplication of code. This patch is not expected to change any functionality, it's just some simplification in preparation for future work. Also slightly simplified some code that was being touched anyway and added some unit tests for some functions that were touched.
This looks good in general. Some minor comments below.
Thanks for cleaning this up - this looks unrelated to the patch. This should at least be mentioned in the summary. "FlatAffineConstraints cleanup"?
Thanks for removing duplication here. Please also use the "/*....=*/" form wherever constant integers, etc. are being passed - for readability. I think numReservedRows/Cols was earlier uninitialized?
It would be good to have a doc comment for these.
Doc comment please.
nReservedColumns needs a doc comment at least.
llvm math has this function: https://llvm.org/doxygen/MathExtras_8h_source.html
A bit weird that these tests are under Analysis/Presburger. Is there a better place for them?
Thanks for the quick review!
My primary reason to touch this code was to fix the usage of inequalities.reserve and the reference to nReservedColumns in accordance with the change to Matrix. I did slightly simplify the code since I was touching it anyway; I've mentioned this in the summary now.
Not sure where else to put it since Matrix is under Analysis/Presburger too at the moment. I'm happy to have them both moved in another patch if there's a better place for them.