[flang] Rework .mod file writing for subprogram interfaces
A subprogram interface in a `.mod` file requires all of the symbols
needed to declare the function return value and dummy arguments.
Some of those were missing.
`SubprogramSymbolCollector` recursively discovers all such symbols,
including symbols used in type parameters, array bounds, character
lengths, parent types.
Common blocks require special handling: If any of the symbols that
are need appear in a common block, we have to include that common block
and all other symbols in it. To make that easier to figure out, add the
`commonBlock` property to `ObjectEntityDetails` to map the entity to
the common block it is in, if any.
Original-commit: flang-compiler/f18@
08709f8e88c3b37bdf8461f34340dc345dfbb085
Reviewed-on: https://github.com/flang-compiler/f18/pull/368
Tree-same-pre-rewrite: false