https://github.com/AaronBallman approved this pull request. LGTM with nit addressed. Test coverage would be nice to add, but not strictly required if this is purely a defensive measure (which it seems to be). https://github.com/llvm/llvm-project/pull/131677