[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 4 14:37:54 PST 2020


rjmccall added inline comments.


================
Comment at: clang/include/clang/AST/Stmt.h:1104
+    static_assert(sizeof(*this) <= 16,
                   "changing bitfields changed sizeof(Stmt)");
     static_assert(sizeof(*this) % alignof(void *) == 0,
----------------
mibintc wrote:
> rjmccall wrote:
> > What's happening here is exactly what this assertion is supposed to prevent.   If you need more bits in one of these classes (I assume it's `CXXOperatorCallExpr`), you need to either make a field in the actual class or investigate more arcane mechanisms like  trailing storage to reduce the normal impact.  The latter is probably unnecessary for `CXXOperatorCallExpr`.
> @rjmccall The reason i changed the assertion is because FPOptions is now wider, so I had to change the assertion.  See line 609 above. Is there something I need to do differently? 
Because `Stmt` is a common base class for so much of the AST but only needs to store a small amount of state itself, we have a complicated system for optimizing space usage in subclasses by allocating bit-fields into `Stmt`.  Letting an individual subclass's bit-field usage run over the expected size and therefore inflate `Stmt` for all subclasses would be counter-productive, hence the `static_assert` and why it shouldn't be changed.  You need to move the storage of `FPOptions` into the appropriate subclass wherever it would cause the `static_assert` to fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841





More information about the cfe-commits mailing list