[clang] [clang][bytecode][NFC] Move Pointer::StorageKind above the union (PR #147942)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 10 05:09:44 PDT 2025
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/147942
>From 86d5da314fd23bd135549773badc9893b5aee85a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Thu, 10 Jul 2025 13:52:10 +0200
Subject: [PATCH] [clang][bytecode][NFC] Move Pointer::StorageKind above the
union
This is easier to read in debuggers and more common.
---
clang/lib/AST/ByteCode/Pointer.cpp | 8 ++++----
clang/lib/AST/ByteCode/Pointer.h | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp
index 6769e51a8ad00..159b4238a6a04 100644
--- a/clang/lib/AST/ByteCode/Pointer.cpp
+++ b/clang/lib/AST/ByteCode/Pointer.cpp
@@ -30,8 +30,8 @@ Pointer::Pointer(Block *Pointee, uint64_t BaseAndOffset)
: Pointer(Pointee, BaseAndOffset, BaseAndOffset) {}
Pointer::Pointer(const Pointer &P)
- : Offset(P.Offset), PointeeStorage(P.PointeeStorage),
- StorageKind(P.StorageKind) {
+ : Offset(P.Offset), StorageKind(P.StorageKind),
+ PointeeStorage(P.PointeeStorage) {
if (isBlockPointer() && PointeeStorage.BS.Pointee)
PointeeStorage.BS.Pointee->addPointer(this);
@@ -48,8 +48,8 @@ Pointer::Pointer(Block *Pointee, unsigned Base, uint64_t Offset)
}
Pointer::Pointer(Pointer &&P)
- : Offset(P.Offset), PointeeStorage(P.PointeeStorage),
- StorageKind(P.StorageKind) {
+ : Offset(P.Offset), StorageKind(P.StorageKind),
+ PointeeStorage(P.PointeeStorage) {
if (StorageKind == Storage::Block && PointeeStorage.BS.Pointee)
PointeeStorage.BS.Pointee->replacePointer(&P, this);
diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index d525f84fd6605..e6a64e6658f06 100644
--- a/clang/lib/AST/ByteCode/Pointer.h
+++ b/clang/lib/AST/ByteCode/Pointer.h
@@ -809,13 +809,13 @@ class Pointer {
/// Next link in the pointer chain.
Pointer *Next = nullptr;
+ Storage StorageKind = Storage::Int;
union {
BlockPointer BS;
IntPointer Int;
FunctionPointer Fn;
TypeidPointer Typeid;
} PointeeStorage;
- Storage StorageKind = Storage::Int;
};
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Pointer &P) {
More information about the cfe-commits
mailing list