[clang] 4797437 - [clang][NFC] Increase NumStmtBits by 1 as we are approaching the limit (#120341)

via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 19 12:32:35 PST 2024


Author: Ziqing Luo
Date: 2024-12-19T12:32:31-08:00
New Revision: 4797437463e63ee289a1ff1904cfb7b2fe6cb4c2

URL: https://github.com/llvm/llvm-project/commit/4797437463e63ee289a1ff1904cfb7b2fe6cb4c2
DIFF: https://github.com/llvm/llvm-project/commit/4797437463e63ee289a1ff1904cfb7b2fe6cb4c2.diff

LOG: [clang][NFC] Increase NumStmtBits by 1 as we are approaching the limit (#120341)

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

Added: 
    

Modified: 
    clang/include/clang/AST/Stmt.h

Removed: 
    


################################################################################
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