[PATCH] D75443: [AST] Unpack FPFeatures bits to BinaryOperator, NFC.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 2 03:54:01 PST 2020


hokein created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
hokein edited the summary of this revision.

The stmt bit-fields is full (max 64 bits) for BinaryOperator now, adding
a new bit field (error) causes an 'static_assert(sizeof(*this) <=8)'
violation in Stmt constructor.

This patch unpacks the FPFeautres, make available bitfields for error
bit (https://reviews.llvm.org/D65591).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75443

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/Stmt.h


Index: clang/include/clang/AST/Stmt.h
===================================================================
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -531,10 +531,6 @@
 
     unsigned Opc : 6;
 
-    /// This is only meaningful for operations on floating point
-    /// types and 0 otherwise.
-    unsigned FPFeatures : 8;
-
     SourceLocation OpLoc;
   };
 
Index: clang/include/clang/AST/Expr.h
===================================================================
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -3439,7 +3439,9 @@
 class BinaryOperator : public Expr {
   enum { LHS, RHS, END_EXPR };
   Stmt *SubExprs[END_EXPR];
-
+  /// This is only meaningful for operations on floating point
+  /// types and 0 otherwise.
+  FPOptions FPFeatures;
 public:
   typedef BinaryOperatorKind Opcode;
 
@@ -3452,9 +3454,9 @@
            (lhs->isInstantiationDependent() ||
             rhs->isInstantiationDependent()),
            (lhs->containsUnexpandedParameterPack() ||
-            rhs->containsUnexpandedParameterPack())) {
+            rhs->containsUnexpandedParameterPack())),
+            FPFeatures(FPFeatures) {
     BinaryOperatorBits.Opc = opc;
-    BinaryOperatorBits.FPFeatures = FPFeatures.getInt();
     BinaryOperatorBits.OpLoc = opLoc;
     SubExprs[LHS] = lhs;
     SubExprs[RHS] = rhs;
@@ -3610,11 +3612,11 @@
   // Set the FP contractability status of this operator. Only meaningful for
   // operations on floating point types.
   void setFPFeatures(FPOptions F) {
-    BinaryOperatorBits.FPFeatures = F.getInt();
+    FPFeatures = F;
   }
 
   FPOptions getFPFeatures() const {
-    return FPOptions(BinaryOperatorBits.FPFeatures);
+    return FPFeatures;
   }
 
   // Get the FP contractability status of this operator. Only meaningful for
@@ -3637,9 +3639,9 @@
            (lhs->isInstantiationDependent() ||
             rhs->isInstantiationDependent()),
            (lhs->containsUnexpandedParameterPack() ||
-            rhs->containsUnexpandedParameterPack())) {
+            rhs->containsUnexpandedParameterPack())),
+            FPFeatures(FPFeatures) {
     BinaryOperatorBits.Opc = opc;
-    BinaryOperatorBits.FPFeatures = FPFeatures.getInt();
     BinaryOperatorBits.OpLoc = opLoc;
     SubExprs[LHS] = lhs;
     SubExprs[RHS] = rhs;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75443.247587.patch
Type: text/x-patch
Size: 2324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200302/a29cb473/attachment.bin>


More information about the cfe-commits mailing list