Author: Ziqing Luo Date: 2024-12-20T12:42:21-08:00 New Revision: 131acb07d814fabcc969dcaa63f4f352cd529267
URL: https://github.com/llvm/llvm-project/commit/131acb07d814fabcc969dcaa63f4f352cd529267 DIFF: https://github.com/llvm/llvm-project/commit/131acb07d814fabcc969dcaa63f4f352cd529267.diff LOG: [clang][NFC] Move static assert on StmtClass bounds from header to source A follow-up change to PR #120341 & #120643. Address @nikic's concern: https://github.com/llvm/llvm-project/pull/120341#discussion_r1893822845 Added: Modified: clang/include/clang/AST/Stmt.h clang/lib/AST/Stmt.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index f188bd47f5c0aa..405c6166adb15a 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -109,16 +109,7 @@ 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::isUInt<NumStmtBits>(StmtClass::LAST##Class), \ - "The number of 'StmtClass'es is strictly bound " \ - "by a bitfield of width NumStmtBits"); -#define ABSTRACT_STMT(STMT) -#include "clang/AST/StmtNodes.inc" + #define NumStmtBits 9 class StmtBitfields { friend class ASTStmtReader; diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 1e527ed0b2a2ea..d6a351a78c7ba8 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -47,6 +47,15 @@ using namespace clang; +#define STMT(CLASS, PARENT) +#define STMT_RANGE(BASE, FIRST, LAST) +#define LAST_STMT_RANGE(BASE, FIRST, LAST) \ + static_assert(llvm::isUInt<NumStmtBits>(Stmt::StmtClass::LAST##Class), \ + "The number of 'StmtClass'es is strictly bound " \ + "by a bitfield of width NumStmtBits"); +#define ABSTRACT_STMT(STMT) +#include "clang/AST/StmtNodes.inc" + static struct StmtClassNameTable { const char *Name; unsigned Counter; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits