Cleanup and improve --check-cfg
implementation
#117025
Merged
--check-cfg
implementation
#117025