[PATCH] D56358: [AST] Move back BasePathSize to the bit-fields of CastExpr

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 7 00:03:54 PST 2019


rjmccall added inline comments.


================
Comment at: include/clang/AST/Expr.h:3029
+    assert((CastExprBits.BasePathSize == BasePathSize) &&
+           "BasePathSize overflow!");
     assert(CastConsistency());
----------------
riccibruno wrote:
> lebedev.ri wrote:
> > riccibruno wrote:
> > > It cannot overflow now, but someone in the future is going
> > > to shrink `CastExprBitfields::BasePathSize`.
> > Can you move that static assert here instead of deleting it?
> I am not sure it is really useful since when someone will want to
> shrink it, it will be stored as `unsigned BasePathSite : x;`. What we
> don't want is having `x` too small. However `numeric_limits` will
> be based on the underlying type of the bit-field and so will never fail.
> 
> Storing it as something other than an unsigned, say a short, would work,
> but it will pack poorly with MSVC.
> 
> Hopefully the comment in `CastExprBitfields` will tell people to not shrink it
> mindlessly.
I agree that the type-based numeric limit is not useful if we're anticipating
it becoming a bit-field.  The comment seems fine since it's in the code that
would need to be edited.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56358/new/

https://reviews.llvm.org/D56358





More information about the cfe-commits mailing list