Since the custom target is a feature implemented at constraint
level, it is more appropriate to handle it in the common wrapper
functions, instead of modifying all the type specific callbacs
like get_constraint_targets and flush_constraint_targets.
Also, tag the special target with a flag so other code can
handle it appropriately where necessary.
This was split from D9732, and effectively reverts and refactors
part of D7437. This patch should cause no functional changes.