How does clang support opaque pointer

Hello, I want to know how the front-end supports opaque pointer. But I can’t find the coresponding patch in clang.

In what way do you mean? We support the -opaque-pointers flag (and do that by default). The rest of opaque-pointer is simply no longer using getPointerElementType on the llvm::Type/llvm::PointerType in our code generator. I believe this was done over a few dozen patches.

(all of this is assuming you’re talking about the LLVM transition to typeless pointees, aka Opaque Pointers).

Thanks a lot. I thought there was a patch that made clang support opaque pointer. I want to learn from the source code how to make clang support opaque pointer.

There is no single patch, but the likely most important part of opaque pointer support in clang is the Address class: llvm-project/Address.h at main · llvm/llvm-project · GitHub Historically, this only stored the pointer value and alignment. To support opaque pointers, it now also stores the element type (which is no longer implied by the pointer type).

Similarly, the element type is also tracked in a few other core structures in clang, such as RValue and LValue.

Thank you. Your answer is very helpful.