[clang] [clang][bytecode][NFC] Use an anonymous union in Pointer (PR #154405)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 23 19:20:18 PDT 2025
================
@@ -95,31 +93,23 @@ class Pointer {
static constexpr unsigned RootPtrMark = ~0u;
public:
- Pointer() {
- StorageKind = Storage::Int;
- PointeeStorage.Int.Value = 0;
- PointeeStorage.Int.Desc = nullptr;
- }
- Pointer(IntPointer &&IntPtr) : StorageKind(Storage::Int) {
- PointeeStorage.Int = std::move(IntPtr);
- }
+ Pointer() : StorageKind(Storage::Int), Int{nullptr, 0} {}
+ Pointer(IntPointer &&IntPtr)
+ : StorageKind(Storage::Int), Int(std::move(IntPtr)) {}
Pointer(Block *B);
Pointer(Block *B, uint64_t BaseAndOffset);
Pointer(const Pointer &P);
Pointer(Pointer &&P);
Pointer(uint64_t Address, const Descriptor *Desc, uint64_t Offset = 0)
- : Offset(Offset), StorageKind(Storage::Int) {
- PointeeStorage.Int.Value = Address;
- PointeeStorage.Int.Desc = Desc;
- }
+ : Offset(Offset), StorageKind(Storage::Int), Int{Desc, Address} {}
Pointer(const Function *F, uint64_t Offset = 0)
- : Offset(Offset), StorageKind(Storage::Fn) {
- PointeeStorage.Fn = FunctionPointer(F);
+ : Offset(Offset), StorageKind(Storage::Fn), Fn(F) {
----------------
shafik wrote:
Why do you set `Fn` twice, once in the mem-init-list and then in the body of the constructor?
https://github.com/llvm/llvm-project/pull/154405
More information about the cfe-commits
mailing list