automoc: avoid compiler warnings in linker-warning-silencing code

Revise the code added by commit 4a9daae4 (automoc: silence linker
warning on macos, 2022-05-25, v3.24.0-rc1~55^2).  Make
`cmake_automoc_silence_linker_warning` less warning-y.
Fix weak-tables clang warning and copyable-polymorph clazy warning.

Fixes: #23823
26 jobs for !7550 with less_warnings_in_cmake_automoc_silence_linker_warning in 43 minutes and 23 seconds (queued for 4 seconds)
latest merge request