[clang] [clang][bytecode] Cache Is(Unnamed)BitFields bools in `Record::Field` (PR #221392)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 4 22:30:15 PDT 2026


https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/221392

We need to query those a lot and we can save them in the padding bytes of `Record::Field`.

>From ab9fcb20011fbbb64352572b5735a49c8b45dcd1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Fri, 4 Sep 2026 16:42:22 +0200
Subject: [PATCH] Field bools

---
 clang/lib/AST/ByteCode/Record.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Record.h b/clang/lib/AST/ByteCode/Record.h
index 536bc319bde22..a32ac5d14bf81 100644
--- a/clang/lib/AST/ByteCode/Record.h
+++ b/clang/lib/AST/ByteCode/Record.h
@@ -29,16 +29,21 @@ class Record final {
     const FieldDecl *Decl;
     const Descriptor *Desc;
     unsigned Offset;
+    bool IsBitField;
+    bool IsUnnamedBitField;
 
-    bool isBitField() const { return Decl->isBitField(); }
-    bool isUnnamedBitField() const { return Decl->isUnnamedBitField(); }
+    bool isBitField() const { return IsBitField; }
+    bool isUnnamedBitField() const { return IsUnnamedBitField; }
     unsigned bitWidth() const {
       assert(isBitField());
       return Decl->getBitWidthValue();
     }
 
     Field(const FieldDecl *D, const Descriptor *Desc, unsigned Offset)
-        : Decl(D), Desc(Desc), Offset(Offset) {}
+        : Decl(D), Desc(Desc), Offset(Offset) {
+      IsBitField = Decl->isBitField();
+      IsUnnamedBitField = IsBitField && Decl->isUnnamedBitField();
+    }
   };
 
   /// Describes a base class.



More information about the cfe-commits mailing list