[PATCH] D123298: [NFC] [AST] Reduce the size of TemplateParmPosition
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 8 04:31:27 PDT 2022
aaron.ballman added inline comments.
================
Comment at: clang/include/clang/AST/DeclTemplate.h:1151-1152
protected:
- // FIXME: These probably don't need to be ints. int:5 for depth, int:8 for
- // position? Maybe?
- unsigned Depth;
- unsigned Position;
+#define DEPTH_BITWIDTH 20
+#define POSITION_BITWIDTH 12
+ unsigned Depth : DEPTH_BITWIDTH;
----------------
Just as constant as a macro, but without all the macro issues.
================
Comment at: clang/include/clang/AST/DeclTemplate.h:1156-1157
- TemplateParmPosition(unsigned D, unsigned P) : Depth(D), Position(P) {}
+ static constexpr unsigned MaxDepth = (1l << DEPTH_BITWIDTH) - 1;
+ static constexpr unsigned MaxPosition = (1l << POSITION_BITWIDTH) - 1;
+
----------------
ChuanqiXu wrote:
> I don't find standard way to generate the maximum value for bit fields.. So I choose to calculate it by hand.
Since we're adding 1 everywhere we look at these values, would it make more sense to drop the -1 here and the +1 elsewhere?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123298/new/
https://reviews.llvm.org/D123298
More information about the cfe-commits
mailing list