Several different places in the code had similar computations for the parameters that were eventually passed to the TypeInfo constructor.
This centralizes that code in one function, and allows passing TypeInfo to the various other *Info structures that need it.
Remove some "auto" types and replace with the real type for getting declarations. This was making some duplicate checking difficult to see.
nit: can we invert this condition and use an early return to reduce nesting?