Skip to content

Commit 131acb0

Browse files
committed
[clang][NFC] Move static assert on StmtClass bounds from header to source
A follow-up change to PR llvm#120341 & llvm#120643. Address @nikic's concern: llvm#120341 (comment)
1 parent ef42e9c commit 131acb0

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

clang/include/clang/AST/Stmt.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,7 @@ class alignas(void *) Stmt {
109109

110110
//===--- Statement bitfields classes ---===//
111111

112-
enum { NumStmtBits = 9 };
113-
114-
#define STMT(CLASS, PARENT)
115-
#define STMT_RANGE(BASE, FIRST, LAST)
116-
#define LAST_STMT_RANGE(BASE, FIRST, LAST) \
117-
static_assert(llvm::isUInt<NumStmtBits>(StmtClass::LAST##Class), \
118-
"The number of 'StmtClass'es is strictly bound " \
119-
"by a bitfield of width NumStmtBits");
120-
#define ABSTRACT_STMT(STMT)
121-
#include "clang/AST/StmtNodes.inc"
112+
#define NumStmtBits 9
122113

123114
class StmtBitfields {
124115
friend class ASTStmtReader;

clang/lib/AST/Stmt.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@
4747

4848
using namespace clang;
4949

50+
#define STMT(CLASS, PARENT)
51+
#define STMT_RANGE(BASE, FIRST, LAST)
52+
#define LAST_STMT_RANGE(BASE, FIRST, LAST) \
53+
static_assert(llvm::isUInt<NumStmtBits>(Stmt::StmtClass::LAST##Class), \
54+
"The number of 'StmtClass'es is strictly bound " \
55+
"by a bitfield of width NumStmtBits");
56+
#define ABSTRACT_STMT(STMT)
57+
#include "clang/AST/StmtNodes.inc"
58+
5059
static struct StmtClassNameTable {
5160
const char *Name;
5261
unsigned Counter;

0 commit comments

Comments
 (0)