[PATCH] D123298: [NFC] [AST] Reduce the size of TemplateParmPosition

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 7 03:58:12 PDT 2022

ChuanqiXu created this revision.
ChuanqiXu added reviewers: erichkeane, aaron.ballman, cor3ntin.
ChuanqiXu added a project: clang.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added a subscriber: cfe-commits.

I found this when reading the codes. I think it makes sense to reduce the space for TemplateParmPosition. It is hard to image the depth of template parameter is larger than 2^20 and the index is larger than 2^12. So I think the patch might be reasonable.

  rG LLVM Github Monorepo



Index: clang/include/clang/AST/DeclTemplate.h
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -1148,10 +1148,8 @@
 /// parameters and is not part of the Decl hierarchy. Just a facility.
 class TemplateParmPosition {
-  // FIXME: These probably don't need to be ints. int:5 for depth, int:8 for
-  // position? Maybe?
-  unsigned Depth;
-  unsigned Position;
+  unsigned Depth : 20;
+  unsigned Position : 12;
   TemplateParmPosition(unsigned D, unsigned P) : Depth(D), Position(P) {}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123298.421152.patch
Type: text/x-patch
Size: 609 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220407/3adda9b6/attachment.bin>

More information about the cfe-commits mailing list