Also replace dyn_cast_or_null with dyn_cast when possible.
A couple of nits
Is it really worth it to add a template (and hence increase compile time and binary size) only to forward it to SmallVector? I'd just use 4 instead, this should cover the vast majority of cases.
Please use LogicalResult instead of bool
Can we use ValueRange instead of ArrayRef<Value>, this is more flexible and ValueRange is implicitly constructible from ArrayRef and other things.
Nit: drop trivial braces