[PATCH] D50050: [AST] CastExpr: BasePathSize is not large enough.

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 31 11:22:28 PDT 2018


lebedev.ri added inline comments.


================
Comment at: include/clang/AST/Expr.h:2791
+public:
+  using BasePathSizeTy = unsigned short;
+  static_assert(std::numeric_limits<BasePathSizeTy>::max() >= 16384,
----------------
erichkeane wrote:
> I'll let @rjmccall comment here, but I think I'd be willing to give up 2 more bytes here and just go with unsigned int.  It has the advantage of likely never being an issue again (since 4 billion bases is not an issue).
> 
> We might be paying for those 2 ANYWAY with alignment as well, right?
Yes, i do expect that we are paying for 2 bytes in padding already.


================
Comment at: include/clang/AST/Expr.h:2805
+  }
+  BasePathSizeTy &BasePathSize();
+
----------------
erichkeane wrote:
> Why is this a reference?  This seems odd... It seems that the const-cast magic above shouldn't be necessary either.
I'll make it a pointer and replace `BasePathSizeTy BasePathSize() const` with `path_size()`.
I don't really think it would be good to get rid of this pointer/reference, since then
we'd have more than one function doing what `CastExpr::BasePathSizeTy *CastExpr::BasePathSize()` does now.


Repository:
  rC Clang

https://reviews.llvm.org/D50050





More information about the cfe-commits mailing list