[clang] [clang] Recover necessary AddrSpaceCast (PR #119246)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 12 17:27:31 PST 2024


arsenm wrote:

> I mean, why do we have to watch for type mismatches and fix them instead of creating the correct type in the first place? There is `getPointerType(RetQT)` just above, shouldn't it be something like `getPointerType(RetQT, <correct address space>)`? Or RetQT should have had the correct address space, but for some reason it was lost?

Correct, this is generally how things should work. There are select contexts where a cast is necessary. 

> I'm unfamiliar with Clang Qualtypes and how clang QualTypes' addrspace info match to llvm types' addrspace info, so I shared a quick dirty fix to at least share a direction.

This depends where the value was created from. Generally you just query getTargetAddressSpace



https://github.com/llvm/llvm-project/pull/119246


More information about the cfe-commits mailing list