[clang] [clang][NFC] Increase NumStmtBits by 2 as we are approaching the limit (PR #120341)

Ziqing Luo via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 18 12:15:45 PST 2024


https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/120341

>From 69477100ca48508517a56c9efc3db6840bea82cb Mon Sep 17 00:00:00 2001
From: Ziqing Luo <ziqing at udel.edu>
Date: Wed, 18 Dec 2024 12:14:05 -0800
Subject: [PATCH] [clang][NFC] Increase NumStmtBits by 1 as we are approaching
 the limit

We have already hit the limit of NumStmtBits downstream after 010d011,
which adds 4 new StmtNodes.

(rdar://141555357)
---
 clang/include/clang/AST/Stmt.h | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 83fafbabb1d460..07cb63956aed0d 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -109,6 +109,18 @@ class alignas(void *) Stmt {
 
   //===--- Statement bitfields classes ---===//
 
+  enum { NumStmtBits = 9 };
+
+#define STMT(CLASS, PARENT)
+#define STMT_RANGE(BASE, FIRST, LAST)
+#define LAST_STMT_RANGE(BASE, FIRST, LAST)                                     \
+  static_assert(                                                               \
+      llvm::isInt<NumStmtBits>(StmtClass::LAST##Class),                        \
+      "The number of 'StmtClass'es is strictly bounded under two to "          \
+      "the power of 'NumStmtBits'");
+#define ABSTRACT_STMT(STMT)
+#include "clang/AST/StmtNodes.inc"
+
   class StmtBitfields {
     friend class ASTStmtReader;
     friend class ASTStmtWriter;
@@ -116,9 +128,8 @@ class alignas(void *) Stmt {
 
     /// The statement class.
     LLVM_PREFERRED_TYPE(StmtClass)
-    unsigned sClass : 8;
+    unsigned sClass : NumStmtBits;
   };
-  enum { NumStmtBits = 8 };
 
   class NullStmtBitfields {
     friend class ASTStmtReader;



More information about the cfe-commits mailing list