[PATCH] D158302: [clang] Add simple utils to ensure static assert on bit count of DeclContext

Ding Fei via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 18 11:33:44 PDT 2023


danix800 created this revision.
danix800 added a reviewer: aaron.ballman.
danix800 added a project: clang.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
danix800 requested review of this revision.
Herald added a subscriber: cfe-commits.

Manually counting bits for DeclContext is error-prone. These two are still out-dated:

1. `NumObjCMethodDeclBits` (25, not 24)
2. `NumBlockDeclBits` (6, not 5)

Although no harm at this moment but it's still misleading and might cause problem
for the future.

Two simple reflection-like utilities `countBits` & `countFields` are added for auto-
updating these bits at compile time and static assert on syncing with any changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158302

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Support/BitFieldReflection.h
  clang/lib/Serialization/ASTWriterDecl.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158302.551586.patch
Type: text/x-patch
Size: 20266 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230818/85392663/attachment-0001.bin>


More information about the cfe-commits mailing list