[flang] Fixed regression in copy-in/copy-out (#161259)
Fixed the polymprphic check for copy-in/copy-out, added regression
tests.
Changed MayNeedCopy() to return std::optional<bool> and renamed it to
ActualArgNeedsCopy(). This function now returns true/false when it's
known that actual arguments needs copy in/out, or std::nullopt to
signify that it's now known, whether copy in/out is needed.
Fixes #159149