https://github.com/efriedma-quic approved this pull request. I don't think you're describing the failure mode correctly. (`castAs<PointerType>` ignores qualifiers). Otherwise LGTM https://github.com/llvm/llvm-project/pull/203010