Don't fail dtx-hide="ident.something" attributes if ident is null

Also moved code for generating nullChecks to BuildTools as it's used
in multiple places now
Fix for variables only ever referenced in a template attribute being DCE'd if not set explicitly