diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -1535,9 +1535,6 @@ }; class FixedPointLiteral : public Expr, public APIntStorage { - SourceLocation Loc; - unsigned Scale; - /// \brief Construct an empty fixed-point literal. explicit FixedPointLiteral(EmptyShell Empty) : Expr(FixedPointLiteralClass, Empty) {} @@ -1555,16 +1552,22 @@ /// Returns an empty fixed-point literal. static FixedPointLiteral *Create(const ASTContext &C, EmptyShell Empty); - SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; } - SourceLocation getEndLoc() const LLVM_READONLY { return Loc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return FixedPointLiteralBits.Loc; + } + SourceLocation getEndLoc() const LLVM_READONLY { + return FixedPointLiteralBits.Loc; + } /// \brief Retrieve the location of the literal. - SourceLocation getLocation() const { return Loc; } + SourceLocation getLocation() const { return FixedPointLiteralBits.Loc; } - void setLocation(SourceLocation Location) { Loc = Location; } + void setLocation(SourceLocation Location) { + FixedPointLiteralBits.Loc = Location; + } - unsigned getScale() const { return Scale; } - void setScale(unsigned S) { Scale = S; } + unsigned getScale() const { return FixedPointLiteralBits.Scale; } + void setScale(unsigned S) { FixedPointLiteralBits.Scale = S; } static bool classof(const Stmt *T) { return T->getStmtClass() == FixedPointLiteralClass; @@ -1592,15 +1595,15 @@ }; private: - unsigned Value; SourceLocation Loc; + public: // type should be IntTy CharacterLiteral(unsigned value, CharacterKind kind, QualType type, SourceLocation l) - : Expr(CharacterLiteralClass, type, VK_PRValue, OK_Ordinary), - Value(value), Loc(l) { + : Expr(CharacterLiteralClass, type, VK_PRValue, OK_Ordinary), Loc(l) { CharacterLiteralBits.Kind = kind; + CharacterLiteralBits.Value = value; setDependence(ExprDependence::None); } @@ -1615,11 +1618,11 @@ SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; } SourceLocation getEndLoc() const LLVM_READONLY { return Loc; } - unsigned getValue() const { return Value; } + unsigned getValue() const { return CharacterLiteralBits.Value; } void setLocation(SourceLocation Location) { Loc = Location; } void setKind(CharacterKind kind) { CharacterLiteralBits.Kind = kind; } - void setValue(unsigned Val) { Value = Val; } + void setValue(unsigned Val) { CharacterLiteralBits.Value = Val; } static bool classof(const Stmt *T) { return T->getStmtClass() == CharacterLiteralClass; @@ -1637,8 +1640,6 @@ }; class FloatingLiteral : public Expr, private APFloatStorage { - SourceLocation Loc; - FloatingLiteral(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L); @@ -1691,11 +1692,15 @@ /// debugging dumps, etc. double getValueAsApproximateDouble() const; - SourceLocation getLocation() const { return Loc; } - void setLocation(SourceLocation L) { Loc = L; } + SourceLocation getLocation() const { return FloatingLiteralBits.Loc; } + void setLocation(SourceLocation L) { FloatingLiteralBits.Loc = L; } - SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; } - SourceLocation getEndLoc() const LLVM_READONLY { return Loc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return FloatingLiteralBits.Loc; + } + SourceLocation getEndLoc() const LLVM_READONLY { + return FloatingLiteralBits.Loc; + } static bool classof(const Stmt *T) { return T->getStmtClass() == FloatingLiteralClass; @@ -2055,7 +2060,7 @@ // kernels. class SYCLUniqueStableNameExpr final : public Expr { friend class ASTStmtReader; - SourceLocation OpLoc, LParen, RParen; + SourceLocation LParen, RParen; TypeSourceInfo *TypeInfo; SYCLUniqueStableNameExpr(EmptyShell Empty, QualType ResultTy); @@ -2065,7 +2070,7 @@ void setTypeSourceInfo(TypeSourceInfo *Ty) { TypeInfo = Ty; } - void setLocation(SourceLocation L) { OpLoc = L; } + void setLocation(SourceLocation L) { ExprWithSourceLocBits.Loc = L; } void setLParenLocation(SourceLocation L) { LParen = L; } void setRParenLocation(SourceLocation L) { RParen = L; } @@ -2082,7 +2087,7 @@ SourceLocation getBeginLoc() const { return getLocation(); } SourceLocation getEndLoc() const { return RParen; } - SourceLocation getLocation() const { return OpLoc; } + SourceLocation getLocation() const { return ExprWithSourceLocBits.Loc; } SourceLocation getLParenLocation() const { return LParen; } SourceLocation getRParenLocation() const { return RParen; } @@ -2110,13 +2115,14 @@ /// ParenExpr - This represents a parethesized expression, e.g. "(1)". This /// AST node is only formed if full location information is requested. class ParenExpr : public Expr { - SourceLocation L, R; + SourceLocation R; Stmt *Val; public: ParenExpr(SourceLocation l, SourceLocation r, Expr *val) : Expr(ParenExprClass, val->getType(), val->getValueKind(), val->getObjectKind()), - L(l), R(r), Val(val) { + R(r), Val(val) { + ExprWithSourceLocBits.Loc = l; setDependence(computeDependence(this)); } @@ -2128,12 +2134,14 @@ Expr *getSubExpr() { return cast(Val); } void setSubExpr(Expr *E) { Val = E; } - SourceLocation getBeginLoc() const LLVM_READONLY { return L; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return ExprWithSourceLocBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { return R; } /// Get the location of the left parentheses '('. - SourceLocation getLParen() const { return L; } - void setLParen(SourceLocation Loc) { L = Loc; } + SourceLocation getLParen() const { return ExprWithSourceLocBits.Loc; } + void setLParen(SourceLocation Loc) { ExprWithSourceLocBits.Loc = Loc; } /// Get the location of the right parentheses ')'. SourceLocation getRParen() const { return R; } @@ -2447,13 +2455,9 @@ SourceLocation OperatorLoc, RParenLoc; // Base type; TypeSourceInfo *TSInfo; - // Number of sub-components (i.e. instances of OffsetOfNode). - unsigned NumComps; - // Number of sub-expressions (i.e. array subscript expressions). - unsigned NumExprs; size_t numTrailingObjects(OverloadToken) const { - return NumComps; + return OffsetOfExprBits.NumComps; } OffsetOfExpr(const ASTContext &C, QualType type, @@ -2462,8 +2466,10 @@ SourceLocation RParenLoc); explicit OffsetOfExpr(unsigned numComps, unsigned numExprs) - : Expr(OffsetOfExprClass, EmptyShell()), - TSInfo(nullptr), NumComps(numComps), NumExprs(numExprs) {} + : Expr(OffsetOfExprClass, EmptyShell()), TSInfo(nullptr) { + OffsetOfExprBits.NumComps = numComps; + OffsetOfExprBits.NumExprs = numExprs; + } public: @@ -2491,37 +2497,33 @@ } const OffsetOfNode &getComponent(unsigned Idx) const { - assert(Idx < NumComps && "Subscript out of range"); + assert(Idx < OffsetOfExprBits.NumComps && "Subscript out of range"); return getTrailingObjects()[Idx]; } void setComponent(unsigned Idx, OffsetOfNode ON) { - assert(Idx < NumComps && "Subscript out of range"); + assert(Idx < OffsetOfExprBits.NumComps && "Subscript out of range"); getTrailingObjects()[Idx] = ON; } - unsigned getNumComponents() const { - return NumComps; - } + unsigned getNumComponents() const { return OffsetOfExprBits.NumComps; } Expr* getIndexExpr(unsigned Idx) { - assert(Idx < NumExprs && "Subscript out of range"); + assert(Idx < OffsetOfExprBits.NumExprs && "Subscript out of range"); return getTrailingObjects()[Idx]; } const Expr *getIndexExpr(unsigned Idx) const { - assert(Idx < NumExprs && "Subscript out of range"); + assert(Idx < OffsetOfExprBits.NumExprs && "Subscript out of range"); return getTrailingObjects()[Idx]; } void setIndexExpr(unsigned Idx, Expr* E) { - assert(Idx < NumComps && "Subscript out of range"); + assert(Idx < OffsetOfExprBits.NumComps && "Subscript out of range"); getTrailingObjects()[Idx] = E; } - unsigned getNumExpressions() const { - return NumExprs; - } + unsigned getNumExpressions() const { return OffsetOfExprBits.NumExprs; } SourceLocation getBeginLoc() const LLVM_READONLY { return OperatorLoc; } SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; } @@ -2533,12 +2535,12 @@ // Iterators child_range children() { Stmt **begin = reinterpret_cast(getTrailingObjects()); - return child_range(begin, begin + NumExprs); + return child_range(begin, begin + OffsetOfExprBits.NumExprs); } const_child_range children() const { Stmt *const *begin = reinterpret_cast(getTrailingObjects()); - return const_child_range(begin, begin + NumExprs); + return const_child_range(begin, begin + OffsetOfExprBits.NumExprs); } friend TrailingObjects; }; @@ -2551,7 +2553,7 @@ TypeSourceInfo *Ty; Stmt *Ex; } Argument; - SourceLocation OpLoc, RParenLoc; + SourceLocation RParenLoc; public: UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo, @@ -2559,9 +2561,10 @@ SourceLocation rp) : Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_PRValue, OK_Ordinary), - OpLoc(op), RParenLoc(rp) { + RParenLoc(rp) { assert(ExprKind <= UETT_Last && "invalid enum value!"); UnaryExprOrTypeTraitExprBits.Kind = ExprKind; + UnaryExprOrTypeTraitExprBits.OpLoc = op; assert(static_cast(ExprKind) == UnaryExprOrTypeTraitExprBits.Kind && "UnaryExprOrTypeTraitExprBits.Kind overflow!"); @@ -2619,13 +2622,19 @@ return isArgumentType() ? getArgumentType() : getArgumentExpr()->getType(); } - SourceLocation getOperatorLoc() const { return OpLoc; } - void setOperatorLoc(SourceLocation L) { OpLoc = L; } + SourceLocation getOperatorLoc() const { + return UnaryExprOrTypeTraitExprBits.OpLoc; + } + void setOperatorLoc(SourceLocation L) { + UnaryExprOrTypeTraitExprBits.OpLoc = L; + } SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceLocation getBeginLoc() const LLVM_READONLY { return OpLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return UnaryExprOrTypeTraitExprBits.OpLoc; + } SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; } static bool classof(const Stmt *T) { @@ -2654,7 +2663,7 @@ : Expr(ArraySubscriptExprClass, t, VK, OK) { SubExprs[LHS] = lhs; SubExprs[RHS] = rhs; - ArrayOrMatrixSubscriptExprBits.RBracketLoc = rbracketloc; + ExprWithSourceLocBits.Loc = rbracketloc; setDependence(computeDependence(this)); } @@ -2690,12 +2699,8 @@ } SourceLocation getEndLoc() const { return getRBracketLoc(); } - SourceLocation getRBracketLoc() const { - return ArrayOrMatrixSubscriptExprBits.RBracketLoc; - } - void setRBracketLoc(SourceLocation L) { - ArrayOrMatrixSubscriptExprBits.RBracketLoc = L; - } + SourceLocation getRBracketLoc() const { return ExprWithSourceLocBits.Loc; } + void setRBracketLoc(SourceLocation L) { ExprWithSourceLocBits.Loc = L; } SourceLocation getExprLoc() const LLVM_READONLY { return getBase()->getExprLoc(); @@ -2732,7 +2737,7 @@ SubExprs[BASE] = Base; SubExprs[ROW_IDX] = RowIdx; SubExprs[COLUMN_IDX] = ColumnIdx; - ArrayOrMatrixSubscriptExprBits.RBracketLoc = RBracketLoc; + ExprWithSourceLocBits.Loc = RBracketLoc; setDependence(computeDependence(this)); } @@ -2772,12 +2777,8 @@ return getBase()->getExprLoc(); } - SourceLocation getRBracketLoc() const { - return ArrayOrMatrixSubscriptExprBits.RBracketLoc; - } - void setRBracketLoc(SourceLocation L) { - ArrayOrMatrixSubscriptExprBits.RBracketLoc = L; - } + SourceLocation getRBracketLoc() const { return ExprWithSourceLocBits.Loc; } + void setRBracketLoc(SourceLocation L) { ExprWithSourceLocBits.Loc = L; } static bool classof(const Stmt *T) { return T->getStmtClass() == MatrixSubscriptExprClass; @@ -3403,11 +3404,6 @@ /// CompoundLiteralExpr - [C99 6.5.2.5] /// class CompoundLiteralExpr : public Expr { - /// LParenLoc - If non-null, this is the location of the left paren in a - /// compound literal like "(int){4}". This can be null if this is a - /// synthesized compound expression. - SourceLocation LParenLoc; - /// The type as written. This can be an incomplete array type, in /// which case the actual expression type will be different. /// The int part of the pair stores whether this expr is file scope. @@ -3417,7 +3413,8 @@ CompoundLiteralExpr(SourceLocation lparenloc, TypeSourceInfo *tinfo, QualType T, ExprValueKind VK, Expr *init, bool fileScope) : Expr(CompoundLiteralExprClass, T, VK, OK_Ordinary), - LParenLoc(lparenloc), TInfoAndScope(tinfo, fileScope), Init(init) { + TInfoAndScope(tinfo, fileScope), Init(init) { + ExprWithSourceLocBits.Loc = lparenloc; setDependence(computeDependence(this)); } @@ -3432,8 +3429,8 @@ bool isFileScope() const { return TInfoAndScope.getInt(); } void setFileScope(bool FS) { TInfoAndScope.setInt(FS); } - SourceLocation getLParenLoc() const { return LParenLoc; } - void setLParenLoc(SourceLocation L) { LParenLoc = L; } + SourceLocation getLParenLoc() const { return ExprWithSourceLocBits.Loc; } + void setLParenLoc(SourceLocation L) { ExprWithSourceLocBits.Loc = L; } TypeSourceInfo *getTypeSourceInfo() const { return TInfoAndScope.getPointer(); @@ -3446,9 +3443,9 @@ // FIXME: Init should never be null. if (!Init) return SourceLocation(); - if (LParenLoc.isInvalid()) + if (ExprWithSourceLocBits.Loc.isInvalid()) return Init->getBeginLoc(); - return LParenLoc; + return ExprWithSourceLocBits.Loc; } SourceLocation getEndLoc() const LLVM_READONLY { // FIXME: Init should never be null. @@ -4105,14 +4102,16 @@ /// AbstractConditionalOperator - An abstract base class for /// ConditionalOperator and BinaryConditionalOperator. class AbstractConditionalOperator : public Expr { - SourceLocation QuestionLoc, ColonLoc; + SourceLocation ColonLoc; friend class ASTStmtReader; protected: AbstractConditionalOperator(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation qloc, SourceLocation cloc) - : Expr(SC, T, VK, OK), QuestionLoc(qloc), ColonLoc(cloc) {} + : Expr(SC, T, VK, OK), ColonLoc(cloc) { + ExprWithSourceLocBits.Loc = qloc; + } AbstractConditionalOperator(StmtClass SC, EmptyShell Empty) : Expr(SC, Empty) { } @@ -4131,7 +4130,7 @@ // the same as getRHS. Expr *getFalseExpr() const; - SourceLocation getQuestionLoc() const { return QuestionLoc; } + SourceLocation getQuestionLoc() const { return ExprWithSourceLocBits.Loc; } SourceLocation getColonLoc() const { return ColonLoc; } static bool classof(const Stmt *T) { @@ -4302,13 +4301,14 @@ /// AddrLabelExpr - The GNU address of label extension, representing &&label. class AddrLabelExpr : public Expr { - SourceLocation AmpAmpLoc, LabelLoc; + SourceLocation LabelLoc; LabelDecl *Label; public: AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelDecl *L, QualType t) - : Expr(AddrLabelExprClass, t, VK_PRValue, OK_Ordinary), AmpAmpLoc(AALoc), - LabelLoc(LLoc), Label(L) { + : Expr(AddrLabelExprClass, t, VK_PRValue, OK_Ordinary), LabelLoc(LLoc), + Label(L) { + ExprWithSourceLocBits.Loc = AALoc; setDependence(ExprDependence::None); } @@ -4316,12 +4316,14 @@ explicit AddrLabelExpr(EmptyShell Empty) : Expr(AddrLabelExprClass, Empty) { } - SourceLocation getAmpAmpLoc() const { return AmpAmpLoc; } - void setAmpAmpLoc(SourceLocation L) { AmpAmpLoc = L; } + SourceLocation getAmpAmpLoc() const { return ExprWithSourceLocBits.Loc; } + void setAmpAmpLoc(SourceLocation L) { ExprWithSourceLocBits.Loc = L; } SourceLocation getLabelLoc() const { return LabelLoc; } void setLabelLoc(SourceLocation L) { LabelLoc = L; } - SourceLocation getBeginLoc() const LLVM_READONLY { return AmpAmpLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return ExprWithSourceLocBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { return LabelLoc; } LabelDecl *getLabel() const { return Label; } @@ -4402,7 +4404,6 @@ // indices. The number of values in this list is always // 2+the number of indices in the vector type. Stmt **SubExprs; - unsigned NumExprs; public: ShuffleVectorExpr(const ASTContext &C, ArrayRef args, QualType Type, @@ -4428,34 +4429,39 @@ /// getNumSubExprs - Return the size of the SubExprs array. This includes the /// constant expression, the actual arguments passed in, and the function /// pointers. - unsigned getNumSubExprs() const { return NumExprs; } + unsigned getNumSubExprs() const { return ShuffleVectorExprBits.NumExprs; } /// Retrieve the array of expressions. Expr **getSubExprs() { return reinterpret_cast(SubExprs); } /// getExpr - Return the Expr at the specified index. Expr *getExpr(unsigned Index) { - assert((Index < NumExprs) && "Arg access out of range!"); + assert((Index < ShuffleVectorExprBits.NumExprs) && + "Arg access out of range!"); return cast(SubExprs[Index]); } const Expr *getExpr(unsigned Index) const { - assert((Index < NumExprs) && "Arg access out of range!"); + assert((Index < ShuffleVectorExprBits.NumExprs) && + "Arg access out of range!"); return cast(SubExprs[Index]); } void setExprs(const ASTContext &C, ArrayRef Exprs); llvm::APSInt getShuffleMaskIdx(const ASTContext &Ctx, unsigned N) const { - assert((N < NumExprs - 2) && "Shuffle idx out of range!"); + assert((N < ShuffleVectorExprBits.NumExprs - 2) && + "Shuffle idx out of range!"); return getExpr(N+2)->EvaluateKnownConstInt(Ctx); } // Iterators child_range children() { - return child_range(&SubExprs[0], &SubExprs[0]+NumExprs); + return child_range(&SubExprs[0], + &SubExprs[0] + ShuffleVectorExprBits.NumExprs); } const_child_range children() const { - return const_child_range(&SubExprs[0], &SubExprs[0] + NumExprs); + return const_child_range(&SubExprs[0], + &SubExprs[0] + ShuffleVectorExprBits.NumExprs); } }; @@ -4524,14 +4530,15 @@ class ChooseExpr : public Expr { enum { COND, LHS, RHS, END_EXPR }; Stmt* SubExprs[END_EXPR]; // Left/Middle/Right hand sides. - SourceLocation BuiltinLoc, RParenLoc; - bool CondIsTrue; + SourceLocation RParenLoc; + public: ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation RP, bool condIsTrue) - : Expr(ChooseExprClass, t, VK, OK), BuiltinLoc(BLoc), RParenLoc(RP), - CondIsTrue(condIsTrue) { + : Expr(ChooseExprClass, t, VK, OK), RParenLoc(RP) { + ChooseExprBits.CondIsTrue = condIsTrue; + ChooseExprBits.BuiltinLoc = BLoc; SubExprs[COND] = cond; SubExprs[LHS] = lhs; SubExprs[RHS] = rhs; @@ -4547,9 +4554,9 @@ bool isConditionTrue() const { assert(!isConditionDependent() && "Dependent condition isn't true or false"); - return CondIsTrue; + return ChooseExprBits.CondIsTrue; } - void setIsConditionTrue(bool isTrue) { CondIsTrue = isTrue; } + void setIsConditionTrue(bool isTrue) { ChooseExprBits.CondIsTrue = isTrue; } bool isConditionDependent() const { return getCond()->isTypeDependent() || getCond()->isValueDependent(); @@ -4568,13 +4575,15 @@ Expr *getRHS() const { return cast(SubExprs[RHS]); } void setRHS(Expr *E) { SubExprs[RHS] = E; } - SourceLocation getBuiltinLoc() const { return BuiltinLoc; } - void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; } + SourceLocation getBuiltinLoc() const { return ChooseExprBits.BuiltinLoc; } + void setBuiltinLoc(SourceLocation L) { ChooseExprBits.BuiltinLoc = L; } SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceLocation getBeginLoc() const LLVM_READONLY { return BuiltinLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return ChooseExprBits.BuiltinLoc; + } SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; } static bool classof(const Stmt *T) { @@ -4598,11 +4607,11 @@ /// that may not match the size of a pointer). class GNUNullExpr : public Expr { /// TokenLoc - The location of the __null keyword. - SourceLocation TokenLoc; public: GNUNullExpr(QualType Ty, SourceLocation Loc) - : Expr(GNUNullExprClass, Ty, VK_PRValue, OK_Ordinary), TokenLoc(Loc) { + : Expr(GNUNullExprClass, Ty, VK_PRValue, OK_Ordinary) { + ExprWithSourceLocBits.Loc = Loc; setDependence(ExprDependence::None); } @@ -4610,11 +4619,15 @@ explicit GNUNullExpr(EmptyShell Empty) : Expr(GNUNullExprClass, Empty) { } /// getTokenLocation - The location of the __null token. - SourceLocation getTokenLocation() const { return TokenLoc; } - void setTokenLocation(SourceLocation L) { TokenLoc = L; } + SourceLocation getTokenLocation() const { return ExprWithSourceLocBits.Loc; } + void setTokenLocation(SourceLocation L) { ExprWithSourceLocBits.Loc = L; } - SourceLocation getBeginLoc() const LLVM_READONLY { return TokenLoc; } - SourceLocation getEndLoc() const LLVM_READONLY { return TokenLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return ExprWithSourceLocBits.Loc; + } + SourceLocation getEndLoc() const LLVM_READONLY { + return ExprWithSourceLocBits.Loc; + } static bool classof(const Stmt *T) { return T->getStmtClass() == GNUNullExprClass; @@ -4680,7 +4693,7 @@ /// Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), /// __builtin_FUNCTION(), __builtin_FILE(), or __builtin_source_location(). class SourceLocExpr final : public Expr { - SourceLocation BuiltinLoc, RParenLoc; + SourceLocation RParenLoc; DeclContext *ParentContext; public: @@ -4723,8 +4736,8 @@ const DeclContext *getParentContext() const { return ParentContext; } DeclContext *getParentContext() { return ParentContext; } - SourceLocation getLocation() const { return BuiltinLoc; } - SourceLocation getBeginLoc() const { return BuiltinLoc; } + SourceLocation getLocation() const { return SourceLocExprBits.BuiltinLoc; } + SourceLocation getBeginLoc() const { return SourceLocExprBits.BuiltinLoc; } SourceLocation getEndLoc() const { return RParenLoc; } child_range children() { @@ -4792,7 +4805,7 @@ // FIXME: Eliminate this vector in favor of ASTContext allocation typedef ASTVector InitExprsTy; InitExprsTy InitExprs; - SourceLocation LBraceLoc, RBraceLoc; + SourceLocation RBraceLoc; /// The alternative form of the initializer list (if it exists). /// The int part of the pair stores whether this initializer list is @@ -4921,7 +4934,7 @@ // FIXME: This is wrong; InitListExprs created by semantic analysis have // valid source locations too! bool isExplicit() const { - return LBraceLoc.isValid() && RBraceLoc.isValid(); + return InitListExprBits.LBraceLoc.isValid() && RBraceLoc.isValid(); } // Is this an initializer for an array of characters, initialized by a string @@ -4937,8 +4950,8 @@ /// idiomatic? bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const; - SourceLocation getLBraceLoc() const { return LBraceLoc; } - void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; } + SourceLocation getLBraceLoc() const { return InitListExprBits.LBraceLoc; } + void setLBraceLoc(SourceLocation Loc) { InitListExprBits.LBraceLoc = Loc; } SourceLocation getRBraceLoc() const { return RBraceLoc; } void setRBraceLoc(SourceLocation Loc) { RBraceLoc = Loc; } @@ -5038,18 +5051,6 @@ /// expression. SourceLocation EqualOrColonLoc; - /// Whether this designated initializer used the GNU deprecated - /// syntax rather than the C99 '=' syntax. - unsigned GNUSyntax : 1; - - /// The number of designators in this initializer expression. - unsigned NumDesignators : 15; - - /// The number of subexpressions of this initializer expression, - /// which contains both the initializer and any additional - /// expressions used by array and array-range designators. - unsigned NumSubExprs : 16; - /// The designators in this designated initialization /// expression. Designator *Designators; @@ -5060,8 +5061,10 @@ ArrayRef IndexExprs, Expr *Init); explicit DesignatedInitExpr(unsigned NumSubExprs) - : Expr(DesignatedInitExprClass, EmptyShell()), - NumDesignators(0), NumSubExprs(NumSubExprs), Designators(nullptr) { } + : Expr(DesignatedInitExprClass, EmptyShell()), Designators(nullptr) { + DesignatedInitExprBits.NumDesignators = 0; + DesignatedInitExprBits.NumSubExprs = NumSubExprs; + } public: /// A field designator, e.g., ".x". @@ -5229,15 +5232,15 @@ unsigned NumIndexExprs); /// Returns the number of designators in this initializer. - unsigned size() const { return NumDesignators; } + unsigned size() const { return DesignatedInitExprBits.NumDesignators; } // Iterator access to the designators. llvm::MutableArrayRef designators() { - return {Designators, NumDesignators}; + return {Designators, DesignatedInitExprBits.NumDesignators}; } llvm::ArrayRef designators() const { - return {Designators, NumDesignators}; + return {Designators, DesignatedInitExprBits.NumDesignators}; } Designator *getDesignator(unsigned Idx) { return &designators()[Idx]; } @@ -5263,8 +5266,8 @@ /// Determines whether this designated initializer used the /// deprecated GNU syntax for designated initializers. - bool usesGNUSyntax() const { return GNUSyntax; } - void setGNUSyntax(bool GNU) { GNUSyntax = GNU; } + bool usesGNUSyntax() const { return DesignatedInitExprBits.GNUSyntax; } + void setGNUSyntax(bool GNU) { DesignatedInitExprBits.GNUSyntax = GNU; } /// Retrieve the initializer value. Expr *getInit() const { @@ -5279,15 +5282,17 @@ /// designated initializer expression, including the actual /// initialized value and any expressions that occur within array /// and array-range designators. - unsigned getNumSubExprs() const { return NumSubExprs; } + unsigned getNumSubExprs() const { return DesignatedInitExprBits.NumSubExprs; } Expr *getSubExpr(unsigned Idx) const { - assert(Idx < NumSubExprs && "Subscript out of range"); + assert(Idx < DesignatedInitExprBits.NumSubExprs && + "Subscript out of range"); return cast(getTrailingObjects()[Idx]); } void setSubExpr(unsigned Idx, Expr *E) { - assert(Idx < NumSubExprs && "Subscript out of range"); + assert(Idx < DesignatedInitExprBits.NumSubExprs && + "Subscript out of range"); getTrailingObjects()[Idx] = E; } @@ -5308,11 +5313,11 @@ // Iterators child_range children() { Stmt **begin = getTrailingObjects(); - return child_range(begin, begin + NumSubExprs); + return child_range(begin, begin + DesignatedInitExprBits.NumSubExprs); } const_child_range children() const { Stmt * const *begin = getTrailingObjects(); - return const_child_range(begin, begin + NumSubExprs); + return const_child_range(begin, begin + DesignatedInitExprBits.NumSubExprs); } friend TrailingObjects; @@ -5872,9 +5877,7 @@ return llvm::make_range(Begin, End); } - SourceLocation getGenericLoc() const { - return GenericSelectionExprBits.GenericLoc; - } + SourceLocation getGenericLoc() const { return ExprWithSourceLocBits.Loc; } SourceLocation getDefaultLoc() const { return DefaultLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getBeginLoc() const { return getGenericLoc(); } @@ -5910,13 +5913,14 @@ class ExtVectorElementExpr : public Expr { Stmt *Base; IdentifierInfo *Accessor; - SourceLocation AccessorLoc; + public: ExtVectorElementExpr(QualType ty, ExprValueKind VK, Expr *base, IdentifierInfo &accessor, SourceLocation loc) : Expr(ExtVectorElementExprClass, ty, VK, (VK == VK_PRValue ? OK_Ordinary : OK_VectorComponent)), - Base(base), Accessor(&accessor), AccessorLoc(loc) { + Base(base), Accessor(&accessor) { + ExprWithSourceLocBits.Loc = loc; setDependence(computeDependence(this)); } @@ -5931,8 +5935,8 @@ IdentifierInfo &getAccessor() const { return *Accessor; } void setAccessor(IdentifierInfo *II) { Accessor = II; } - SourceLocation getAccessorLoc() const { return AccessorLoc; } - void setAccessorLoc(SourceLocation L) { AccessorLoc = L; } + SourceLocation getAccessorLoc() const { return ExprWithSourceLocBits.Loc; } + void setAccessorLoc(SourceLocation L) { ExprWithSourceLocBits.Loc = L; } /// getNumElements - Get the number of components being selected. unsigned getNumElements() const; @@ -5948,7 +5952,9 @@ SourceLocation getBeginLoc() const LLVM_READONLY { return getBase()->getBeginLoc(); } - SourceLocation getEndLoc() const LLVM_READONLY { return AccessorLoc; } + SourceLocation getEndLoc() const LLVM_READONLY { + return ExprWithSourceLocBits.Loc; + } /// isArrow - Return true if the base expression is a pointer to vector, /// return false if the base expression is a vector. @@ -6247,9 +6253,7 @@ /// not fixed, therefore is not defined in enum. enum { PTR, ORDER, VAL1, ORDER_FAIL, VAL2, WEAK, END_EXPR }; Stmt *SubExprs[END_EXPR + 1]; - unsigned NumSubExprs; SourceLocation BuiltinLoc, RParenLoc; - AtomicOp Op; friend class ASTStmtReader; public: @@ -6271,32 +6275,33 @@ } Expr *getScope() const { assert(getScopeModel() && "No scope"); - return cast(SubExprs[NumSubExprs - 1]); + return cast(SubExprs[AtomicExprBits.NumSubExprs - 1]); } Expr *getVal1() const { - if (Op == AO__c11_atomic_init || Op == AO__opencl_atomic_init) + if (AtomicExprBits.Op == AO__c11_atomic_init || + AtomicExprBits.Op == AO__opencl_atomic_init) return cast(SubExprs[ORDER]); - assert(NumSubExprs > VAL1); + assert(AtomicExprBits.NumSubExprs > VAL1); return cast(SubExprs[VAL1]); } Expr *getOrderFail() const { - assert(NumSubExprs > ORDER_FAIL); + assert(AtomicExprBits.NumSubExprs > ORDER_FAIL); return cast(SubExprs[ORDER_FAIL]); } Expr *getVal2() const { - if (Op == AO__atomic_exchange) + if (AtomicExprBits.Op == AO__atomic_exchange) return cast(SubExprs[ORDER_FAIL]); - assert(NumSubExprs > VAL2); + assert(AtomicExprBits.NumSubExprs > VAL2); return cast(SubExprs[VAL2]); } Expr *getWeak() const { - assert(NumSubExprs > WEAK); + assert(AtomicExprBits.NumSubExprs > WEAK); return cast(SubExprs[WEAK]); } QualType getValueType() const; - AtomicOp getOp() const { return Op; } - unsigned getNumSubExprs() const { return NumSubExprs; } + AtomicOp getOp() const { return static_cast(AtomicExprBits.Op); } + unsigned getNumSubExprs() const { return AtomicExprBits.NumSubExprs; } Expr **getSubExprs() { return reinterpret_cast(SubExprs); } const Expr * const *getSubExprs() const { @@ -6335,10 +6340,10 @@ // Iterators child_range children() { - return child_range(SubExprs, SubExprs+NumSubExprs); + return child_range(SubExprs, SubExprs + AtomicExprBits.NumSubExprs); } const_child_range children() const { - return const_child_range(SubExprs, SubExprs + NumSubExprs); + return const_child_range(SubExprs, SubExprs + AtomicExprBits.NumSubExprs); } /// Get atomic scope model for the atomic op code. @@ -6365,12 +6370,10 @@ /// TypoExpr - Internal placeholder for expressions where typo correction /// still needs to be performed and/or an error diagnostic emitted. class TypoExpr : public Expr { - // The location for the typo name. - SourceLocation TypoLoc; - public: TypoExpr(QualType T, SourceLocation TypoLoc) - : Expr(TypoExprClass, T, VK_LValue, OK_Ordinary), TypoLoc(TypoLoc) { + : Expr(TypoExprClass, T, VK_LValue, OK_Ordinary) { + ExprWithSourceLocBits.Loc = TypoLoc; assert(T->isDependentType() && "TypoExpr given a non-dependent type"); setDependence(ExprDependence::TypeValueInstantiation | ExprDependence::Error); @@ -6383,13 +6386,16 @@ return const_child_range(const_child_iterator(), const_child_iterator()); } - SourceLocation getBeginLoc() const LLVM_READONLY { return TypoLoc; } - SourceLocation getEndLoc() const LLVM_READONLY { return TypoLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return ExprWithSourceLocBits.Loc; + } + SourceLocation getEndLoc() const LLVM_READONLY { + return ExprWithSourceLocBits.Loc; + } static bool classof(const Stmt *T) { return T->getStmtClass() == TypoExprClass; } - }; /// Frontend produces RecoveryExprs on semantic errors that prevent creating @@ -6428,7 +6434,7 @@ ArrayRef subExpressions() { auto *B = getTrailingObjects(); - return llvm::makeArrayRef(B, B + NumExprs); + return llvm::makeArrayRef(B, B + RecoveryExprBits.NumExprs); } ArrayRef subExpressions() const { @@ -6437,10 +6443,10 @@ child_range children() { Stmt **B = reinterpret_cast(getTrailingObjects()); - return child_range(B, B + NumExprs); + return child_range(B, B + RecoveryExprBits.NumExprs); } - SourceLocation getBeginLoc() const { return BeginLoc; } + SourceLocation getBeginLoc() const { return RecoveryExprBits.BeginLoc; } SourceLocation getEndLoc() const { return EndLoc; } static bool classof(const Stmt *T) { @@ -6451,12 +6457,15 @@ RecoveryExpr(ASTContext &Ctx, QualType T, SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef SubExprs); RecoveryExpr(EmptyShell Empty, unsigned NumSubExprs) - : Expr(RecoveryExprClass, Empty), NumExprs(NumSubExprs) {} + : Expr(RecoveryExprClass, Empty) { + RecoveryExprBits.NumExprs = NumSubExprs; + } - size_t numTrailingObjects(OverloadToken) const { return NumExprs; } + size_t numTrailingObjects(OverloadToken) const { + return RecoveryExprBits.NumExprs; + } - SourceLocation BeginLoc, EndLoc; - unsigned NumExprs; + SourceLocation EndLoc; friend TrailingObjects; friend class ASTStmtReader; friend class ASTStmtWriter; diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -760,7 +760,7 @@ public: CXXNullPtrLiteralExpr(QualType Ty, SourceLocation Loc) : Expr(CXXNullPtrLiteralExprClass, Ty, VK_PRValue, OK_Ordinary) { - CXXNullPtrLiteralExprBits.Loc = Loc; + ExprWithSourceLocBits.Loc = Loc; setDependence(ExprDependence::None); } @@ -770,8 +770,8 @@ SourceLocation getBeginLoc() const { return getLocation(); } SourceLocation getEndLoc() const { return getLocation(); } - SourceLocation getLocation() const { return CXXNullPtrLiteralExprBits.Loc; } - void setLocation(SourceLocation L) { CXXNullPtrLiteralExprBits.Loc = L; } + SourceLocation getLocation() const { return ExprWithSourceLocBits.Loc; } + void setLocation(SourceLocation L) { ExprWithSourceLocBits.Loc = L; } static bool classof(const Stmt *T) { return T->getStmtClass() == CXXNullPtrLiteralExprClass; @@ -923,8 +923,6 @@ class MSPropertyRefExpr : public Expr { Expr *BaseExpr; MSPropertyDecl *TheDecl; - SourceLocation MemberLoc; - bool IsArrow; NestedNameSpecifierLoc QualifierLoc; public: @@ -934,8 +932,9 @@ QualType ty, ExprValueKind VK, NestedNameSpecifierLoc qualifierLoc, SourceLocation nameLoc) : Expr(MSPropertyRefExprClass, ty, VK, OK_Ordinary), BaseExpr(baseExpr), - TheDecl(decl), MemberLoc(nameLoc), IsArrow(isArrow), - QualifierLoc(qualifierLoc) { + TheDecl(decl), QualifierLoc(qualifierLoc) { + MSPropertyRefExprBits.IsArrow = isArrow; + MSPropertyRefExprBits.MemberLoc = nameLoc; setDependence(computeDependence(this)); } @@ -955,7 +954,7 @@ else if (QualifierLoc) return QualifierLoc.getBeginLoc(); else - return MemberLoc; + return MSPropertyRefExprBits.MemberLoc; } SourceLocation getEndLoc() const { return getMemberLoc(); } @@ -975,8 +974,10 @@ Expr *getBaseExpr() const { return BaseExpr; } MSPropertyDecl *getPropertyDecl() const { return TheDecl; } - bool isArrow() const { return IsArrow; } - SourceLocation getMemberLoc() const { return MemberLoc; } + bool isArrow() const { return MSPropertyRefExprBits.IsArrow; } + SourceLocation getMemberLoc() const { + return MSPropertyRefExprBits.MemberLoc; + } NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } }; @@ -997,7 +998,6 @@ enum { BASE_EXPR, IDX_EXPR, NUM_SUBEXPRS = 2 }; Stmt *SubExprs[NUM_SUBEXPRS]; - SourceLocation RBracketLoc; void setBase(Expr *Base) { SubExprs[BASE_EXPR] = Base; } void setIdx(Expr *Idx) { SubExprs[IDX_EXPR] = Idx; } @@ -1005,8 +1005,8 @@ public: MSPropertySubscriptExpr(Expr *Base, Expr *Idx, QualType Ty, ExprValueKind VK, ExprObjectKind OK, SourceLocation RBracketLoc) - : Expr(MSPropertySubscriptExprClass, Ty, VK, OK), - RBracketLoc(RBracketLoc) { + : Expr(MSPropertySubscriptExprClass, Ty, VK, OK) { + ExprWithSourceLocBits.Loc = RBracketLoc; SubExprs[BASE_EXPR] = Base; SubExprs[IDX_EXPR] = Idx; setDependence(computeDependence(this)); @@ -1026,10 +1026,12 @@ return getBase()->getBeginLoc(); } - SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; } + SourceLocation getEndLoc() const LLVM_READONLY { + return ExprWithSourceLocBits.Loc; + } - SourceLocation getRBracketLoc() const { return RBracketLoc; } - void setRBracketLoc(SourceLocation L) { RBracketLoc = L; } + SourceLocation getRBracketLoc() const { return ExprWithSourceLocBits.Loc; } + void setRBracketLoc(SourceLocation L) { ExprWithSourceLocBits.Loc = L; } SourceLocation getExprLoc() const LLVM_READONLY { return getBase()->getExprLoc(); @@ -1256,7 +1258,7 @@ Param->getDefaultArg()->getValueKind(), Param->getDefaultArg()->getObjectKind()), Param(Param), UsedContext(UsedContext) { - CXXDefaultArgExprBits.Loc = Loc; + ExprWithSourceLocBits.Loc = Loc; setDependence(computeDependence(this)); } @@ -1284,7 +1286,7 @@ DeclContext *getUsedContext() { return UsedContext; } /// Retrieve the location where this default argument was actually used. - SourceLocation getUsedLocation() const { return CXXDefaultArgExprBits.Loc; } + SourceLocation getUsedLocation() const { return ExprWithSourceLocBits.Loc; } /// Default argument expressions have no representation in the /// source, so they have an empty source range. @@ -1359,8 +1361,8 @@ /// actually used. SourceLocation getUsedLocation() const { return getBeginLoc(); } - SourceLocation getBeginLoc() const { return CXXDefaultInitExprBits.Loc; } - SourceLocation getEndLoc() const { return CXXDefaultInitExprBits.Loc; } + SourceLocation getBeginLoc() const { return ExprWithSourceLocBits.Loc; } + SourceLocation getEndLoc() const { return ExprWithSourceLocBits.Loc; } static bool classof(const Stmt *T) { return T->getStmtClass() == CXXDefaultInitExprClass; @@ -1652,16 +1654,6 @@ private: CXXConstructorDecl *Constructor = nullptr; - /// The location of the using declaration. - SourceLocation Loc; - - /// Whether this is the construction of a virtual base. - unsigned ConstructsVirtualBase : 1; - - /// Whether the constructor is inherited from a virtual base class of the - /// class that we construct. - unsigned InheritedFromVirtualBase : 1; - public: friend class ASTStmtReader; @@ -1670,38 +1662,53 @@ CXXConstructorDecl *Ctor, bool ConstructsVirtualBase, bool InheritedFromVirtualBase) : Expr(CXXInheritedCtorInitExprClass, T, VK_PRValue, OK_Ordinary), - Constructor(Ctor), Loc(Loc), - ConstructsVirtualBase(ConstructsVirtualBase), - InheritedFromVirtualBase(InheritedFromVirtualBase) { + Constructor(Ctor) { + CXXInheritedCtorInitExprBits.Loc = Loc; + CXXInheritedCtorInitExprBits.ConstructsVirtualBase = ConstructsVirtualBase; + CXXInheritedCtorInitExprBits.InheritedFromVirtualBase = + InheritedFromVirtualBase; assert(!T->isDependentType()); setDependence(ExprDependence::None); } /// Construct an empty C++ inheriting construction expression. explicit CXXInheritedCtorInitExpr(EmptyShell Empty) - : Expr(CXXInheritedCtorInitExprClass, Empty), - ConstructsVirtualBase(false), InheritedFromVirtualBase(false) {} + : Expr(CXXInheritedCtorInitExprClass, Empty) { + CXXInheritedCtorInitExprBits.ConstructsVirtualBase = false; + CXXInheritedCtorInitExprBits.InheritedFromVirtualBase = false; + } /// Get the constructor that this expression will call. CXXConstructorDecl *getConstructor() const { return Constructor; } /// Determine whether this constructor is actually constructing /// a base class (rather than a complete object). - bool constructsVBase() const { return ConstructsVirtualBase; } + bool constructsVBase() const { + return CXXInheritedCtorInitExprBits.ConstructsVirtualBase; + } CXXConstructExpr::ConstructionKind getConstructionKind() const { - return ConstructsVirtualBase ? CXXConstructExpr::CK_VirtualBase - : CXXConstructExpr::CK_NonVirtualBase; + return CXXInheritedCtorInitExprBits.ConstructsVirtualBase + ? CXXConstructExpr::CK_VirtualBase + : CXXConstructExpr::CK_NonVirtualBase; } /// Determine whether the inherited constructor is inherited from a /// virtual base of the object we construct. If so, we are not responsible /// for calling the inherited constructor (the complete object constructor /// does that), and so we don't need to pass any arguments. - bool inheritedFromVBase() const { return InheritedFromVirtualBase; } + bool inheritedFromVBase() const { + return CXXInheritedCtorInitExprBits.InheritedFromVirtualBase; + } - SourceLocation getLocation() const LLVM_READONLY { return Loc; } - SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; } - SourceLocation getEndLoc() const LLVM_READONLY { return Loc; } + SourceLocation getLocation() const LLVM_READONLY { + return CXXInheritedCtorInitExprBits.Loc; + } + SourceLocation getBeginLoc() const LLVM_READONLY { + return CXXInheritedCtorInitExprBits.Loc; + } + SourceLocation getEndLoc() const LLVM_READONLY { + return CXXInheritedCtorInitExprBits.Loc; + } static bool classof(const Stmt *T) { return T->getStmtClass() == CXXInheritedCtorInitExprClass; @@ -2102,7 +2109,7 @@ SourceLocation RParenLoc) : Expr(CXXScalarValueInitExprClass, Type, VK_PRValue, OK_Ordinary), TypeInfo(TypeInfo) { - CXXScalarValueInitExprBits.RParenLoc = RParenLoc; + ExprWithSourceLocBits.Loc = RParenLoc; setDependence(computeDependence(this)); } @@ -2113,9 +2120,7 @@ return TypeInfo; } - SourceLocation getRParenLoc() const { - return CXXScalarValueInitExprBits.RParenLoc; - } + SourceLocation getRParenLoc() const { return ExprWithSourceLocBits.Loc; } SourceLocation getBeginLoc() const LLVM_READONLY; SourceLocation getEndLoc() const { return getRParenLoc(); } @@ -2537,13 +2542,6 @@ /// The base expression (that is being destroyed). Stmt *Base = nullptr; - /// Whether the operator was an arrow ('->'); otherwise, it was a - /// period ('.'). - bool IsArrow : 1; - - /// The location of the '.' or '->' operator. - SourceLocation OperatorLoc; - /// The nested-name-specifier that follows the operator, if present. NestedNameSpecifierLoc QualifierLoc; @@ -2572,7 +2570,9 @@ PseudoDestructorTypeStorage DestroyedType); explicit CXXPseudoDestructorExpr(EmptyShell Shell) - : Expr(CXXPseudoDestructorExprClass, Shell), IsArrow(false) {} + : Expr(CXXPseudoDestructorExprClass, Shell) { + CXXPseudoDestructorExprBits.IsArrow = false; + } Expr *getBase() const { return cast(Base); } @@ -2594,10 +2594,12 @@ /// Determine whether this pseudo-destructor expression was written /// using an '->' (otherwise, it used a '.'). - bool isArrow() const { return IsArrow; } + bool isArrow() const { return CXXPseudoDestructorExprBits.IsArrow; } /// Retrieve the location of the '.' or '->' operator. - SourceLocation getOperatorLoc() const { return OperatorLoc; } + SourceLocation getOperatorLoc() const { + return CXXPseudoDestructorExprBits.OperatorLoc; + } /// Retrieve the scope type in a qualified pseudo-destructor /// expression. @@ -2768,8 +2770,6 @@ /// __array_extent(int, 1) == 20 /// \endcode class ArrayTypeTraitExpr : public Expr { - /// The trait. An ArrayTypeTrait enum in MSVC compat unsigned. - unsigned ATT : 2; /// The value of the type trait. Unspecified if dependent. uint64_t Value = 0; @@ -2777,9 +2777,6 @@ /// The array dimension being queried, or -1 if not used. Expr *Dimension; - /// The location of the type trait keyword. - SourceLocation Loc; - /// The location of the closing paren. SourceLocation RParen; @@ -2792,21 +2789,30 @@ ArrayTypeTraitExpr(SourceLocation loc, ArrayTypeTrait att, TypeSourceInfo *queried, uint64_t value, Expr *dimension, SourceLocation rparen, QualType ty) - : Expr(ArrayTypeTraitExprClass, ty, VK_PRValue, OK_Ordinary), ATT(att), - Value(value), Dimension(dimension), Loc(loc), RParen(rparen), + : Expr(ArrayTypeTraitExprClass, ty, VK_PRValue, OK_Ordinary), + Value(value), Dimension(dimension), RParen(rparen), QueriedType(queried) { + ArrayTypeTraitExprBits.ATT = att; + ArrayTypeTraitExprBits.Loc = loc; assert(att <= ATT_Last && "invalid enum value!"); - assert(static_cast(att) == ATT && "ATT overflow!"); + assert(static_cast(att) == ArrayTypeTraitExprBits.ATT && + "ATT overflow!"); setDependence(computeDependence(this)); } explicit ArrayTypeTraitExpr(EmptyShell Empty) - : Expr(ArrayTypeTraitExprClass, Empty), ATT(0) {} + : Expr(ArrayTypeTraitExprClass, Empty) { + ArrayTypeTraitExprBits.ATT = 0; + } - SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return ArrayTypeTraitExprBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { return RParen; } - ArrayTypeTrait getTrait() const { return static_cast(ATT); } + ArrayTypeTrait getTrait() const { + return static_cast(ArrayTypeTraitExprBits.ATT); + } QualType getQueriedType() const { return QueriedType->getType(); } @@ -2839,13 +2845,7 @@ /// \endcode class ExpressionTraitExpr : public Expr { /// The trait. A ExpressionTrait enum in MSVC compatible unsigned. - unsigned ET : 31; - - /// The value of the type trait. Unspecified if dependent. - unsigned Value : 1; - - /// The location of the type trait keyword. - SourceLocation Loc; + unsigned ET; /// The location of the closing paren. SourceLocation RParen; @@ -2859,24 +2859,29 @@ ExpressionTraitExpr(SourceLocation loc, ExpressionTrait et, Expr *queried, bool value, SourceLocation rparen, QualType resultType) : Expr(ExpressionTraitExprClass, resultType, VK_PRValue, OK_Ordinary), - ET(et), Value(value), Loc(loc), RParen(rparen), - QueriedExpression(queried) { + ET(et), RParen(rparen), QueriedExpression(queried) { assert(et <= ET_Last && "invalid enum value!"); assert(static_cast(et) == ET && "ET overflow!"); + ExpressionTraitExprBits.Value = value; + ExpressionTraitExprBits.Loc = loc; setDependence(computeDependence(this)); } explicit ExpressionTraitExpr(EmptyShell Empty) - : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false) {} + : Expr(ExpressionTraitExprClass, Empty), ET(0) { + ExpressionTraitExprBits.Value = 0; + } - SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return ExpressionTraitExprBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { return RParen; } ExpressionTrait getTrait() const { return static_cast(ET); } Expr *getQueriedExpression() const { return QueriedExpression; } - bool getValue() const { return Value; } + bool getValue() const { return ExpressionTraitExprBits.Value; } static bool classof(const Stmt *T) { return T->getStmtClass() == ExpressionTraitExprClass; @@ -4015,14 +4020,15 @@ friend class ASTStmtReader; Stmt *Operand; - SourceRange Range; + SourceLocation RParenLoc; public: CXXNoexceptExpr(QualType Ty, Expr *Operand, CanThrowResult Val, SourceLocation Keyword, SourceLocation RParen) : Expr(CXXNoexceptExprClass, Ty, VK_PRValue, OK_Ordinary), - Operand(Operand), Range(Keyword, RParen) { + Operand(Operand), RParenLoc(RParen) { CXXNoexceptExprBits.Value = Val == CT_Cannot; + CXXNoexceptExprBits.KeywordLoc = Keyword; setDependence(computeDependence(this, Val)); } @@ -4030,9 +4036,11 @@ Expr *getOperand() const { return static_cast(Operand); } - SourceLocation getBeginLoc() const { return Range.getBegin(); } - SourceLocation getEndLoc() const { return Range.getEnd(); } - SourceRange getSourceRange() const { return Range; } + SourceLocation getBeginLoc() const { return CXXNoexceptExprBits.KeywordLoc; } + SourceLocation getEndLoc() const { return RParenLoc; } + SourceRange getSourceRange() const { + return {CXXNoexceptExprBits.KeywordLoc, RParenLoc}; + } bool getValue() const { return CXXNoexceptExprBits.Value; } @@ -4281,13 +4289,11 @@ Expr *Replacement) : Expr(SubstNonTypeTemplateParmExprClass, Ty, ValueKind, OK_Ordinary), ParamAndRef(Param, RefParam), Replacement(Replacement) { - SubstNonTypeTemplateParmExprBits.NameLoc = Loc; + ExprWithSourceLocBits.Loc = Loc; setDependence(computeDependence(this)); } - SourceLocation getNameLoc() const { - return SubstNonTypeTemplateParmExprBits.NameLoc; - } + SourceLocation getNameLoc() const { return ExprWithSourceLocBits.Loc; } SourceLocation getBeginLoc() const { return getNameLoc(); } SourceLocation getEndLoc() const { return getNameLoc(); } @@ -4594,14 +4600,12 @@ enum SubExpr { Callee, LHS, RHS, Count }; - SourceLocation LParenLoc; SourceLocation EllipsisLoc; SourceLocation RParenLoc; // When 0, the number of expansions is not known. Otherwise, this is one more // than the number of expansions. unsigned NumExpansions; Stmt *SubExprs[SubExpr::Count]; - BinaryOperatorKind Opcode; public: CXXFoldExpr(QualType T, UnresolvedLookupExpr *Callee, @@ -4609,8 +4613,10 @@ SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, Optional NumExpansions) : Expr(CXXFoldExprClass, T, VK_PRValue, OK_Ordinary), - LParenLoc(LParenLoc), EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc), - NumExpansions(NumExpansions ? *NumExpansions + 1 : 0), Opcode(Opcode) { + EllipsisLoc(EllipsisLoc), RParenLoc(RParenLoc), + NumExpansions(NumExpansions ? *NumExpansions + 1 : 0) { + CXXFoldExprBits.LParenLoc = LParenLoc; + CXXFoldExprBits.Opcode = Opcode; SubExprs[SubExpr::Callee] = Callee; SubExprs[SubExpr::LHS] = LHS; SubExprs[SubExpr::RHS] = RHS; @@ -4639,10 +4645,12 @@ /// Get the operand that doesn't contain a pack, for a binary fold. Expr *getInit() const { return isLeftFold() ? getLHS() : getRHS(); } - SourceLocation getLParenLoc() const { return LParenLoc; } + SourceLocation getLParenLoc() const { return CXXFoldExprBits.LParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getEllipsisLoc() const { return EllipsisLoc; } - BinaryOperatorKind getOperator() const { return Opcode; } + BinaryOperatorKind getOperator() const { + return BinaryOperatorKind(CXXFoldExprBits.Opcode); + } Optional getNumExpansions() const { if (NumExpansions) @@ -4651,8 +4659,8 @@ } SourceLocation getBeginLoc() const LLVM_READONLY { - if (LParenLoc.isValid()) - return LParenLoc; + if (CXXFoldExprBits.LParenLoc.isValid()) + return CXXFoldExprBits.LParenLoc; if (isLeftFold()) return getEllipsisLoc(); return getLHS()->getBeginLoc(); @@ -4696,8 +4704,6 @@ class CoroutineSuspendExpr : public Expr { friend class ASTStmtReader; - SourceLocation KeywordLoc; - enum SubExpr { Operand, Common, Ready, Suspend, Resume, Count }; Stmt *SubExprs[SubExpr::Count]; @@ -4709,7 +4715,8 @@ OpaqueValueExpr *OpaqueValue) : Expr(SC, Resume->getType(), Resume->getValueKind(), Resume->getObjectKind()), - KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) { + OpaqueValue(OpaqueValue) { + CoroutineSuspendExprBits.KeywordLoc = KeywordLoc; SubExprs[SubExpr::Operand] = Operand; SubExprs[SubExpr::Common] = Common; SubExprs[SubExpr::Ready] = Ready; @@ -4720,9 +4727,10 @@ CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, QualType Ty, Expr *Operand, Expr *Common) - : Expr(SC, Ty, VK_PRValue, OK_Ordinary), KeywordLoc(KeywordLoc) { + : Expr(SC, Ty, VK_PRValue, OK_Ordinary) { assert(Common->isTypeDependent() && Ty->isDependentType() && "wrong constructor for non-dependent co_await/co_yield expression"); + CoroutineSuspendExprBits.KeywordLoc = KeywordLoc; SubExprs[SubExpr::Operand] = Operand; SubExprs[SubExpr::Common] = Common; SubExprs[SubExpr::Ready] = nullptr; @@ -4763,9 +4771,13 @@ return static_cast(SubExprs[SubExpr::Operand]); } - SourceLocation getKeywordLoc() const { return KeywordLoc; } + SourceLocation getKeywordLoc() const { + return CoroutineSuspendExprBits.KeywordLoc; + } - SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return CoroutineSuspendExprBits.KeywordLoc; + } SourceLocation getEndLoc() const LLVM_READONLY { return getOperand()->getEndLoc(); @@ -4821,18 +4833,17 @@ class DependentCoawaitExpr : public Expr { friend class ASTStmtReader; - SourceLocation KeywordLoc; Stmt *SubExprs[2]; public: DependentCoawaitExpr(SourceLocation KeywordLoc, QualType Ty, Expr *Op, UnresolvedLookupExpr *OpCoawait) - : Expr(DependentCoawaitExprClass, Ty, VK_PRValue, OK_Ordinary), - KeywordLoc(KeywordLoc) { + : Expr(DependentCoawaitExprClass, Ty, VK_PRValue, OK_Ordinary) { // NOTE: A co_await expression is dependent on the coroutines promise // type and may be dependent even when the `Op` expression is not. assert(Ty->isDependentType() && "wrong constructor for non-dependent co_await/co_yield expression"); + ExprWithSourceLocBits.Loc = KeywordLoc; SubExprs[0] = Op; SubExprs[1] = OpCoawait; setDependence(computeDependence(this)); @@ -4847,9 +4858,11 @@ return cast(SubExprs[1]); } - SourceLocation getKeywordLoc() const { return KeywordLoc; } + SourceLocation getKeywordLoc() const { return ExprWithSourceLocBits.Loc; } - SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return ExprWithSourceLocBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { return getOperand()->getEndLoc(); diff --git a/clang/include/clang/AST/ExprObjC.h b/clang/include/clang/AST/ExprObjC.h --- a/clang/include/clang/AST/ExprObjC.h +++ b/clang/include/clang/AST/ExprObjC.h @@ -51,12 +51,11 @@ /// i.e. @"foo". class ObjCStringLiteral : public Expr { Stmt *String; - SourceLocation AtLoc; public: ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L) - : Expr(ObjCStringLiteralClass, T, VK_PRValue, OK_Ordinary), String(SL), - AtLoc(L) { + : Expr(ObjCStringLiteralClass, T, VK_PRValue, OK_Ordinary), String(SL) { + ExprWithSourceLocBits.Loc = L; setDependence(ExprDependence::None); } explicit ObjCStringLiteral(EmptyShell Empty) @@ -66,10 +65,12 @@ const StringLiteral *getString() const { return cast(String); } void setString(StringLiteral *S) { String = S; } - SourceLocation getAtLoc() const { return AtLoc; } - void setAtLoc(SourceLocation L) { AtLoc = L; } + SourceLocation getAtLoc() const { return ExprWithSourceLocBits.Loc; } + void setAtLoc(SourceLocation L) { ExprWithSourceLocBits.Loc = L; } - SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return ExprWithSourceLocBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { return String->getEndLoc(); } // Iterators @@ -86,26 +87,28 @@ /// ObjCBoolLiteralExpr - Objective-C Boolean Literal. class ObjCBoolLiteralExpr : public Expr { - bool Value; - SourceLocation Loc; - public: ObjCBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) - : Expr(ObjCBoolLiteralExprClass, Ty, VK_PRValue, OK_Ordinary), Value(val), - Loc(l) { + : Expr(ObjCBoolLiteralExprClass, Ty, VK_PRValue, OK_Ordinary) { + ObjCBoolLiteralExprBits.Value = val; + ObjCBoolLiteralExprBits.Loc = l; setDependence(ExprDependence::None); } explicit ObjCBoolLiteralExpr(EmptyShell Empty) : Expr(ObjCBoolLiteralExprClass, Empty) {} - bool getValue() const { return Value; } - void setValue(bool V) { Value = V; } + bool getValue() const { return ObjCBoolLiteralExprBits.Value; } + void setValue(bool V) { ObjCBoolLiteralExprBits.Value = V; } - SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; } - SourceLocation getEndLoc() const LLVM_READONLY { return Loc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return ObjCBoolLiteralExprBits.Loc; + } + SourceLocation getEndLoc() const LLVM_READONLY { + return ObjCBoolLiteralExprBits.Loc; + } - SourceLocation getLocation() const { return Loc; } - void setLocation(SourceLocation L) { Loc = L; } + SourceLocation getLocation() const { return ObjCBoolLiteralExprBits.Loc; } + void setLocation(SourceLocation L) { ObjCBoolLiteralExprBits.Loc = L; } // Iterators child_range children() { @@ -190,7 +193,6 @@ class ObjCArrayLiteral final : public Expr, private llvm::TrailingObjects { - unsigned NumElements; SourceRange Range; ObjCMethodDecl *ArrayWithObjectsMethod; @@ -199,7 +201,9 @@ SourceRange SR); explicit ObjCArrayLiteral(EmptyShell Empty, unsigned NumElements) - : Expr(ObjCArrayLiteralClass, Empty), NumElements(NumElements) {} + : Expr(ObjCArrayLiteralClass, Empty) { + ObjCArrayLiteralBits.NumElements = NumElements; + } public: friend class ASTStmtReader; @@ -226,15 +230,17 @@ } /// getNumElements - Return number of elements of objective-c array literal. - unsigned getNumElements() const { return NumElements; } + unsigned getNumElements() const { return ObjCArrayLiteralBits.NumElements; } /// getElement - Return the Element at the specified index. Expr *getElement(unsigned Index) { - assert((Index < NumElements) && "Arg access out of range!"); + assert((Index < ObjCArrayLiteralBits.NumElements) && + "Arg access out of range!"); return getElements()[Index]; } const Expr *getElement(unsigned Index) const { - assert((Index < NumElements) && "Arg access out of range!"); + assert((Index < ObjCArrayLiteralBits.NumElements) && + "Arg access out of range!"); return getElements()[Index]; } @@ -245,7 +251,8 @@ // Iterators child_range children() { return child_range(reinterpret_cast(getElements()), - reinterpret_cast(getElements()) + NumElements); + reinterpret_cast(getElements()) + + ObjCArrayLiteralBits.NumElements); } const_child_range children() const { @@ -308,17 +315,6 @@ private llvm::TrailingObjects { - /// The number of elements in this dictionary literal. - unsigned NumElements : 31; - - /// Determine whether this dictionary literal has any pack expansions. - /// - /// If the dictionary literal has pack expansions, then there will - /// be an array of pack expansion data following the array of - /// key/value pairs, which provide the locations of the ellipses (if - /// any) and number of elements in the expansion (if known). If - /// there are no pack expansions, we optimize away this storage. - unsigned HasPackExpansions : 1; SourceRange Range; ObjCMethodDecl *DictWithObjectsMethod; @@ -333,11 +329,13 @@ explicit ObjCDictionaryLiteral(EmptyShell Empty, unsigned NumElements, bool HasPackExpansions) - : Expr(ObjCDictionaryLiteralClass, Empty), NumElements(NumElements), - HasPackExpansions(HasPackExpansions) {} + : Expr(ObjCDictionaryLiteralClass, Empty) { + ObjCDictionaryLiteralBits.NumElements = NumElements; + ObjCDictionaryLiteralBits.HasPackExpansions = HasPackExpansions; + } size_t numTrailingObjects(OverloadToken) const { - return NumElements; + return ObjCDictionaryLiteralBits.NumElements; } public: @@ -357,13 +355,16 @@ /// getNumElements - Return number of elements of objective-c dictionary /// literal. - unsigned getNumElements() const { return NumElements; } + unsigned getNumElements() const { + return ObjCDictionaryLiteralBits.NumElements; + } ObjCDictionaryElement getKeyValueElement(unsigned Index) const { - assert((Index < NumElements) && "Arg access out of range!"); + assert((Index < ObjCDictionaryLiteralBits.NumElements) && + "Arg access out of range!"); const KeyValuePair &KV = getTrailingObjects()[Index]; ObjCDictionaryElement Result = { KV.Key, KV.Value, SourceLocation(), None }; - if (HasPackExpansions) { + if (ObjCDictionaryLiteralBits.HasPackExpansions) { const ExpansionData &Expansion = getTrailingObjects()[Index]; Result.EllipsisLoc = Expansion.EllipsisLoc; @@ -390,7 +391,7 @@ return child_range( reinterpret_cast(getTrailingObjects()), reinterpret_cast(getTrailingObjects()) + - NumElements * 2); + ObjCDictionaryLiteralBits.NumElements * 2); } const_child_range children() const { @@ -503,7 +504,7 @@ /// The return type is "Protocol*". class ObjCProtocolExpr : public Expr { ObjCProtocolDecl *TheProtocol; - SourceLocation AtLoc, ProtoLoc, RParenLoc; + SourceLocation ProtoLoc, RParenLoc; public: friend class ASTStmtReader; @@ -512,7 +513,8 @@ ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol, SourceLocation at, SourceLocation protoLoc, SourceLocation rp) : Expr(ObjCProtocolExprClass, T, VK_PRValue, OK_Ordinary), - TheProtocol(protocol), AtLoc(at), ProtoLoc(protoLoc), RParenLoc(rp) { + TheProtocol(protocol), ProtoLoc(protoLoc), RParenLoc(rp) { + ExprWithSourceLocBits.Loc = at; setDependence(ExprDependence::None); } explicit ObjCProtocolExpr(EmptyShell Empty) @@ -522,12 +524,14 @@ void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; } SourceLocation getProtocolIdLoc() const { return ProtoLoc; } - SourceLocation getAtLoc() const { return AtLoc; } + SourceLocation getAtLoc() const { return ExprWithSourceLocBits.Loc; } SourceLocation getRParenLoc() const { return RParenLoc; } - void setAtLoc(SourceLocation L) { AtLoc = L; } + void setAtLoc(SourceLocation L) { ExprWithSourceLocBits.Loc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return ExprWithSourceLocBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; } // Iterators @@ -548,25 +552,20 @@ class ObjCIvarRefExpr : public Expr { ObjCIvarDecl *D; Stmt *Base; - SourceLocation Loc; /// OpLoc - This is the location of '.' or '->' SourceLocation OpLoc; - // True if this is "X->F", false if this is "X.F". - bool IsArrow : 1; - - // True if ivar reference has no base (self assumed). - bool IsFreeIvar : 1; - public: ObjCIvarRefExpr(ObjCIvarDecl *d, QualType t, SourceLocation l, SourceLocation oploc, Expr *base, bool arrow = false, bool freeIvar = false) : Expr(ObjCIvarRefExprClass, t, VK_LValue, d->isBitField() ? OK_BitField : OK_Ordinary), - D(d), Base(base), Loc(l), OpLoc(oploc), IsArrow(arrow), - IsFreeIvar(freeIvar) { + D(d), Base(base), OpLoc(oploc) { + ObjCIvarRefExprBits.Loc = l; + ObjCIvarRefExprBits.IsArrow = arrow; + ObjCIvarRefExprBits.IsFreeIvar = freeIvar; setDependence(computeDependence(this)); } @@ -581,18 +580,20 @@ Expr *getBase() { return cast(Base); } void setBase(Expr * base) { Base = base; } - bool isArrow() const { return IsArrow; } - bool isFreeIvar() const { return IsFreeIvar; } - void setIsArrow(bool A) { IsArrow = A; } - void setIsFreeIvar(bool A) { IsFreeIvar = A; } + bool isArrow() const { return ObjCIvarRefExprBits.IsArrow; } + bool isFreeIvar() const { return ObjCIvarRefExprBits.IsFreeIvar; } + void setIsArrow(bool A) { ObjCIvarRefExprBits.IsArrow = A; } + void setIsFreeIvar(bool A) { ObjCIvarRefExprBits.IsFreeIvar = A; } - SourceLocation getLocation() const { return Loc; } - void setLocation(SourceLocation L) { Loc = L; } + SourceLocation getLocation() const { return ObjCIvarRefExprBits.Loc; } + void setLocation(SourceLocation L) { ObjCIvarRefExprBits.Loc = L; } SourceLocation getBeginLoc() const LLVM_READONLY { - return isFreeIvar() ? Loc : getBase()->getBeginLoc(); + return isFreeIvar() ? ObjCIvarRefExprBits.Loc : getBase()->getBeginLoc(); + } + SourceLocation getEndLoc() const LLVM_READONLY { + return ObjCIvarRefExprBits.Loc; } - SourceLocation getEndLoc() const LLVM_READONLY { return Loc; } SourceLocation getOpLoc() const { return OpLoc; } void setOpLoc(SourceLocation L) { OpLoc = L; } @@ -839,9 +840,6 @@ /// ObjCSubscriptRefExpr - used for array and dictionary subscripting. /// array[4] = array[3]; dictionary[key] = dictionary[alt_key]; class ObjCSubscriptRefExpr : public Expr { - // Location of ']' in an indexing expression. - SourceLocation RBracket; - // array/dictionary base expression. // for arrays, this is a numeric expression. For dictionaries, this is // an objective-c object pointer expression. @@ -858,8 +856,9 @@ ObjCSubscriptRefExpr(Expr *base, Expr *key, QualType T, ExprValueKind VK, ExprObjectKind OK, ObjCMethodDecl *getMethod, ObjCMethodDecl *setMethod, SourceLocation RB) - : Expr(ObjCSubscriptRefExprClass, T, VK, OK), RBracket(RB), + : Expr(ObjCSubscriptRefExprClass, T, VK, OK), GetAtIndexMethodDecl(getMethod), SetAtIndexMethodDecl(setMethod) { + ExprWithSourceLocBits.Loc = RB; SubExprs[BASE] = base; SubExprs[KEY] = key; setDependence(computeDependence(this)); @@ -868,14 +867,16 @@ explicit ObjCSubscriptRefExpr(EmptyShell Empty) : Expr(ObjCSubscriptRefExprClass, Empty) {} - SourceLocation getRBracket() const { return RBracket; } - void setRBracket(SourceLocation RB) { RBracket = RB; } + SourceLocation getRBracket() const { return ExprWithSourceLocBits.Loc; } + void setRBracket(SourceLocation RB) { ExprWithSourceLocBits.Loc = RB; } SourceLocation getBeginLoc() const LLVM_READONLY { return SubExprs[BASE]->getBeginLoc(); } - SourceLocation getEndLoc() const LLVM_READONLY { return RBracket; } + SourceLocation getEndLoc() const LLVM_READONLY { + return ExprWithSourceLocBits.Loc; + } Expr *getBaseExpr() const { return cast(SubExprs[BASE]); } void setBaseExpr(Stmt *S) { SubExprs[BASE] = S; } @@ -1483,20 +1484,16 @@ /// Base - the expression for the base object pointer. Stmt *Base; - /// IsaMemberLoc - This is the location of the 'isa'. - SourceLocation IsaMemberLoc; - /// OpLoc - This is the location of '.' or '->' SourceLocation OpLoc; - /// IsArrow - True if this is "X->F", false if this is "X.F". - bool IsArrow; - public: ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, SourceLocation oploc, QualType ty) : Expr(ObjCIsaExprClass, ty, VK_LValue, OK_Ordinary), Base(base), - IsaMemberLoc(l), OpLoc(oploc), IsArrow(isarrow) { + OpLoc(oploc) { + ObjCIsaExprBits.IsArrow = isarrow; + ObjCIsaExprBits.IsaMemberLoc = l; setDependence(computeDependence(this)); } @@ -1506,13 +1503,15 @@ void setBase(Expr *E) { Base = E; } Expr *getBase() const { return cast(Base); } - bool isArrow() const { return IsArrow; } - void setArrow(bool A) { IsArrow = A; } + bool isArrow() const { return ObjCIsaExprBits.IsArrow; } + void setArrow(bool A) { ObjCIsaExprBits.IsArrow = A; } /// getMemberLoc - Return the location of the "member", in X->F, it is the /// location of 'F'. - SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; } - void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; } + SourceLocation getIsaMemberLoc() const { + return ObjCIsaExprBits.IsaMemberLoc; + } + void setIsaMemberLoc(SourceLocation L) { ObjCIsaExprBits.IsaMemberLoc = L; } SourceLocation getOpLoc() const { return OpLoc; } void setOpLoc(SourceLocation L) { OpLoc = L; } @@ -1525,9 +1524,13 @@ return getBase()->getEndLoc(); } - SourceLocation getEndLoc() const LLVM_READONLY { return IsaMemberLoc; } + SourceLocation getEndLoc() const LLVM_READONLY { + return ObjCIsaExprBits.IsaMemberLoc; + } - SourceLocation getExprLoc() const LLVM_READONLY { return IsaMemberLoc; } + SourceLocation getExprLoc() const LLVM_READONLY { + return ObjCIsaExprBits.IsaMemberLoc; + } // Iterators child_range children() { return child_range(&Base, &Base+1); } @@ -1632,7 +1635,6 @@ SourceLocation LParenLoc; SourceLocation BridgeKeywordLoc; - unsigned Kind : 2; public: ObjCBridgedCastExpr(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, @@ -1640,7 +1642,9 @@ TypeSourceInfo *TSInfo, Expr *Operand) : ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(), VK_PRValue, CK, Operand, 0, false, TSInfo), - LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc), Kind(Kind) {} + LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc) { + ObjCBridgedCastExprBits.Kind = Kind; + } /// Construct an empty Objective-C bridged cast. explicit ObjCBridgedCastExpr(EmptyShell Shell) @@ -1650,7 +1654,7 @@ /// Determine which kind of bridge is being performed via this cast. ObjCBridgeCastKind getBridgeKind() const { - return static_cast(Kind); + return static_cast(ObjCBridgedCastExprBits.Kind); } /// Retrieve the kind of bridge being performed as a string. diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -104,6 +104,30 @@ }; enum { NumStmtBits = 8 }; + class StmtWithSourceLocBitfields { + friend class ASTStmtReader; + friend class SEHExceptStmt; + friend class SEHFinallyStmt; + friend class SEHLeaveStmt; + friend class CXXCatchStmt; + friend class CXXForRangeStmt; + friend class ObjCAtFinallyStmt; + friend class ObjCAtSynchronizedStmt; + friend class ObjCAtThrowStmt; + friend class ObjCAutoreleasePoolStmt; + friend class ForStmt; + friend class DoStmt; + friend class BreakStmt; + friend class ContinueStmt; + friend class GotoStmt; + friend class IndirectGotoStmt; + + unsigned : NumStmtBits; + unsigned : 32 - NumStmtBits; + + SourceLocation Loc; + }; + class NullStmtBitfields { friend class ASTStmtReader; friend class ASTStmtWriter; @@ -139,6 +163,8 @@ unsigned : NumStmtBits; + unsigned SideEntry : 1; + SourceLocation IdentLoc; }; @@ -210,76 +236,132 @@ SourceLocation WhileLoc; }; - class DoStmtBitfields { - friend class DoStmt; + class ReturnStmtBitfields { + friend class ReturnStmt; unsigned : NumStmtBits; - /// The location of the "do". - SourceLocation DoLoc; + /// True if this ReturnStmt has storage for an NRVO candidate. + unsigned HasNRVOCandidate : 1; + + /// The location of the "return". + SourceLocation RetLoc; }; - class ForStmtBitfields { - friend class ForStmt; + class SwitchCaseBitfields { + friend class SwitchCase; + friend class CaseStmt; unsigned : NumStmtBits; - /// The location of the "for". - SourceLocation ForLoc; + /// Used by CaseStmt to store whether it is a case statement + /// of the form case LHS ... RHS (a GNU extension). + unsigned CaseStmtIsGNURange : 1; + + /// The location of the "case" or "default" keyword. + SourceLocation KeywordLoc; }; - class GotoStmtBitfields { - friend class GotoStmt; - friend class IndirectGotoStmt; + class AsmStmtBitfields { + friend class ASTStmtReader; + friend class AsmStmt; + friend class GCCAsmStmt; + friend class MSAsmStmt; unsigned : NumStmtBits; - /// The location of the "goto". - SourceLocation GotoLoc; + /// True if the assembly statement does not have any input or output + /// operands. + unsigned IsSimple : 1; + + /// If true, treat this inline assembly as having side effects. + /// This assembly statement should not be optimized, deleted or moved. + unsigned IsVolatile : 1; + + // Padding so that NumOutputs in aligned to 16 bytes for faster access + unsigned : 16 - 2 - NumStmtBits; + + unsigned NumOutputs : 16; + + SourceLocation AsmLoc; }; - class ContinueStmtBitfields { - friend class ContinueStmt; + class SEHTryStmtBitfields { + friend class ASTStmtReader; + friend class SEHTryStmt; unsigned : NumStmtBits; - /// The location of the "continue". - SourceLocation ContinueLoc; + unsigned IsCXXTry : 1; + SourceLocation TryLoc; }; - class BreakStmtBitfields { - friend class BreakStmt; + class CapturedStmtBitfields { + friend class ASTStmtReader; + friend class CapturedStmt; unsigned : NumStmtBits; + /// The number of variable captured, including 'this'. + unsigned NumCaptures; + }; - /// The location of the "break". - SourceLocation BreakLoc; + //===--- C++ Statement bitfields classes ---===// + + class CXXTryStmtBitfields { + friend class ASTStmtReader; + friend class CXXTryStmt; + + unsigned : NumStmtBits; + unsigned NumHandlers : 32 - NumStmtBits; + SourceLocation TryLoc; }; - class ReturnStmtBitfields { - friend class ReturnStmt; + class MSDependentExistsStmtBitfields { + friend class ASTStmtReader; + friend class MSDependentExistsStmt; unsigned : NumStmtBits; + unsigned IsIfExists : 1; + SourceLocation KeywordLoc; + }; - /// True if this ReturnStmt has storage for an NRVO candidate. - unsigned HasNRVOCandidate : 1; + class CoroutineBodyStmtBitfields { + friend class ASTStmtReader; + friend class CoroutineBodyStmt; - /// The location of the "return". - SourceLocation RetLoc; + unsigned : NumStmtBits; + unsigned : 32 - NumStmtBits; + unsigned NumParams; }; - class SwitchCaseBitfields { - friend class SwitchCase; - friend class CaseStmt; + class CoreturnStmtBitfields { + friend class ASTStmtReader; + friend class CoreturnStmt; unsigned : NumStmtBits; + unsigned IsImplicit : 1; + SourceLocation CoreturnLoc; + }; - /// Used by CaseStmt to store whether it is a case statement - /// of the form case LHS ... RHS (a GNU extension). - unsigned CaseStmtIsGNURange : 1; + //===--- ObjC Statement bitfields classes ---===// - /// The location of the "case" or "default" keyword. - SourceLocation KeywordLoc; + class ObjCAtTryStmtBitfields { + friend class ASTStmtReader; + friend class ObjCAtTryStmt; + + unsigned : NumStmtBits; + + // Whether this statement has a \@finally statement. + unsigned HasFinally : 1; + + // Pad out so NumCatchStmts is on a 16bit boundary. + unsigned : 16 - NumStmtBits - 1; + + // The number of catch blocks in this statement. + unsigned NumCatchStmts : 16; + + // The location of the @ in the \@try. + SourceLocation AtTryLoc; }; //===--- Expression bitfields classes ---===// @@ -316,6 +398,43 @@ }; enum { NumExprBits = NumStmtBits + 5 + llvm::BitWidth }; + /// A few Expr nodes only contain a \c SourceLocation that can be pulled into + /// the bitfield. This just saves having to create a new Bitfield for each of + /// those nodes. + class ExprWithSourceLocBitFields { + friend class ASTStmtReader; + friend class SYCLUniqueStableNameExpr; + friend class ParenExpr; + friend class AddrLabelExpr; + friend class AbstractConditionalOperator; + friend class GNUNullExpr; + friend class ExtVectorElementExpr; + friend class TypoExpr; + friend class DependentCoawaitExpr; + friend class MSPropertySubscriptExpr; + friend class ObjCStringLiteral; + friend class ObjCProtocolExpr; + friend class ObjCSubscriptRefExpr; + friend class ArraySubscriptExpr; + friend class MatrixSubscriptExpr; + friend class ASTStmtReader; + friend class SubstNonTypeTemplateParmExpr; + friend class ASTStmtReader; + friend class CXXScalarValueInitExpr; + friend class ASTStmtReader; + friend class CXXDefaultInitExpr; + friend class CompoundLiteralExpr; + friend class ASTStmtReader; + friend class CXXDefaultArgExpr; + friend class CXXNullPtrLiteralExpr; + friend class ASTStmtReader; + friend class GenericSelectionExpr; + + unsigned : NumExprBits; + unsigned : 32 - NumExprBits; + SourceLocation Loc; + }; + class ConstantExprBitfields { friend class ASTStmtReader; friend class ASTStmtWriter; @@ -389,6 +508,18 @@ unsigned Semantics : 3; // Provides semantics for APFloat construction unsigned IsExact : 1; + + SourceLocation Loc; + }; + + class FixedPointLiteralBitfields { + friend class FixedPointLiteral; + + unsigned : NumExprBits; + + unsigned Scale : 8; + + SourceLocation Loc; }; class StringLiteralBitfields { @@ -419,6 +550,8 @@ unsigned : NumExprBits; unsigned Kind : 3; + + unsigned Value; }; class UnaryOperatorBitfields { @@ -437,6 +570,15 @@ SourceLocation Loc; }; + class OffsetOfExprBitfields { + friend class OffsetOfExpr; + + unsigned : NumExprBits; + unsigned : 32 - NumExprBits; + unsigned NumComps : 16; + unsigned NumExprs : 16; + }; + class UnaryExprOrTypeTraitExprBitfields { friend class UnaryExprOrTypeTraitExpr; @@ -444,15 +586,8 @@ unsigned Kind : 3; unsigned IsType : 1; // true if operand is a type, false if an expression. - }; - class ArrayOrMatrixSubscriptExprBitfields { - friend class ArraySubscriptExpr; - friend class MatrixSubscriptExpr; - - unsigned : NumExprBits; - - SourceLocation RBracketLoc; + SourceLocation OpLoc; }; class CallExprBitfields { @@ -525,11 +660,18 @@ /// True if the call expression has some floating-point features. unsigned HasFPFeatures : 1; + /// Padding used by the derived classes to store various bits. If you + /// need to add some data here, shrink this padding and add your data + /// above. NumCastExprBits also needs to be updated. + unsigned : 32 - NumExprBits - 7 - 1 - 1; + /// The number of CXXBaseSpecifiers in the cast. 14 bits would be enough /// here. ([implimits] Direct and indirect base classes [16384]). unsigned BasePathSize; }; + enum { NumCastExprBits = NumExprBits + 7 + 1 + 1 }; + class BinaryOperatorBitfields { friend class BinaryOperator; @@ -545,6 +687,14 @@ SourceLocation OpLoc; }; + class ShuffleVectorExprBitfields { + friend class ShuffleVectorExpr; + + unsigned : NumExprBits; + + unsigned NumExprs; + }; + class InitListExprBitfields { friend class InitListExpr; @@ -553,6 +703,8 @@ /// Whether this initializer list originally had a GNU array-range /// designator in it. This is a temporary marker used by CodeGen. unsigned HadArrayRangeDesignator : 1; + + SourceLocation LBraceLoc; }; class ParenListExprBitfields { @@ -565,16 +717,6 @@ unsigned NumExprs; }; - class GenericSelectionExprBitfields { - friend class ASTStmtReader; - friend class GenericSelectionExpr; - - unsigned : NumExprBits; - - /// The location of the "_Generic". - SourceLocation GenericLoc; - }; - class PseudoObjectExprBitfields { friend class ASTStmtReader; // deserialization friend class PseudoObjectExpr; @@ -594,8 +736,51 @@ unsigned : NumExprBits; /// The kind of source location builtin represented by the SourceLocExpr. - /// Ex. __builtin_LINE, __builtin_FUNCTION, etc. + /// Ex. __builtin_LINE, __builtin_FUNCTION, ect. unsigned Kind : 3; + + SourceLocation BuiltinLoc; + }; + + class DesignatedInitExprBitfields { + friend class ASTStmtReader; + friend class DesignatedInitExpr; + + unsigned : NumExprBits; + + /// Whether this designated initializer used the GNU deprecated + /// syntax rather than the C99 '=' syntax. + unsigned GNUSyntax : 1; + + /// The number of designators in this initializer expression. + unsigned NumDesignators : 15; + + /// The number of subexpressions of this initializer expression, + /// which contains both the initializer and any additional + /// expressions used by array and array-range designators. + unsigned NumSubExprs : 16; + }; + + class AtomicExprBitfields { + friend class ASTStmtReader; + friend class AtomicExpr; + + unsigned : NumExprBits; + + unsigned Op : 6; + + unsigned NumSubExprs; + }; + + class RecoveryExprBitfields { + friend class ASTStmtReader; + friend class RecoveryExpr; + + unsigned : NumExprBits; + + unsigned NumExprs : 32 - NumExprBits; + + SourceLocation BeginLoc; }; class StmtExprBitfields { @@ -610,6 +795,15 @@ unsigned TemplateDepth; }; + class ChooseExprBitfields { + friend class ASTStmtReader; + friend class ChooseExpr; + + unsigned : NumExprBits; + unsigned CondIsTrue : 1; + SourceLocation BuiltinLoc; + }; + //===--- C++ Expression bitfields classes ---===// class CXXOperatorCallExprBitfields { @@ -644,13 +838,14 @@ SourceLocation Loc; }; - class CXXNullPtrLiteralExprBitfields { - friend class CXXNullPtrLiteralExpr; + class MSPropertyRefExprBitfields { + friend class ASTStmtReader; + friend class MSPropertyRefExpr; unsigned : NumExprBits; - /// The location of the null pointer literal. - SourceLocation Loc; + unsigned IsArrow : 1; + SourceLocation MemberLoc; }; class CXXThisExprBitfields { @@ -678,35 +873,6 @@ SourceLocation ThrowLoc; }; - class CXXDefaultArgExprBitfields { - friend class ASTStmtReader; - friend class CXXDefaultArgExpr; - - unsigned : NumExprBits; - - /// The location where the default argument expression was used. - SourceLocation Loc; - }; - - class CXXDefaultInitExprBitfields { - friend class ASTStmtReader; - friend class CXXDefaultInitExpr; - - unsigned : NumExprBits; - - /// The location where the default initializer expression was used. - SourceLocation Loc; - }; - - class CXXScalarValueInitExprBitfields { - friend class ASTStmtReader; - friend class CXXScalarValueInitExpr; - - unsigned : NumExprBits; - - SourceLocation RParenLoc; - }; - class CXXNewExprBitfields { friend class ASTStmtReader; friend class ASTStmtWriter; @@ -765,6 +931,20 @@ SourceLocation Loc; }; + class CXXPseudoDestructorExprBitfields { + friend class ASTStmtReader; + friend class CXXPseudoDestructorExpr; + + unsigned : NumExprBits; + + /// Whether the operator was an arrow ('->'); otherwise, it was a + /// period ('.'). + unsigned IsArrow : 1; + + /// The location of the '.' or '->' operator. + SourceLocation OperatorLoc; + }; + class TypeTraitExprBitfields { friend class ASTStmtReader; friend class ASTStmtWriter; @@ -785,6 +965,30 @@ unsigned NumArgs; }; + class ArrayTypeTraitExprBitfields { + friend class ASTStmtReader; + friend class ArrayTypeTraitExpr; + + unsigned : NumExprBits; + + /// The trait. An ArrayTypeTrait enum in MSVC compat unsigned. + unsigned ATT : 2; + /// The location of the type trait keyword. + SourceLocation Loc; + }; + + class ExpressionTraitExprBitfields { + friend class ASTStmtReader; + friend class ExpressionTraitExpr; + + unsigned : NumExprBits; + /// The value of the type trait. Unspecified if dependent. + unsigned Value : 1; + + /// The location of the type trait keyword. + SourceLocation Loc; + }; + class DependentScopeDeclRefExprBitfields { friend class ASTStmtReader; friend class ASTStmtWriter; @@ -813,6 +1017,22 @@ SourceLocation Loc; }; + class CXXInheritedCtorInitExprBitfields { + friend class ASTStmtReader; + friend class CXXInheritedCtorInitExpr; + unsigned : NumExprBits; + + /// Whether this is the construction of a virtual base. + unsigned ConstructsVirtualBase : 1; + + /// Whether the constructor is inherited from a virtual base class of the + /// class that we construct. + unsigned InheritedFromVirtualBase : 1; + + /// The location of the using declaration. + SourceLocation Loc; + }; + class ExprWithCleanupsBitfields { friend class ASTStmtReader; // deserialization friend class ExprWithCleanups; @@ -919,16 +1139,8 @@ unsigned : NumExprBits; unsigned Value : 1; - }; - class SubstNonTypeTemplateParmExprBitfields { - friend class ASTStmtReader; - friend class SubstNonTypeTemplateParmExpr; - - unsigned : NumExprBits; - - /// The location of the non-type template parameter reference. - SourceLocation NameLoc; + SourceLocation KeywordLoc; }; class LambdaExprBitfields { @@ -953,6 +1165,15 @@ unsigned NumCaptures : 16; }; + class CXXFoldExprBitfields { + friend class ASTStmtReader; + friend class CXXFoldExpr; + + unsigned : NumExprBits; + unsigned Opcode : 6; + SourceLocation LParenLoc; + }; + class RequiresExprBitfields { friend class ASTStmtReader; friend class ASTStmtWriter; @@ -966,14 +1187,31 @@ //===--- C++ Coroutines TS bitfields classes ---===// + class CoroutineSuspendExprBitfields { + friend class CoroutineSuspendExpr; + friend class ASTStmtReader; + + unsigned : NumExprBits; + + unsigned : 32 - NumExprBits; + + SourceLocation KeywordLoc; + }; + + enum { NumCoroutineSuspendExprBits = NumExprBits }; + class CoawaitExprBitfields { friend class CoawaitExpr; - unsigned : NumExprBits; + unsigned : NumCoroutineSuspendExprBits; unsigned IsImplicit : 1; }; + static_assert(sizeof(CoawaitExprBitfields) <= 4, + "CoawaitExprBitfields must be <= than 4 bytes to" + "avoid trashing CoroutineSuspendExprBitfields::KeywordLoc!"); + //===--- Obj-C Expression bitfields classes ---===// class ObjCIndirectCopyRestoreExprBitfields { @@ -984,6 +1222,82 @@ unsigned ShouldCopy : 1; }; + class ObjCBoolLiteralExprBitfields { + friend class ObjCBoolLiteralExpr; + + unsigned : NumExprBits; + + unsigned Value : 1; + SourceLocation Loc; + }; + + class ObjCArrayLiteralBitfields { + friend class ObjCArrayLiteral; + + unsigned : NumExprBits; + + unsigned NumElements; + }; + + class ObjCDictionaryLiteralBitfields { + friend class ASTStmtReader; + friend class ASTStmtWriter; + friend class ObjCDictionaryLiteral; + + unsigned : NumExprBits; + + /// Determine whether this dictionary literal has any pack expansions. + /// + /// If the dictionary literal has pack expansions, then there will + /// be an array of pack expansion data following the array of + /// key/value pairs, which provide the locations of the ellipses (if + /// any) and number of elements in the expansion (if known). If + /// there are no pack expansions, we optimize away this storage. + unsigned HasPackExpansions : 1; + + /// The number of elements in this dictionary literal. + unsigned NumElements; + }; + + class ObjCIvarRefExprBitfields { + friend class ObjCIvarRefExpr; + + unsigned : NumExprBits; + + // True if this is "X->F", false if this is "X.F". + unsigned IsArrow : 1; + + // True if ivar reference has no base (self assumed). + unsigned IsFreeIvar : 1; + + SourceLocation Loc; + }; + + class ObjCIsaExprBitfields { + friend class ObjCIsaExpr; + + unsigned : NumExprBits; + + /// IsArrow - True if this is "X->F", false if this is "X.F". + unsigned IsArrow : 1; + + /// IsaMemberLoc - This is the location of the 'isa'. + SourceLocation IsaMemberLoc; + }; + + class ObjCBridgedCastExprBitfields { + friend class ASTStmtReader; + friend class ObjCBridgedCastExpr; + + unsigned : NumCastExprBits; + + unsigned Kind : 2; + }; + + static_assert(sizeof(ObjCBridgedCastExprBitfields) <= 4, + "ObjCBridgedCastExprBitfields must be <= than 4 bytes to" + "avoid trashing CastExprBitfields::BasePathSize!"); + //===--- Clang Extensions bitfields classes ---===// class OpaqueValueExprBitfields { @@ -1003,6 +1317,7 @@ // Same order as in StmtNodes.td. // Statements StmtBitfields StmtBits; + StmtWithSourceLocBitfields StmtWithSourceLocBits; NullStmtBitfields NullStmtBits; CompoundStmtBitfields CompoundStmtBits; LabelStmtBitfields LabelStmtBits; @@ -1010,53 +1325,67 @@ IfStmtBitfields IfStmtBits; SwitchStmtBitfields SwitchStmtBits; WhileStmtBitfields WhileStmtBits; - DoStmtBitfields DoStmtBits; - ForStmtBitfields ForStmtBits; - GotoStmtBitfields GotoStmtBits; - ContinueStmtBitfields ContinueStmtBits; - BreakStmtBitfields BreakStmtBits; ReturnStmtBitfields ReturnStmtBits; SwitchCaseBitfields SwitchCaseBits; + AsmStmtBitfields AsmStmtBits; + SEHTryStmtBitfields SEHTryStmtBits; + CapturedStmtBitfields CapturedStmtBits; + + // C++ Statements + CXXTryStmtBitfields CXXTryStmtBits; + MSDependentExistsStmtBitfields MSDependentExistsStmtBits; + CoroutineBodyStmtBitfields CoroutineBodyStmtBits; + CoreturnStmtBitfields CoreturnStmtBits; + + // ObjC Statements + ObjCAtTryStmtBitfields ObjCAtTryStmtBits; // Expressions ExprBitfields ExprBits; + ExprWithSourceLocBitFields ExprWithSourceLocBits; ConstantExprBitfields ConstantExprBits; PredefinedExprBitfields PredefinedExprBits; DeclRefExprBitfields DeclRefExprBits; FloatingLiteralBitfields FloatingLiteralBits; + FixedPointLiteralBitfields FixedPointLiteralBits; StringLiteralBitfields StringLiteralBits; CharacterLiteralBitfields CharacterLiteralBits; UnaryOperatorBitfields UnaryOperatorBits; + OffsetOfExprBitfields OffsetOfExprBits; UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits; - ArrayOrMatrixSubscriptExprBitfields ArrayOrMatrixSubscriptExprBits; CallExprBitfields CallExprBits; MemberExprBitfields MemberExprBits; CastExprBitfields CastExprBits; BinaryOperatorBitfields BinaryOperatorBits; + ShuffleVectorExprBitfields ShuffleVectorExprBits; InitListExprBitfields InitListExprBits; ParenListExprBitfields ParenListExprBits; - GenericSelectionExprBitfields GenericSelectionExprBits; PseudoObjectExprBitfields PseudoObjectExprBits; SourceLocExprBitfields SourceLocExprBits; + DesignatedInitExprBitfields DesignatedInitExprBits; + AtomicExprBitfields AtomicExprBits; + RecoveryExprBitfields RecoveryExprBits; // GNU Extensions. StmtExprBitfields StmtExprBits; + ChooseExprBitfields ChooseExprBits; // C++ Expressions CXXOperatorCallExprBitfields CXXOperatorCallExprBits; CXXRewrittenBinaryOperatorBitfields CXXRewrittenBinaryOperatorBits; CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits; - CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits; + MSPropertyRefExprBitfields MSPropertyRefExprBits; CXXThisExprBitfields CXXThisExprBits; CXXThrowExprBitfields CXXThrowExprBits; - CXXDefaultArgExprBitfields CXXDefaultArgExprBits; - CXXDefaultInitExprBitfields CXXDefaultInitExprBits; - CXXScalarValueInitExprBitfields CXXScalarValueInitExprBits; CXXNewExprBitfields CXXNewExprBits; CXXDeleteExprBitfields CXXDeleteExprBits; + CXXPseudoDestructorExprBitfields CXXPseudoDestructorExprBits; TypeTraitExprBitfields TypeTraitExprBits; + ArrayTypeTraitExprBitfields ArrayTypeTraitExprBits; + ExpressionTraitExprBitfields ExpressionTraitExprBits; DependentScopeDeclRefExprBitfields DependentScopeDeclRefExprBits; CXXConstructExprBitfields CXXConstructExprBits; + CXXInheritedCtorInitExprBitfields CXXInheritedCtorInitExprBits; ExprWithCleanupsBitfields ExprWithCleanupsBits; CXXUnresolvedConstructExprBitfields CXXUnresolvedConstructExprBits; CXXDependentScopeMemberExprBitfields CXXDependentScopeMemberExprBits; @@ -1064,15 +1393,22 @@ UnresolvedLookupExprBitfields UnresolvedLookupExprBits; UnresolvedMemberExprBitfields UnresolvedMemberExprBits; CXXNoexceptExprBitfields CXXNoexceptExprBits; - SubstNonTypeTemplateParmExprBitfields SubstNonTypeTemplateParmExprBits; LambdaExprBitfields LambdaExprBits; + CXXFoldExprBitfields CXXFoldExprBits; RequiresExprBitfields RequiresExprBits; // C++ Coroutines TS expressions + CoroutineSuspendExprBitfields CoroutineSuspendExprBits; CoawaitExprBitfields CoawaitBits; // Obj-C Expressions ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits; + ObjCBoolLiteralExprBitfields ObjCBoolLiteralExprBits; + ObjCArrayLiteralBitfields ObjCArrayLiteralBits; + ObjCDictionaryLiteralBitfields ObjCDictionaryLiteralBits; + ObjCIvarRefExprBitfields ObjCIvarRefExprBits; + ObjCIsaExprBitfields ObjCIsaExprBits; + ObjCBridgedCastExprBitfields ObjCBridgedCastExprBits; // Clang Extensions OpaqueValueExprBitfields OpaqueValueExprBits; @@ -1804,12 +2140,12 @@ class LabelStmt : public ValueStmt { LabelDecl *TheDecl; Stmt *SubStmt; - bool SideEntry = false; public: /// Build a label statement. LabelStmt(SourceLocation IL, LabelDecl *D, Stmt *substmt) : ValueStmt(LabelStmtClass), TheDecl(D), SubStmt(substmt) { + LabelStmtBits.SideEntry = false; setIdentLoc(IL); } @@ -1840,8 +2176,8 @@ static bool classof(const Stmt *T) { return T->getStmtClass() == LabelStmtClass; } - bool isSideEntry() const { return SideEntry; } - void setSideEntry(bool SE) { SideEntry = SE; } + bool isSideEntry() const { return LabelStmtBits.SideEntry; } + void setSideEntry(bool SE) { LabelStmtBits.SideEntry = SE; } }; /// Represents an attribute applied to a statement. @@ -2509,8 +2845,8 @@ const Stmt *getBody() const { return SubExprs[BODY]; } void setBody(Stmt *Body) { SubExprs[BODY] = Body; } - SourceLocation getDoLoc() const { return DoStmtBits.DoLoc; } - void setDoLoc(SourceLocation L) { DoStmtBits.DoLoc = L; } + SourceLocation getDoLoc() const { return StmtWithSourceLocBits.Loc; } + void setDoLoc(SourceLocation L) { StmtWithSourceLocBits.Loc = L; } SourceLocation getWhileLoc() const { return WhileLoc; } void setWhileLoc(SourceLocation L) { WhileLoc = L; } SourceLocation getRParenLoc() const { return RParenLoc; } @@ -2582,8 +2918,8 @@ void setInc(Expr *E) { SubExprs[INC] = reinterpret_cast(E); } void setBody(Stmt *S) { SubExprs[BODY] = S; } - SourceLocation getForLoc() const { return ForStmtBits.ForLoc; } - void setForLoc(SourceLocation L) { ForStmtBits.ForLoc = L; } + SourceLocation getForLoc() const { return StmtWithSourceLocBits.Loc; } + void setForLoc(SourceLocation L) { StmtWithSourceLocBits.Loc = L; } SourceLocation getLParenLoc() const { return LParenLoc; } void setLParenLoc(SourceLocation L) { LParenLoc = L; } SourceLocation getRParenLoc() const { return RParenLoc; } @@ -2623,8 +2959,8 @@ LabelDecl *getLabel() const { return Label; } void setLabel(LabelDecl *D) { Label = D; } - SourceLocation getGotoLoc() const { return GotoStmtBits.GotoLoc; } - void setGotoLoc(SourceLocation L) { GotoStmtBits.GotoLoc = L; } + SourceLocation getGotoLoc() const { return StmtWithSourceLocBits.Loc; } + void setGotoLoc(SourceLocation L) { StmtWithSourceLocBits.Loc = L; } SourceLocation getLabelLoc() const { return LabelLoc; } void setLabelLoc(SourceLocation L) { LabelLoc = L; } @@ -2661,8 +2997,8 @@ explicit IndirectGotoStmt(EmptyShell Empty) : Stmt(IndirectGotoStmtClass, Empty) {} - void setGotoLoc(SourceLocation L) { GotoStmtBits.GotoLoc = L; } - SourceLocation getGotoLoc() const { return GotoStmtBits.GotoLoc; } + void setGotoLoc(SourceLocation L) { StmtWithSourceLocBits.Loc = L; } + SourceLocation getGotoLoc() const { return StmtWithSourceLocBits.Loc; } void setStarLoc(SourceLocation L) { StarLoc = L; } SourceLocation getStarLoc() const { return StarLoc; } @@ -2704,8 +3040,8 @@ /// Build an empty continue statement. explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) {} - SourceLocation getContinueLoc() const { return ContinueStmtBits.ContinueLoc; } - void setContinueLoc(SourceLocation L) { ContinueStmtBits.ContinueLoc = L; } + SourceLocation getContinueLoc() const { return StmtWithSourceLocBits.Loc; } + void setContinueLoc(SourceLocation L) { StmtWithSourceLocBits.Loc = L; } SourceLocation getBeginLoc() const { return getContinueLoc(); } SourceLocation getEndLoc() const { return getContinueLoc(); } @@ -2734,8 +3070,8 @@ /// Build an empty break statement. explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) {} - SourceLocation getBreakLoc() const { return BreakStmtBits.BreakLoc; } - void setBreakLoc(SourceLocation L) { BreakStmtBits.BreakLoc = L; } + SourceLocation getBreakLoc() const { return StmtWithSourceLocBits.Loc; } + void setBreakLoc(SourceLocation L) { StmtWithSourceLocBits.Loc = L; } SourceLocation getBeginLoc() const { return getBreakLoc(); } SourceLocation getEndLoc() const { return getBreakLoc(); } @@ -2849,17 +3185,6 @@ protected: friend class ASTStmtReader; - SourceLocation AsmLoc; - - /// True if the assembly statement does not have any input or output - /// operands. - bool IsSimple; - - /// If true, treat this inline assembly as having side effects. - /// This assembly statement should not be optimized, deleted or moved. - bool IsVolatile; - - unsigned NumOutputs; unsigned NumInputs; unsigned NumClobbers; @@ -2867,22 +3192,25 @@ AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile, unsigned numoutputs, unsigned numinputs, unsigned numclobbers) - : Stmt (SC), AsmLoc(asmloc), IsSimple(issimple), IsVolatile(isvolatile), - NumOutputs(numoutputs), NumInputs(numinputs), - NumClobbers(numclobbers) {} + : Stmt(SC), NumInputs(numinputs), NumClobbers(numclobbers) { + AsmStmtBits.AsmLoc = asmloc; + AsmStmtBits.IsSimple = issimple; + AsmStmtBits.IsVolatile = isvolatile; + AsmStmtBits.NumOutputs = numoutputs; + } public: /// Build an empty inline-assembly statement. explicit AsmStmt(StmtClass SC, EmptyShell Empty) : Stmt(SC, Empty) {} - SourceLocation getAsmLoc() const { return AsmLoc; } - void setAsmLoc(SourceLocation L) { AsmLoc = L; } + SourceLocation getAsmLoc() const { return AsmStmtBits.AsmLoc; } + void setAsmLoc(SourceLocation L) { AsmStmtBits.AsmLoc = L; } - bool isSimple() const { return IsSimple; } - void setSimple(bool V) { IsSimple = V; } + bool isSimple() const { return AsmStmtBits.IsSimple; } + void setSimple(bool V) { AsmStmtBits.IsSimple = V; } - bool isVolatile() const { return IsVolatile; } - void setVolatile(bool V) { IsVolatile = V; } + bool isVolatile() const { return AsmStmtBits.IsVolatile; } + void setVolatile(bool V) { AsmStmtBits.IsVolatile = V; } SourceLocation getBeginLoc() const LLVM_READONLY { return {}; } SourceLocation getEndLoc() const LLVM_READONLY { return {}; } @@ -2894,7 +3222,7 @@ //===--- Output operands ---===// - unsigned getNumOutputs() const { return NumOutputs; } + unsigned getNumOutputs() const { return AsmStmtBits.NumOutputs; } /// getOutputConstraint - Return the constraint string for the specified /// output operand. All output constraints are known to be non-empty (either @@ -2941,22 +3269,20 @@ using inputs_range = llvm::iterator_range; using inputs_const_range = llvm::iterator_range; - inputs_iterator begin_inputs() { - return &Exprs[0] + NumOutputs; - } + inputs_iterator begin_inputs() { return &Exprs[0] + AsmStmtBits.NumOutputs; } inputs_iterator end_inputs() { - return &Exprs[0] + NumOutputs + NumInputs; + return &Exprs[0] + AsmStmtBits.NumOutputs + NumInputs; } inputs_range inputs() { return inputs_range(begin_inputs(), end_inputs()); } const_inputs_iterator begin_inputs() const { - return &Exprs[0] + NumOutputs; + return &Exprs[0] + AsmStmtBits.NumOutputs; } const_inputs_iterator end_inputs() const { - return &Exprs[0] + NumOutputs + NumInputs; + return &Exprs[0] + AsmStmtBits.NumOutputs + NumInputs; } inputs_const_range inputs() const { @@ -2974,9 +3300,7 @@ return &Exprs[0]; } - outputs_iterator end_outputs() { - return &Exprs[0] + NumOutputs; - } + outputs_iterator end_outputs() { return &Exprs[0] + AsmStmtBits.NumOutputs; } outputs_range outputs() { return outputs_range(begin_outputs(), end_outputs()); @@ -2987,7 +3311,7 @@ } const_outputs_iterator end_outputs() const { - return &Exprs[0] + NumOutputs; + return &Exprs[0] + AsmStmtBits.NumOutputs; } outputs_const_range outputs() const { @@ -2995,11 +3319,13 @@ } child_range children() { - return child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs); + return child_range(&Exprs[0], + &Exprs[0] + AsmStmtBits.NumOutputs + NumInputs); } const_child_range children() const { - return const_child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs); + return const_child_range(&Exprs[0], + &Exprs[0] + AsmStmtBits.NumOutputs + NumInputs); } }; @@ -3121,7 +3447,7 @@ //===--- Input operands ---===// IdentifierInfo *getInputIdentifier(unsigned i) const { - return Names[i + NumOutputs]; + return Names[i + AsmStmtBits.NumOutputs]; } StringRef getInputName(unsigned i) const { @@ -3134,10 +3460,10 @@ StringRef getInputConstraint(unsigned i) const; const StringLiteral *getInputConstraintLiteral(unsigned i) const { - return Constraints[i + NumOutputs]; + return Constraints[i + AsmStmtBits.NumOutputs]; } StringLiteral *getInputConstraintLiteral(unsigned i) { - return Constraints[i + NumOutputs]; + return Constraints[i + AsmStmtBits.NumOutputs]; } Expr *getInputExpr(unsigned i); @@ -3158,7 +3484,7 @@ } IdentifierInfo *getLabelIdentifier(unsigned i) const { - return Names[i + NumOutputs + NumInputs]; + return Names[i + AsmStmtBits.NumOutputs + NumInputs]; } AddrLabelExpr *getLabelExpr(unsigned i) const; @@ -3169,11 +3495,11 @@ using labels_const_range = llvm::iterator_range; labels_iterator begin_labels() { - return &Exprs[0] + NumOutputs + NumInputs; + return &Exprs[0] + AsmStmtBits.NumOutputs + NumInputs; } labels_iterator end_labels() { - return &Exprs[0] + NumOutputs + NumInputs + NumLabels; + return &Exprs[0] + AsmStmtBits.NumOutputs + NumInputs + NumLabels; } labels_range labels() { @@ -3181,11 +3507,11 @@ } const_labels_iterator begin_labels() const { - return &Exprs[0] + NumOutputs + NumInputs; + return &Exprs[0] + AsmStmtBits.NumOutputs + NumInputs; } const_labels_iterator end_labels() const { - return &Exprs[0] + NumOutputs + NumInputs + NumLabels; + return &Exprs[0] + AsmStmtBits.NumOutputs + NumInputs + NumLabels; } labels_const_range labels() const { @@ -3218,7 +3544,9 @@ return Clobbers[i]; } - SourceLocation getBeginLoc() const LLVM_READONLY { return AsmLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return AsmStmtBits.AsmLoc; + } SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; } static bool classof(const Stmt *T) { @@ -3269,7 +3597,7 @@ //===--- Output operands ---===// StringRef getOutputConstraint(unsigned i) const { - assert(i < NumOutputs); + assert(i < AsmStmtBits.NumOutputs); return Constraints[i]; } @@ -3283,7 +3611,7 @@ StringRef getInputConstraint(unsigned i) const { assert(i < NumInputs); - return Constraints[i + NumOutputs]; + return Constraints[i + AsmStmtBits.NumOutputs]; } Expr *getInputExpr(unsigned i); @@ -3296,7 +3624,7 @@ //===--- Other ---===// ArrayRef getAllConstraints() const { - return llvm::makeArrayRef(Constraints, NumInputs + NumOutputs); + return llvm::makeArrayRef(Constraints, NumInputs + AsmStmtBits.NumOutputs); } ArrayRef getClobbers() const { @@ -3304,8 +3632,8 @@ } ArrayRef getAllExprs() const { - return llvm::makeArrayRef(reinterpret_cast(Exprs), - NumInputs + NumOutputs); + return llvm::makeArrayRef(reinterpret_cast(Exprs), + NumInputs + AsmStmtBits.NumOutputs); } StringRef getClobber(unsigned i) const { return getClobbers()[i]; } @@ -3316,18 +3644,21 @@ ArrayRef Exprs, ArrayRef Clobbers); public: - SourceLocation getBeginLoc() const LLVM_READONLY { return AsmLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return AsmStmtBits.AsmLoc; + } static bool classof(const Stmt *T) { return T->getStmtClass() == MSAsmStmtClass; } child_range children() { - return child_range(&Exprs[0], &Exprs[NumInputs + NumOutputs]); + return child_range(&Exprs[0], &Exprs[NumInputs + AsmStmtBits.NumOutputs]); } const_child_range children() const { - return const_child_range(&Exprs[0], &Exprs[NumInputs + NumOutputs]); + return const_child_range(&Exprs[0], + &Exprs[NumInputs + AsmStmtBits.NumOutputs]); } }; @@ -3335,7 +3666,6 @@ friend class ASTReader; friend class ASTStmtReader; - SourceLocation Loc; Stmt *Children[2]; enum { FILTER_EXPR, BLOCK }; @@ -3351,7 +3681,7 @@ SourceLocation getBeginLoc() const LLVM_READONLY { return getExceptLoc(); } - SourceLocation getExceptLoc() const { return Loc; } + SourceLocation getExceptLoc() const { return StmtWithSourceLocBits.Loc; } SourceLocation getEndLoc() const { return getBlock()->getEndLoc(); } Expr *getFilterExpr() const { @@ -3379,7 +3709,6 @@ friend class ASTReader; friend class ASTStmtReader; - SourceLocation Loc; Stmt *Block; SEHFinallyStmt(SourceLocation Loc, Stmt *Block); @@ -3392,7 +3721,7 @@ SourceLocation getBeginLoc() const LLVM_READONLY { return getFinallyLoc(); } - SourceLocation getFinallyLoc() const { return Loc; } + SourceLocation getFinallyLoc() const { return StmtWithSourceLocBits.Loc; } SourceLocation getEndLoc() const { return Block->getEndLoc(); } CompoundStmt *getBlock() const { return cast(Block); } @@ -3414,8 +3743,6 @@ friend class ASTReader; friend class ASTStmtReader; - bool IsCXXTry; - SourceLocation TryLoc; Stmt *Children[2]; enum { TRY = 0, HANDLER = 1 }; @@ -3434,10 +3761,10 @@ SourceLocation getBeginLoc() const LLVM_READONLY { return getTryLoc(); } - SourceLocation getTryLoc() const { return TryLoc; } + SourceLocation getTryLoc() const { return SEHTryStmtBits.TryLoc; } SourceLocation getEndLoc() const { return Children[HANDLER]->getEndLoc(); } - bool getIsCXXTry() const { return IsCXXTry; } + bool getIsCXXTry() const { return SEHTryStmtBits.IsCXXTry; } CompoundStmt* getTryBlock() const { return cast(Children[TRY]); @@ -3464,20 +3791,23 @@ /// Represents a __leave statement. class SEHLeaveStmt : public Stmt { - SourceLocation LeaveLoc; - public: - explicit SEHLeaveStmt(SourceLocation LL) - : Stmt(SEHLeaveStmtClass), LeaveLoc(LL) {} + explicit SEHLeaveStmt(SourceLocation LL) : Stmt(SEHLeaveStmtClass) { + StmtWithSourceLocBits.Loc = LL; + } /// Build an empty __leave statement. explicit SEHLeaveStmt(EmptyShell Empty) : Stmt(SEHLeaveStmtClass, Empty) {} - SourceLocation getLeaveLoc() const { return LeaveLoc; } - void setLeaveLoc(SourceLocation L) { LeaveLoc = L; } + SourceLocation getLeaveLoc() const { return StmtWithSourceLocBits.Loc; } + void setLeaveLoc(SourceLocation L) { StmtWithSourceLocBits.Loc = L; } - SourceLocation getBeginLoc() const LLVM_READONLY { return LeaveLoc; } - SourceLocation getEndLoc() const LLVM_READONLY { return LeaveLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return StmtWithSourceLocBits.Loc; + } + SourceLocation getEndLoc() const LLVM_READONLY { + return StmtWithSourceLocBits.Loc; + } static bool classof(const Stmt *T) { return T->getStmtClass() == SEHLeaveStmtClass; @@ -3563,9 +3893,6 @@ }; private: - /// The number of variable captured, including 'this'. - unsigned NumCaptures; - /// The pointer part is the implicit the outlined function and the /// int part is the captured region kind, 'CR_Default' etc. llvm::PointerIntPair CapDeclAndKind; @@ -3588,7 +3915,9 @@ Capture *getStoredCaptures() const; - void setCapturedStmt(Stmt *S) { getStoredStmts()[NumCaptures] = S; } + void setCapturedStmt(Stmt *S) { + getStoredStmts()[CapturedStmtBits.NumCaptures] = S; + } public: friend class ASTStmtReader; @@ -3603,8 +3932,12 @@ unsigned NumCaptures); /// Retrieve the statement being captured. - Stmt *getCapturedStmt() { return getStoredStmts()[NumCaptures]; } - const Stmt *getCapturedStmt() const { return getStoredStmts()[NumCaptures]; } + Stmt *getCapturedStmt() { + return getStoredStmts()[CapturedStmtBits.NumCaptures]; + } + const Stmt *getCapturedStmt() const { + return getStoredStmts()[CapturedStmtBits.NumCaptures]; + } /// Retrieve the outlined function declaration. CapturedDecl *getCapturedDecl(); @@ -3651,11 +3984,11 @@ /// Retrieve an iterator pointing past the end of the sequence of /// captures. capture_iterator capture_end() const { - return getStoredCaptures() + NumCaptures; + return getStoredCaptures() + CapturedStmtBits.NumCaptures; } /// Retrieve the number of captures, including 'this'. - unsigned capture_size() const { return NumCaptures; } + unsigned capture_size() const { return CapturedStmtBits.NumCaptures; } /// Iterator that walks over the capture initialization arguments. using capture_init_iterator = Expr **; @@ -3687,11 +4020,11 @@ /// Retrieve the iterator pointing one past the last initialization /// argument. capture_init_iterator capture_init_end() { - return capture_init_begin() + NumCaptures; + return capture_init_begin() + CapturedStmtBits.NumCaptures; } const_capture_init_iterator capture_init_end() const { - return capture_init_begin() + NumCaptures; + return capture_init_begin() + CapturedStmtBits.NumCaptures; } SourceLocation getBeginLoc() const LLVM_READONLY { diff --git a/clang/include/clang/AST/StmtCXX.h b/clang/include/clang/AST/StmtCXX.h --- a/clang/include/clang/AST/StmtCXX.h +++ b/clang/include/clang/AST/StmtCXX.h @@ -26,7 +26,6 @@ /// CXXCatchStmt - This represents a C++ catch block. /// class CXXCatchStmt : public Stmt { - SourceLocation CatchLoc; /// The exception-declaration of the type. VarDecl *ExceptionDecl; /// The handler block. @@ -34,18 +33,22 @@ public: CXXCatchStmt(SourceLocation catchLoc, VarDecl *exDecl, Stmt *handlerBlock) - : Stmt(CXXCatchStmtClass), CatchLoc(catchLoc), ExceptionDecl(exDecl), - HandlerBlock(handlerBlock) {} + : Stmt(CXXCatchStmtClass), ExceptionDecl(exDecl), + HandlerBlock(handlerBlock) { + StmtWithSourceLocBits.Loc = catchLoc; + } CXXCatchStmt(EmptyShell Empty) : Stmt(CXXCatchStmtClass), ExceptionDecl(nullptr), HandlerBlock(nullptr) {} - SourceLocation getBeginLoc() const LLVM_READONLY { return CatchLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return StmtWithSourceLocBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { return HandlerBlock->getEndLoc(); } - SourceLocation getCatchLoc() const { return CatchLoc; } + SourceLocation getCatchLoc() const { return StmtWithSourceLocBits.Loc; } VarDecl *getExceptionDecl() const { return ExceptionDecl; } QualType getCaughtType() const; Stmt *getHandlerBlock() const { return HandlerBlock; } @@ -71,13 +74,14 @@ friend TrailingObjects; friend class ASTStmtReader; - SourceLocation TryLoc; - unsigned NumHandlers; - size_t numTrailingObjects(OverloadToken) const { return NumHandlers; } + size_t numTrailingObjects(OverloadToken) const { + return CXXTryStmtBits.NumHandlers; + } CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock, ArrayRef handlers); - CXXTryStmt(EmptyShell Empty, unsigned numHandlers) - : Stmt(CXXTryStmtClass), NumHandlers(numHandlers) { } + CXXTryStmt(EmptyShell Empty, unsigned numHandlers) : Stmt(CXXTryStmtClass) { + CXXTryStmtBits.NumHandlers = numHandlers; + } Stmt *const *getStmts() const { return getTrailingObjects(); } Stmt **getStmts() { return getTrailingObjects(); } @@ -91,9 +95,9 @@ SourceLocation getBeginLoc() const LLVM_READONLY { return getTryLoc(); } - SourceLocation getTryLoc() const { return TryLoc; } + SourceLocation getTryLoc() const { return CXXTryStmtBits.TryLoc; } SourceLocation getEndLoc() const { - return getStmts()[NumHandlers]->getEndLoc(); + return getStmts()[CXXTryStmtBits.NumHandlers]->getEndLoc(); } CompoundStmt *getTryBlock() { @@ -103,7 +107,7 @@ return cast(getStmts()[0]); } - unsigned getNumHandlers() const { return NumHandlers; } + unsigned getNumHandlers() const { return CXXTryStmtBits.NumHandlers; } CXXCatchStmt *getHandler(unsigned i) { return cast(getStmts()[i + 1]); } @@ -132,7 +136,6 @@ /// analysis of the constituent components. The original syntactic components /// can be extracted using getLoopVariable and getRangeInit. class CXXForRangeStmt : public Stmt { - SourceLocation ForLoc; enum { INIT, RANGE, BEGINSTMT, ENDSTMT, COND, INC, LOOPVAR, BODY, END }; // SubExprs[RANGE] is an expression or declstmt. // SubExprs[COND] and SubExprs[INC] are expressions. @@ -198,12 +201,14 @@ void setLoopVarStmt(Stmt *S) { SubExprs[LOOPVAR] = S; } void setBody(Stmt *S) { SubExprs[BODY] = S; } - SourceLocation getForLoc() const { return ForLoc; } + SourceLocation getForLoc() const { return StmtWithSourceLocBits.Loc; } SourceLocation getCoawaitLoc() const { return CoawaitLoc; } SourceLocation getColonLoc() const { return ColonLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } - SourceLocation getBeginLoc() const LLVM_READONLY { return ForLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return StmtWithSourceLocBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { return SubExprs[BODY]->getEndLoc(); } @@ -250,8 +255,7 @@ /// Visual C++ (which never introduces a scope), but is a fairly reasonable /// approximation of the VC++ behavior. class MSDependentExistsStmt : public Stmt { - SourceLocation KeywordLoc; - bool IsIfExists; + NestedNameSpecifierLoc QualifierLoc; DeclarationNameInfo NameInfo; Stmt *SubStmt; @@ -262,22 +266,24 @@ public: MSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, - DeclarationNameInfo NameInfo, - CompoundStmt *SubStmt) - : Stmt(MSDependentExistsStmtClass), - KeywordLoc(KeywordLoc), IsIfExists(IsIfExists), - QualifierLoc(QualifierLoc), NameInfo(NameInfo), - SubStmt(reinterpret_cast(SubStmt)) { } + DeclarationNameInfo NameInfo, CompoundStmt *SubStmt) + : Stmt(MSDependentExistsStmtClass), QualifierLoc(QualifierLoc), + NameInfo(NameInfo), SubStmt(reinterpret_cast(SubStmt)) { + MSDependentExistsStmtBits.KeywordLoc = KeywordLoc; + MSDependentExistsStmtBits.IsIfExists = IsIfExists; + } /// Retrieve the location of the __if_exists or __if_not_exists /// keyword. - SourceLocation getKeywordLoc() const { return KeywordLoc; } + SourceLocation getKeywordLoc() const { + return MSDependentExistsStmtBits.KeywordLoc; + } /// Determine whether this is an __if_exists statement. - bool isIfExists() const { return IsIfExists; } + bool isIfExists() const { return MSDependentExistsStmtBits.IsIfExists; } /// Determine whether this is an __if_exists statement. - bool isIfNotExists() const { return !IsIfExists; } + bool isIfNotExists() const { return !MSDependentExistsStmtBits.IsIfExists; } /// Retrieve the nested-name-specifier that qualifies this name, if /// any. @@ -293,7 +299,9 @@ return reinterpret_cast(SubStmt); } - SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return MSDependentExistsStmtBits.KeywordLoc; + } SourceLocation getEndLoc() const LLVM_READONLY { return SubStmt->getEndLoc(); } @@ -331,7 +339,6 @@ ReturnStmtOnAllocFailure, ///< Return statement if allocation failed. FirstParamMove ///< First offset for move construction of parameter copies. }; - unsigned NumParams; friend class ASTStmtReader; friend class ASTReader; @@ -417,7 +424,8 @@ return getStoredStmts()[SubStmt::ReturnStmtOnAllocFailure]; } ArrayRef getParamMoves() const { - return {getStoredStmts() + SubStmt::FirstParamMove, NumParams}; + return {getStoredStmts() + SubStmt::FirstParamMove, + CoroutineBodyStmtBits.NumParams}; } SourceLocation getBeginLoc() const LLVM_READONLY { @@ -429,14 +437,15 @@ } child_range children() { - return child_range(getStoredStmts(), - getStoredStmts() + SubStmt::FirstParamMove + NumParams); + return child_range(getStoredStmts(), getStoredStmts() + + SubStmt::FirstParamMove + + CoroutineBodyStmtBits.NumParams); } const_child_range children() const { - return const_child_range(getStoredStmts(), getStoredStmts() + - SubStmt::FirstParamMove + - NumParams); + return const_child_range(getStoredStmts(), + getStoredStmts() + SubStmt::FirstParamMove + + CoroutineBodyStmtBits.NumParams); } static bool classof(const Stmt *T) { @@ -456,26 +465,24 @@ /// .return_void() /// which we name the "promise call". class CoreturnStmt : public Stmt { - SourceLocation CoreturnLoc; enum SubStmt { Operand, PromiseCall, Count }; Stmt *SubStmts[SubStmt::Count]; - bool IsImplicit : 1; - friend class ASTStmtReader; public: CoreturnStmt(SourceLocation CoreturnLoc, Stmt *Operand, Stmt *PromiseCall, bool IsImplicit = false) - : Stmt(CoreturnStmtClass), CoreturnLoc(CoreturnLoc), - IsImplicit(IsImplicit) { + : Stmt(CoreturnStmtClass) { + CoreturnStmtBits.CoreturnLoc = CoreturnLoc; + CoreturnStmtBits.IsImplicit = IsImplicit; SubStmts[SubStmt::Operand] = Operand; SubStmts[SubStmt::PromiseCall] = PromiseCall; } CoreturnStmt(EmptyShell) : CoreturnStmt({}, {}, {}) {} - SourceLocation getKeywordLoc() const { return CoreturnLoc; } + SourceLocation getKeywordLoc() const { return CoreturnStmtBits.CoreturnLoc; } /// Retrieve the operand of the 'co_return' statement. Will be nullptr /// if none was specified. @@ -488,10 +495,12 @@ return static_cast(SubStmts[PromiseCall]); } - bool isImplicit() const { return IsImplicit; } - void setIsImplicit(bool value = true) { IsImplicit = value; } + bool isImplicit() const { return CoreturnStmtBits.IsImplicit; } + void setIsImplicit(bool value = true) { CoreturnStmtBits.IsImplicit = value; } - SourceLocation getBeginLoc() const LLVM_READONLY { return CoreturnLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return CoreturnStmtBits.CoreturnLoc; + } SourceLocation getEndLoc() const LLVM_READONLY { return getOperand() ? getOperand()->getEndLoc() : getBeginLoc(); } diff --git a/clang/include/clang/AST/StmtObjC.h b/clang/include/clang/AST/StmtObjC.h --- a/clang/include/clang/AST/StmtObjC.h +++ b/clang/include/clang/AST/StmtObjC.h @@ -125,13 +125,13 @@ /// Represents Objective-C's \@finally statement class ObjCAtFinallyStmt : public Stmt { - SourceLocation AtFinallyLoc; Stmt *AtFinallyStmt; public: ObjCAtFinallyStmt(SourceLocation atFinallyLoc, Stmt *atFinallyStmt) - : Stmt(ObjCAtFinallyStmtClass), AtFinallyLoc(atFinallyLoc), - AtFinallyStmt(atFinallyStmt) {} + : Stmt(ObjCAtFinallyStmtClass), AtFinallyStmt(atFinallyStmt) { + StmtWithSourceLocBits.Loc = atFinallyLoc; + } explicit ObjCAtFinallyStmt(EmptyShell Empty) : Stmt(ObjCAtFinallyStmtClass, Empty) { } @@ -140,13 +140,15 @@ Stmt *getFinallyBody() { return AtFinallyStmt; } void setFinallyBody(Stmt *S) { AtFinallyStmt = S; } - SourceLocation getBeginLoc() const LLVM_READONLY { return AtFinallyLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return StmtWithSourceLocBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { return AtFinallyStmt->getEndLoc(); } - SourceLocation getAtFinallyLoc() const { return AtFinallyLoc; } - void setAtFinallyLoc(SourceLocation Loc) { AtFinallyLoc = Loc; } + SourceLocation getAtFinallyLoc() const { return StmtWithSourceLocBits.Loc; } + void setAtFinallyLoc(SourceLocation Loc) { StmtWithSourceLocBits.Loc = Loc; } static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCAtFinallyStmtClass; @@ -167,18 +169,9 @@ private llvm::TrailingObjects { friend TrailingObjects; size_t numTrailingObjects(OverloadToken) const { - return 1 + NumCatchStmts + HasFinally; + return 1 + ObjCAtTryStmtBits.NumCatchStmts + ObjCAtTryStmtBits.HasFinally; } - // The location of the @ in the \@try. - SourceLocation AtTryLoc; - - // The number of catch blocks in this statement. - unsigned NumCatchStmts : 16; - - // Whether this statement has a \@finally statement. - bool HasFinally : 1; - /// Retrieve the statements that are stored after this \@try statement. /// /// The order of the statements in memory follows the order in the source, @@ -193,8 +186,10 @@ explicit ObjCAtTryStmt(EmptyShell Empty, unsigned NumCatchStmts, bool HasFinally) - : Stmt(ObjCAtTryStmtClass, Empty), NumCatchStmts(NumCatchStmts), - HasFinally(HasFinally) { } + : Stmt(ObjCAtTryStmtClass, Empty) { + ObjCAtTryStmtBits.NumCatchStmts = NumCatchStmts; + ObjCAtTryStmtBits.HasFinally = HasFinally; + } public: static ObjCAtTryStmt *Create(const ASTContext &Context, @@ -205,8 +200,8 @@ unsigned NumCatchStmts, bool HasFinally); /// Retrieve the location of the @ in the \@try. - SourceLocation getAtTryLoc() const { return AtTryLoc; } - void setAtTryLoc(SourceLocation Loc) { AtTryLoc = Loc; } + SourceLocation getAtTryLoc() const { return ObjCAtTryStmtBits.AtTryLoc; } + void setAtTryLoc(SourceLocation Loc) { ObjCAtTryStmtBits.AtTryLoc = Loc; } /// Retrieve the \@try body. const Stmt *getTryBody() const { return getStmts()[0]; } @@ -215,45 +210,50 @@ /// Retrieve the number of \@catch statements in this try-catch-finally /// block. - unsigned getNumCatchStmts() const { return NumCatchStmts; } + unsigned getNumCatchStmts() const { return ObjCAtTryStmtBits.NumCatchStmts; } /// Retrieve a \@catch statement. const ObjCAtCatchStmt *getCatchStmt(unsigned I) const { - assert(I < NumCatchStmts && "Out-of-bounds @catch index"); + assert(I < ObjCAtTryStmtBits.NumCatchStmts && "Out-of-bounds @catch index"); return cast_or_null(getStmts()[I + 1]); } /// Retrieve a \@catch statement. ObjCAtCatchStmt *getCatchStmt(unsigned I) { - assert(I < NumCatchStmts && "Out-of-bounds @catch index"); + assert(I < ObjCAtTryStmtBits.NumCatchStmts && "Out-of-bounds @catch index"); return cast_or_null(getStmts()[I + 1]); } /// Set a particular catch statement. void setCatchStmt(unsigned I, ObjCAtCatchStmt *S) { - assert(I < NumCatchStmts && "Out-of-bounds @catch index"); + assert(I < ObjCAtTryStmtBits.NumCatchStmts && "Out-of-bounds @catch index"); getStmts()[I + 1] = S; } /// Retrieve the \@finally statement, if any. const ObjCAtFinallyStmt *getFinallyStmt() const { - if (!HasFinally) + if (!ObjCAtTryStmtBits.HasFinally) return nullptr; - return cast_or_null(getStmts()[1 + NumCatchStmts]); + return cast_or_null( + getStmts()[1 + ObjCAtTryStmtBits.NumCatchStmts]); } ObjCAtFinallyStmt *getFinallyStmt() { - if (!HasFinally) + if (!ObjCAtTryStmtBits.HasFinally) return nullptr; - return cast_or_null(getStmts()[1 + NumCatchStmts]); + return cast_or_null( + getStmts()[1 + ObjCAtTryStmtBits.NumCatchStmts]); } void setFinallyStmt(Stmt *S) { - assert(HasFinally && "@try does not have a @finally slot!"); - getStmts()[1 + NumCatchStmts] = S; + assert(ObjCAtTryStmtBits.HasFinally && + "@try does not have a @finally slot!"); + getStmts()[1 + ObjCAtTryStmtBits.NumCatchStmts] = S; } - SourceLocation getBeginLoc() const LLVM_READONLY { return AtTryLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return ObjCAtTryStmtBits.AtTryLoc; + } SourceLocation getEndLoc() const LLVM_READONLY; static bool classof(const Stmt *T) { @@ -276,7 +276,7 @@ catch_stmt_iterator catch_stmts_begin() { return getStmts() + 1; } catch_stmt_iterator catch_stmts_end() { - return catch_stmts_begin() + NumCatchStmts; + return catch_stmts_begin() + ObjCAtTryStmtBits.NumCatchStmts; } catch_range catch_stmts() { return catch_range(catch_stmts_begin(), catch_stmts_end()); @@ -284,7 +284,7 @@ const_catch_stmt_iterator catch_stmts_begin() const { return getStmts() + 1; } const_catch_stmt_iterator catch_stmts_end() const { - return catch_stmts_begin() + NumCatchStmts; + return catch_stmts_begin() + ObjCAtTryStmtBits.NumCatchStmts; } catch_const_range catch_stmts() const { return catch_const_range(catch_stmts_begin(), catch_stmts_end()); @@ -301,7 +301,6 @@ /// \endcode class ObjCAtSynchronizedStmt : public Stmt { private: - SourceLocation AtSynchronizedLoc; enum { SYNC_EXPR, SYNC_BODY, END_EXPR }; Stmt* SubStmts[END_EXPR]; @@ -311,13 +310,17 @@ : Stmt(ObjCAtSynchronizedStmtClass) { SubStmts[SYNC_EXPR] = synchExpr; SubStmts[SYNC_BODY] = synchBody; - AtSynchronizedLoc = atSynchronizedLoc; + StmtWithSourceLocBits.Loc = atSynchronizedLoc; } explicit ObjCAtSynchronizedStmt(EmptyShell Empty) : Stmt(ObjCAtSynchronizedStmtClass, Empty) { } - SourceLocation getAtSynchronizedLoc() const { return AtSynchronizedLoc; } - void setAtSynchronizedLoc(SourceLocation Loc) { AtSynchronizedLoc = Loc; } + SourceLocation getAtSynchronizedLoc() const { + return StmtWithSourceLocBits.Loc; + } + void setAtSynchronizedLoc(SourceLocation Loc) { + StmtWithSourceLocBits.Loc = Loc; + } const CompoundStmt *getSynchBody() const { return reinterpret_cast(SubStmts[SYNC_BODY]); @@ -335,7 +338,9 @@ } void setSynchExpr(Stmt *S) { SubStmts[SYNC_EXPR] = S; } - SourceLocation getBeginLoc() const LLVM_READONLY { return AtSynchronizedLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return StmtWithSourceLocBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { return getSynchBody()->getEndLoc(); } @@ -355,13 +360,12 @@ /// Represents Objective-C's \@throw statement. class ObjCAtThrowStmt : public Stmt { - SourceLocation AtThrowLoc; Stmt *Throw; public: ObjCAtThrowStmt(SourceLocation atThrowLoc, Stmt *throwExpr) : Stmt(ObjCAtThrowStmtClass), Throw(throwExpr) { - AtThrowLoc = atThrowLoc; + StmtWithSourceLocBits.Loc = atThrowLoc; } explicit ObjCAtThrowStmt(EmptyShell Empty) : Stmt(ObjCAtThrowStmtClass, Empty) { } @@ -370,12 +374,16 @@ Expr *getThrowExpr() { return reinterpret_cast(Throw); } void setThrowExpr(Stmt *S) { Throw = S; } - SourceLocation getThrowLoc() const LLVM_READONLY { return AtThrowLoc; } - void setThrowLoc(SourceLocation Loc) { AtThrowLoc = Loc; } + SourceLocation getThrowLoc() const LLVM_READONLY { + return StmtWithSourceLocBits.Loc; + } + void setThrowLoc(SourceLocation Loc) { StmtWithSourceLocBits.Loc = Loc; } - SourceLocation getBeginLoc() const LLVM_READONLY { return AtThrowLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return StmtWithSourceLocBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { - return Throw ? Throw->getEndLoc() : AtThrowLoc; + return Throw ? Throw->getEndLoc() : StmtWithSourceLocBits.Loc; } static bool classof(const Stmt *T) { @@ -391,12 +399,13 @@ /// Represents Objective-C's \@autoreleasepool Statement class ObjCAutoreleasePoolStmt : public Stmt { - SourceLocation AtLoc; Stmt *SubStmt; public: ObjCAutoreleasePoolStmt(SourceLocation atLoc, Stmt *subStmt) - : Stmt(ObjCAutoreleasePoolStmtClass), AtLoc(atLoc), SubStmt(subStmt) {} + : Stmt(ObjCAutoreleasePoolStmtClass), SubStmt(subStmt) { + StmtWithSourceLocBits.Loc = atLoc; + } explicit ObjCAutoreleasePoolStmt(EmptyShell Empty) : Stmt(ObjCAutoreleasePoolStmtClass, Empty) { } @@ -405,13 +414,15 @@ Stmt *getSubStmt() { return SubStmt; } void setSubStmt(Stmt *S) { SubStmt = S; } - SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; } + SourceLocation getBeginLoc() const LLVM_READONLY { + return StmtWithSourceLocBits.Loc; + } SourceLocation getEndLoc() const LLVM_READONLY { return SubStmt->getEndLoc(); } - SourceLocation getAtLoc() const { return AtLoc; } - void setAtLoc(SourceLocation Loc) { AtLoc = Loc; } + SourceLocation getAtLoc() const { return StmtWithSourceLocBits.Loc; } + void setAtLoc(SourceLocation Loc) { StmtWithSourceLocBits.Loc = Loc; } static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCAutoreleasePoolStmtClass; diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -530,7 +530,8 @@ QualType ResultTy, TypeSourceInfo *TSI) : Expr(SYCLUniqueStableNameExprClass, ResultTy, VK_PRValue, OK_Ordinary), - OpLoc(OpLoc), LParen(LParen), RParen(RParen) { + LParen(LParen), RParen(RParen) { + ExprWithSourceLocBits.Loc = OpLoc; setTypeSourceInfo(TSI); setDependence(computeDependence(this)); } @@ -910,11 +911,12 @@ FixedPointLiteral::FixedPointLiteral(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l, unsigned Scale) - : Expr(FixedPointLiteralClass, type, VK_PRValue, OK_Ordinary), Loc(l), - Scale(Scale) { + : Expr(FixedPointLiteralClass, type, VK_PRValue, OK_Ordinary) { assert(type->isFixedPointType() && "Illegal type in FixedPointLiteral"); assert(V.getBitWidth() == C.getTypeInfo(type).Width && "Fixed point type is not the correct size for constant."); + FixedPointLiteralBits.Loc = l; + FixedPointLiteralBits.Scale = Scale; setValue(C, V); setDependence(ExprDependence::None); } @@ -937,8 +939,9 @@ // unsigned long _Accum: 4294967295.99999999976716935634613037109375 // which is 43 characters. SmallString<64> S; - FixedPointValueToString( - S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale); + FixedPointValueToString(S, + llvm::APSInt::getUnsigned(getValue().getZExtValue()), + FixedPointLiteralBits.Scale); return std::string(S.str()); } @@ -984,9 +987,10 @@ FloatingLiteral::FloatingLiteral(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L) - : Expr(FloatingLiteralClass, Type, VK_PRValue, OK_Ordinary), Loc(L) { + : Expr(FloatingLiteralClass, Type, VK_PRValue, OK_Ordinary) { setSemantics(V.getSemantics()); FloatingLiteralBits.IsExact = isexact; + FloatingLiteralBits.Loc = L; setValue(C, V); setDependence(ExprDependence::None); } @@ -1572,8 +1576,9 @@ ArrayRef comps, ArrayRef exprs, SourceLocation RParenLoc) : Expr(OffsetOfExprClass, type, VK_PRValue, OK_Ordinary), - OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi), - NumComps(comps.size()), NumExprs(exprs.size()) { + OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi) { + OffsetOfExprBits.NumComps = comps.size(); + OffsetOfExprBits.NumExprs = exprs.size(); for (unsigned i = 0; i != comps.size(); ++i) setComponent(i, comps[i]); for (unsigned i = 0; i != exprs.size(); ++i) @@ -1594,9 +1599,10 @@ UnaryExprOrTypeTrait ExprKind, Expr *E, QualType resultType, SourceLocation op, SourceLocation rp) : Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_PRValue, OK_Ordinary), - OpLoc(op), RParenLoc(rp) { + RParenLoc(rp) { assert(ExprKind <= UETT_Last && "invalid enum value!"); UnaryExprOrTypeTraitExprBits.Kind = ExprKind; + UnaryExprOrTypeTraitExprBits.OpLoc = op; assert(static_cast(ExprKind) == UnaryExprOrTypeTraitExprBits.Kind && "UnaryExprOrTypeTraitExprBits.Kind overflow!"); UnaryExprOrTypeTraitExprBits.IsType = false; @@ -2141,8 +2147,9 @@ SourceLocation RParenLoc, DeclContext *ParentContext) : Expr(SourceLocExprClass, ResultTy, VK_PRValue, OK_Ordinary), - BuiltinLoc(BLoc), RParenLoc(RParenLoc), ParentContext(ParentContext) { + RParenLoc(RParenLoc), ParentContext(ParentContext) { SourceLocExprBits.Kind = Kind; + SourceLocExprBits.BuiltinLoc = BLoc; setDependence(ExprDependence::None); } @@ -2264,8 +2271,9 @@ InitListExpr::InitListExpr(const ASTContext &C, SourceLocation lbraceloc, ArrayRef initExprs, SourceLocation rbraceloc) : Expr(InitListExprClass, QualType(), VK_PRValue, OK_Ordinary), - InitExprs(C, initExprs.size()), LBraceLoc(lbraceloc), - RBraceLoc(rbraceloc), AltForm(nullptr, true) { + InitExprs(C, initExprs.size()), RBraceLoc(rbraceloc), + AltForm(nullptr, true) { + InitListExprBits.LBraceLoc = lbraceloc; sawArrayRangeDesignator(false); InitExprs.insert(C, InitExprs.end(), initExprs.begin(), initExprs.end()); @@ -2354,7 +2362,7 @@ SourceLocation InitListExpr::getBeginLoc() const { if (InitListExpr *SyntacticForm = getSyntacticForm()) return SyntacticForm->getBeginLoc(); - SourceLocation Beg = LBraceLoc; + SourceLocation Beg = InitListExprBits.LBraceLoc; if (Beg.isInvalid()) { // Find the first non-null initializer. for (InitExprsTy::const_iterator I = InitExprs.begin(), @@ -4191,7 +4199,8 @@ QualType Type, SourceLocation BLoc, SourceLocation RP) : Expr(ShuffleVectorExprClass, Type, VK_PRValue, OK_Ordinary), - BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size()) { + BuiltinLoc(BLoc), RParenLoc(RP) { + ShuffleVectorExprBits.NumExprs = args.size(); SubExprs = new (C) Stmt*[args.size()]; for (unsigned i = 0; i != args.size(); i++) SubExprs[i] = args[i]; @@ -4202,8 +4211,8 @@ void ShuffleVectorExpr::setExprs(const ASTContext &C, ArrayRef Exprs) { if (SubExprs) C.Deallocate(SubExprs); - this->NumExprs = Exprs.size(); - SubExprs = new (C) Stmt*[NumExprs]; + ShuffleVectorExprBits.NumExprs = Exprs.size(); + SubExprs = new (C) Stmt *[ShuffleVectorExprBits.NumExprs]; memcpy(SubExprs, Exprs.data(), sizeof(Expr *) * Exprs.size()); } @@ -4222,7 +4231,7 @@ " and TypeSourceInfo!"); assert(ResultIndex < NumAssocs && "ResultIndex is out-of-bounds!"); - GenericSelectionExprBits.GenericLoc = GenericLoc; + ExprWithSourceLocBits.Loc = GenericLoc; getTrailingObjects()[ControllingIndex] = ControllingExpr; std::copy(AssocExprs.begin(), AssocExprs.end(), getTrailingObjects() + AssocExprStartIndex); @@ -4245,7 +4254,7 @@ "Must have the same number of association expressions" " and TypeSourceInfo!"); - GenericSelectionExprBits.GenericLoc = GenericLoc; + ExprWithSourceLocBits.Loc = GenericLoc; getTrailingObjects()[ControllingIndex] = ControllingExpr; std::copy(AssocExprs.begin(), AssocExprs.end(), getTrailingObjects() + AssocExprStartIndex); @@ -4313,9 +4322,11 @@ ArrayRef IndexExprs, Expr *Init) : Expr(DesignatedInitExprClass, Ty, Init->getValueKind(), Init->getObjectKind()), - EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax), - NumDesignators(Designators.size()), NumSubExprs(IndexExprs.size() + 1) { - this->Designators = new (C) Designator[NumDesignators]; + EqualOrColonLoc(EqualOrColonLoc) { + DesignatedInitExprBits.GNUSyntax = GNUSyntax; + DesignatedInitExprBits.NumDesignators = Designators.size(); + DesignatedInitExprBits.NumSubExprs = IndexExprs.size() + 1; + this->Designators = new (C) Designator[DesignatedInitExprBits.NumDesignators]; // Record the initializer itself. child_iterator Child = child_begin(); @@ -4324,7 +4335,7 @@ // Copy the designators and their subexpressions, computing // value-dependence along the way. unsigned IndexIdx = 0; - for (unsigned I = 0; I != NumDesignators; ++I) { + for (unsigned I = 0; I != DesignatedInitExprBits.NumDesignators; ++I) { this->Designators[I] = Designators[I]; if (this->Designators[I].isArrayDesignator()) { // Copy the index expressions into permanent storage. @@ -4364,7 +4375,7 @@ const Designator *Desigs, unsigned NumDesigs) { Designators = new (C) Designator[NumDesigs]; - NumDesignators = NumDesigs; + DesignatedInitExprBits.NumDesignators = NumDesigs; for (unsigned I = 0; I != NumDesigs; ++I) Designators[I] = Desigs[I]; } @@ -4382,7 +4393,8 @@ auto *DIE = const_cast(this); Designator &First = *DIE->getDesignator(0); if (First.isFieldDesignator()) - StartLoc = GNUSyntax ? First.Field.FieldLoc : First.Field.DotLoc; + StartLoc = DesignatedInitExprBits.GNUSyntax ? First.Field.FieldLoc + : First.Field.DotLoc; else StartLoc = First.ArrayOrRange.LBracketLoc; return StartLoc; @@ -4417,7 +4429,7 @@ unsigned NumNewDesignators = Last - First; if (NumNewDesignators == 0) { std::copy_backward(Designators + Idx + 1, - Designators + NumDesignators, + Designators + DesignatedInitExprBits.NumDesignators, Designators + Idx); --NumNewDesignators; return; @@ -4427,14 +4439,16 @@ return; } - Designator *NewDesignators - = new (C) Designator[NumDesignators - 1 + NumNewDesignators]; + Designator *NewDesignators = new (C) + Designator[DesignatedInitExprBits.NumDesignators - 1 + NumNewDesignators]; std::copy(Designators, Designators + Idx, NewDesignators); std::copy(First, Last, NewDesignators + Idx); - std::copy(Designators + Idx + 1, Designators + NumDesignators, + std::copy(Designators + Idx + 1, + Designators + DesignatedInitExprBits.NumDesignators, NewDesignators + Idx + NumNewDesignators); Designators = NewDesignators; - NumDesignators = NumDesignators - 1 + NumNewDesignators; + DesignatedInitExprBits.NumDesignators = + DesignatedInitExprBits.NumDesignators - 1 + NumNewDesignators; } DesignatedInitUpdateExpr::DesignatedInitUpdateExpr(const ASTContext &C, @@ -4699,8 +4713,10 @@ AtomicExpr::AtomicExpr(SourceLocation BLoc, ArrayRef args, QualType t, AtomicOp op, SourceLocation RP) - : Expr(AtomicExprClass, t, VK_PRValue, OK_Ordinary), - NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op) { + : Expr(AtomicExprClass, t, VK_PRValue, OK_Ordinary), BuiltinLoc(BLoc), + RParenLoc(RP) { + AtomicExprBits.NumSubExprs = args.size(); + AtomicExprBits.Op = op; assert(args.size() == getNumSubExprs(op) && "wrong number of subexpressions"); for (unsigned i = 0; i != args.size(); i++) SubExprs[i] = args[i]; @@ -4823,7 +4839,9 @@ : Expr(RecoveryExprClass, T.getNonReferenceType(), T->isDependentType() ? VK_LValue : getValueKindForType(T), OK_Ordinary), - BeginLoc(BeginLoc), EndLoc(EndLoc), NumExprs(SubExprs.size()) { + EndLoc(EndLoc) { + RecoveryExprBits.NumExprs = SubExprs.size(); + RecoveryExprBits.BeginLoc = BeginLoc; assert(!T.isNull()); assert(llvm::all_of(SubExprs, [](Expr* E) { return E != nullptr; })); diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -324,10 +324,11 @@ SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType) : Expr(CXXPseudoDestructorExprClass, Context.BoundMemberTy, VK_PRValue, OK_Ordinary), - Base(static_cast(Base)), IsArrow(isArrow), - OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc), + Base(static_cast(Base)), QualifierLoc(QualifierLoc), ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc), DestroyedType(DestroyedType) { + CXXPseudoDestructorExprBits.IsArrow = isArrow; + CXXPseudoDestructorExprBits.OperatorLoc = OperatorLoc; setDependence(computeDependence(this)); } @@ -958,7 +959,7 @@ : VK_PRValue, /*FIXME*/ OK_Ordinary), Field(Field), UsedContext(UsedContext) { - CXXDefaultInitExprBits.Loc = Loc; + ExprWithSourceLocBits.Loc = Loc; assert(Field->hasInClassInitializer()); setDependence(computeDependence(this)); diff --git a/clang/lib/AST/ExprObjC.cpp b/clang/lib/AST/ExprObjC.cpp --- a/clang/lib/AST/ExprObjC.cpp +++ b/clang/lib/AST/ExprObjC.cpp @@ -27,8 +27,9 @@ ObjCArrayLiteral::ObjCArrayLiteral(ArrayRef Elements, QualType T, ObjCMethodDecl *Method, SourceRange SR) - : Expr(ObjCArrayLiteralClass, T, VK_PRValue, OK_Ordinary), - NumElements(Elements.size()), Range(SR), ArrayWithObjectsMethod(Method) { + : Expr(ObjCArrayLiteralClass, T, VK_PRValue, OK_Ordinary), Range(SR), + ArrayWithObjectsMethod(Method) { + ObjCArrayLiteralBits.NumElements = Elements.size(); Expr **SaveElements = getElements(); for (unsigned I = 0, N = Elements.size(); I != N; ++I) SaveElements[I] = Elements[I]; @@ -54,13 +55,14 @@ bool HasPackExpansions, QualType T, ObjCMethodDecl *method, SourceRange SR) - : Expr(ObjCDictionaryLiteralClass, T, VK_PRValue, OK_Ordinary), - NumElements(VK.size()), HasPackExpansions(HasPackExpansions), Range(SR), + : Expr(ObjCDictionaryLiteralClass, T, VK_PRValue, OK_Ordinary), Range(SR), DictWithObjectsMethod(method) { + ObjCDictionaryLiteralBits.HasPackExpansions = HasPackExpansions; + ObjCDictionaryLiteralBits.NumElements = VK.size(); KeyValuePair *KeyValues = getTrailingObjects(); ExpansionData *Expansions = HasPackExpansions ? getTrailingObjects() : nullptr; - for (unsigned I = 0; I < NumElements; I++) { + for (unsigned I = 0; I < ObjCDictionaryLiteralBits.NumElements; I++) { KeyValues[I].Key = VK[I].Key; KeyValues[I].Value = VK[I].Value; if (Expansions) { diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -509,15 +509,15 @@ } Expr *GCCAsmStmt::getInputExpr(unsigned i) { - return cast(Exprs[i + NumOutputs]); + return cast(Exprs[i + AsmStmtBits.NumOutputs]); } void GCCAsmStmt::setInputExpr(unsigned i, Expr *E) { - Exprs[i + NumOutputs] = E; + Exprs[i + AsmStmtBits.NumOutputs] = E; } AddrLabelExpr *GCCAsmStmt::getLabelExpr(unsigned i) const { - return cast(Exprs[i + NumOutputs + NumInputs]); + return cast(Exprs[i + AsmStmtBits.NumOutputs + NumInputs]); } StringRef GCCAsmStmt::getLabelName(unsigned i) const { @@ -539,7 +539,7 @@ unsigned NumLabels, StringLiteral **Clobbers, unsigned NumClobbers) { - this->NumOutputs = NumOutputs; + this->AsmStmtBits.NumOutputs = NumOutputs; this->NumInputs = NumInputs; this->NumClobbers = NumClobbers; this->NumLabels = NumLabels; @@ -824,11 +824,11 @@ } Expr *MSAsmStmt::getInputExpr(unsigned i) { - return cast(Exprs[i + NumOutputs]); + return cast(Exprs[i + AsmStmtBits.NumOutputs]); } void MSAsmStmt::setInputExpr(unsigned i, Expr *E) { - Exprs[i + NumOutputs] = E; + Exprs[i + AsmStmtBits.NumOutputs] = E; } //===----------------------------------------------------------------------===// @@ -845,7 +845,7 @@ : AsmStmt(GCCAsmStmtClass, asmloc, issimple, isvolatile, numoutputs, numinputs, numclobbers), RParenLoc(rparenloc), AsmStr(asmstr), NumLabels(numlabels) { - unsigned NumExprs = NumOutputs + NumInputs + NumLabels; + unsigned NumExprs = AsmStmtBits.NumOutputs + NumInputs + NumLabels; Names = new (C) IdentifierInfo*[NumExprs]; std::copy(names, names + NumExprs, Names); @@ -853,7 +853,7 @@ Exprs = new (C) Stmt*[NumExprs]; std::copy(exprs, exprs + NumExprs, Exprs); - unsigned NumConstraints = NumOutputs + NumInputs; + unsigned NumConstraints = AsmStmtBits.NumOutputs + NumInputs; Constraints = new (C) StringLiteral*[NumConstraints]; std::copy(constraints, constraints + NumConstraints, Constraints); @@ -886,7 +886,7 @@ assert(NumAsmToks == asmtoks.size()); assert(NumClobbers == clobbers.size()); - assert(exprs.size() == NumOutputs + NumInputs); + assert(exprs.size() == AsmStmtBits.NumOutputs + NumInputs); assert(exprs.size() == constraints.size()); AsmStr = copyIntoContext(C, asmstr); @@ -1018,7 +1018,7 @@ SubExprs[COND] = Cond; SubExprs[INC] = Inc; SubExprs[BODY] = Body; - ForStmtBits.ForLoc = FL; + StmtWithSourceLocBits.Loc = FL; } VarDecl *ForStmt::getConditionVariable() const { @@ -1229,7 +1229,9 @@ SEHTryStmt::SEHTryStmt(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler) - : Stmt(SEHTryStmtClass), IsCXXTry(IsCXXTry), TryLoc(TryLoc) { + : Stmt(SEHTryStmtClass) { + SEHTryStmtBits.IsCXXTry = IsCXXTry; + SEHTryStmtBits.TryLoc = TryLoc; Children[TRY] = TryBlock; Children[HANDLER] = Handler; } @@ -1249,7 +1251,8 @@ } SEHExceptStmt::SEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, Stmt *Block) - : Stmt(SEHExceptStmtClass), Loc(Loc) { + : Stmt(SEHExceptStmtClass) { + StmtWithSourceLocBits.Loc = Loc; Children[FILTER_EXPR] = FilterExpr; Children[BLOCK] = Block; } @@ -1260,7 +1263,9 @@ } SEHFinallyStmt::SEHFinallyStmt(SourceLocation Loc, Stmt *Block) - : Stmt(SEHFinallyStmtClass), Loc(Loc), Block(Block) {} + : Stmt(SEHFinallyStmtClass), Block(Block) { + StmtWithSourceLocBits.Loc = Loc; +} SEHFinallyStmt* SEHFinallyStmt::Create(const ASTContext &C, SourceLocation Loc, Stmt *Block) { @@ -1299,7 +1304,8 @@ } CapturedStmt::Capture *CapturedStmt::getStoredCaptures() const { - unsigned Size = sizeof(CapturedStmt) + sizeof(Stmt *) * (NumCaptures + 1); + unsigned Size = sizeof(CapturedStmt) + + sizeof(Stmt *) * (CapturedStmtBits.NumCaptures + 1); // Offset of the first Capture object. unsigned FirstCaptureOffset = llvm::alignTo(Size, alignof(Capture)); @@ -1311,18 +1317,17 @@ CapturedStmt::CapturedStmt(Stmt *S, CapturedRegionKind Kind, ArrayRef Captures, - ArrayRef CaptureInits, - CapturedDecl *CD, + ArrayRef CaptureInits, CapturedDecl *CD, RecordDecl *RD) - : Stmt(CapturedStmtClass), NumCaptures(Captures.size()), - CapDeclAndKind(CD, Kind), TheRecordDecl(RD) { + : Stmt(CapturedStmtClass), CapDeclAndKind(CD, Kind), TheRecordDecl(RD) { assert( S && "null captured statement"); assert(CD && "null captured declaration for captured statement"); assert(RD && "null record declaration for captured statement"); + CapturedStmtBits.NumCaptures = Captures.size(); // Copy initialization expressions. Stmt **Stored = getStoredStmts(); - for (unsigned I = 0, N = NumCaptures; I != N; ++I) + for (unsigned I = 0, N = CapturedStmtBits.NumCaptures; I != N; ++I) *Stored++ = CaptureInits[I]; // Copy the statement being captured. @@ -1334,8 +1339,8 @@ } CapturedStmt::CapturedStmt(EmptyShell Empty, unsigned NumCaptures) - : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures), - CapDeclAndKind(nullptr, CR_Default) { + : Stmt(CapturedStmtClass, Empty), CapDeclAndKind(nullptr, CR_Default) { + CapturedStmtBits.NumCaptures = NumCaptures; getStoredStmts()[NumCaptures] = nullptr; } @@ -1382,11 +1387,13 @@ Stmt::child_range CapturedStmt::children() { // Children are captured field initializers. - return child_range(getStoredStmts(), getStoredStmts() + NumCaptures); + return child_range(getStoredStmts(), + getStoredStmts() + CapturedStmtBits.NumCaptures); } Stmt::const_child_range CapturedStmt::children() const { - return const_child_range(getStoredStmts(), getStoredStmts() + NumCaptures); + return const_child_range(getStoredStmts(), + getStoredStmts() + CapturedStmtBits.NumCaptures); } CapturedDecl *CapturedStmt::getCapturedDecl() { diff --git a/clang/lib/AST/StmtCXX.cpp b/clang/lib/AST/StmtCXX.cpp --- a/clang/lib/AST/StmtCXX.cpp +++ b/clang/lib/AST/StmtCXX.cpp @@ -38,7 +38,9 @@ CXXTryStmt::CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock, ArrayRef handlers) - : Stmt(CXXTryStmtClass), TryLoc(tryLoc), NumHandlers(handlers.size()) { + : Stmt(CXXTryStmtClass) { + CXXTryStmtBits.TryLoc = tryLoc; + CXXTryStmtBits.NumHandlers = handlers.size(); Stmt **Stmts = getStmts(); Stmts[0] = tryBlock; std::copy(handlers.begin(), handlers.end(), Stmts + 1); @@ -50,8 +52,9 @@ Stmt *Body, SourceLocation FL, SourceLocation CAL, SourceLocation CL, SourceLocation RPL) - : Stmt(CXXForRangeStmtClass), ForLoc(FL), CoawaitLoc(CAL), ColonLoc(CL), + : Stmt(CXXForRangeStmtClass), CoawaitLoc(CAL), ColonLoc(CL), RParenLoc(RPL) { + StmtWithSourceLocBits.Loc = FL; SubExprs[INIT] = Init; SubExprs[RANGE] = Range; SubExprs[BEGINSTMT] = BeginStmt; @@ -99,7 +102,7 @@ void *Mem = C.Allocate(Size, alignof(CoroutineBodyStmt)); auto *Result = new (Mem) CoroutineBodyStmt(CtorArgs()); - Result->NumParams = NumParams; + Result->CoroutineBodyStmtBits.NumParams = NumParams; auto *ParamBegin = Result->getStoredStmts() + SubStmt::FirstParamMove; std::uninitialized_fill(ParamBegin, ParamBegin + NumParams, static_cast(nullptr)); @@ -107,7 +110,8 @@ } CoroutineBodyStmt::CoroutineBodyStmt(CoroutineBodyStmt::CtorArgs const &Args) - : Stmt(CoroutineBodyStmtClass), NumParams(Args.ParamMoves.size()) { + : Stmt(CoroutineBodyStmtClass) { + CoroutineBodyStmtBits.NumParams = Args.ParamMoves.size(); Stmt **SubStmts = getStoredStmts(); SubStmts[CoroutineBodyStmt::Body] = Args.Body; SubStmts[CoroutineBodyStmt::Promise] = Args.Promise; diff --git a/clang/lib/AST/StmtObjC.cpp b/clang/lib/AST/StmtObjC.cpp --- a/clang/lib/AST/StmtObjC.cpp +++ b/clang/lib/AST/StmtObjC.cpp @@ -31,14 +31,17 @@ ObjCAtTryStmt::ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt) - : Stmt(ObjCAtTryStmtClass), AtTryLoc(atTryLoc), - NumCatchStmts(NumCatchStmts), HasFinally(atFinallyStmt != nullptr) { + : Stmt(ObjCAtTryStmtClass) { + ObjCAtTryStmtBits.AtTryLoc = atTryLoc; + ObjCAtTryStmtBits.NumCatchStmts = NumCatchStmts; + ObjCAtTryStmtBits.HasFinally = atFinallyStmt != nullptr; + Stmt **Stmts = getStmts(); Stmts[0] = atTryStmt; for (unsigned I = 0; I != NumCatchStmts; ++I) Stmts[I + 1] = CatchStmts[I]; - if (HasFinally) + if (ObjCAtTryStmtBits.HasFinally) Stmts[NumCatchStmts + 1] = atFinallyStmt; } @@ -62,9 +65,9 @@ } SourceLocation ObjCAtTryStmt::getEndLoc() const { - if (HasFinally) + if (ObjCAtTryStmtBits.HasFinally) return getFinallyStmt()->getEndLoc(); - if (NumCatchStmts) - return getCatchStmt(NumCatchStmts - 1)->getEndLoc(); + if (ObjCAtTryStmtBits.NumCatchStmts) + return getCatchStmt(ObjCAtTryStmtBits.NumCatchStmts - 1)->getEndLoc(); return getTryBody()->getEndLoc(); } diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -359,7 +359,7 @@ void ASTStmtReader::VisitAsmStmt(AsmStmt *S) { VisitStmt(S); - S->NumOutputs = Record.readInt(); + S->AsmStmtBits.NumOutputs = Record.readInt(); S->NumInputs = Record.readInt(); S->NumClobbers = Record.readInt(); S->setAsmLoc(readSourceLocation()); @@ -432,7 +432,7 @@ } // Read the operands. - unsigned NumOperands = S->NumOutputs + S->NumInputs; + unsigned NumOperands = S->AsmStmtBits.NumOutputs + S->NumInputs; SmallVector Exprs; SmallVector ConstraintsData; SmallVector Constraints; @@ -451,42 +451,43 @@ void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) { VisitStmt(S); - assert(Record.peekInt() == S->NumParams); + assert(Record.peekInt() == S->CoroutineBodyStmtBits.NumParams); Record.skipInts(1); auto *StoredStmts = S->getStoredStmts(); - for (unsigned i = 0; - i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i) + for (unsigned i = 0; i < CoroutineBodyStmt::SubStmt::FirstParamMove + + S->CoroutineBodyStmtBits.NumParams; + ++i) StoredStmts[i] = Record.readSubStmt(); } void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) { VisitStmt(S); - S->CoreturnLoc = Record.readSourceLocation(); + S->CoreturnStmtBits.CoreturnLoc = Record.readSourceLocation(); for (auto &SubStmt: S->SubStmts) SubStmt = Record.readSubStmt(); - S->IsImplicit = Record.readInt() != 0; + S->CoreturnStmtBits.IsImplicit = Record.readInt() != 0; } -void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) { +void ASTStmtReader::VisitCoroutineSuspendExpr(CoroutineSuspendExpr *E) { VisitExpr(E); - E->KeywordLoc = readSourceLocation(); - for (auto &SubExpr: E->SubExprs) + E->CoroutineSuspendExprBits.KeywordLoc = readSourceLocation(); + for (auto &SubExpr : E->SubExprs) SubExpr = Record.readSubStmt(); E->OpaqueValue = cast_or_null(Record.readSubStmt()); +} + +void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) { + VisitCoroutineSuspendExpr(E); E->setIsImplicit(Record.readInt() != 0); } void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) { - VisitExpr(E); - E->KeywordLoc = readSourceLocation(); - for (auto &SubExpr: E->SubExprs) - SubExpr = Record.readSubStmt(); - E->OpaqueValue = cast_or_null(Record.readSubStmt()); + VisitCoroutineSuspendExpr(E); } void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) { VisitExpr(E); - E->KeywordLoc = readSourceLocation(); + E->ExprWithSourceLocBits.Loc = readSourceLocation(); for (auto &SubExpr: E->SubExprs) SubExpr = Record.readSubStmt(); } @@ -1067,7 +1068,7 @@ VisitExplicitCastExpr(E); E->LParenLoc = readSourceLocation(); E->BridgeKeywordLoc = readSourceLocation(); - E->Kind = Record.readInt(); + E->ObjCBridgedCastExprBits.Kind = Record.readInt(); } void ASTStmtReader::VisitCastExpr(CastExpr *E) { @@ -1113,7 +1114,7 @@ E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr(); E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr(); E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr(); - E->QuestionLoc = readSourceLocation(); + E->ExprWithSourceLocBits.Loc = readSourceLocation(); E->ColonLoc = readSourceLocation(); } @@ -1125,7 +1126,7 @@ E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr(); E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr(); E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr(); - E->QuestionLoc = readSourceLocation(); + E->ExprWithSourceLocBits.Loc = readSourceLocation(); E->ColonLoc = readSourceLocation(); } @@ -1278,7 +1279,7 @@ void ASTStmtReader::VisitSourceLocExpr(SourceLocExpr *E) { VisitExpr(E); E->ParentContext = readDeclAs(); - E->BuiltinLoc = readSourceLocation(); + E->SourceLocExprBits.BuiltinLoc = readSourceLocation(); E->RParenLoc = readSourceLocation(); E->SourceLocExprBits.Kind = static_cast(Record.readInt()); @@ -1344,7 +1345,7 @@ unsigned NumAssocs = Record.readInt(); assert(NumAssocs == E->getNumAssocs() && "Wrong NumAssocs!"); E->ResultIndex = Record.readInt(); - E->GenericSelectionExprBits.GenericLoc = readSourceLocation(); + E->ExprWithSourceLocBits.Loc = readSourceLocation(); E->DefaultLoc = readSourceLocation(); E->RParenLoc = readSourceLocation(); @@ -1378,9 +1379,10 @@ void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) { VisitExpr(E); - E->Op = AtomicExpr::AtomicOp(Record.readInt()); - E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op); - for (unsigned I = 0; I != E->NumSubExprs; ++I) + E->AtomicExprBits.Op = Record.readInt(); + E->AtomicExprBits.NumSubExprs = + AtomicExpr::getNumSubExprs(AtomicExpr::AtomicOp(E->AtomicExprBits.Op)); + for (unsigned I = 0; I != E->AtomicExprBits.NumSubExprs; ++I) E->SubExprs[I] = Record.readSubExpr(); E->BuiltinLoc = readSourceLocation(); E->RParenLoc = readSourceLocation(); @@ -1419,7 +1421,8 @@ unsigned NumElements = Record.readInt(); assert(NumElements == E->getNumElements() && "Wrong number of elements"); bool HasPackExpansions = Record.readInt(); - assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch"); + assert(HasPackExpansions == E->ObjCDictionaryLiteralBits.HasPackExpansions && + "Pack expansion mismatch"); auto *KeyValues = E->getTrailingObjects(); auto *Expansions = @@ -1624,7 +1627,7 @@ void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) { VisitStmt(S); - S->CatchLoc = readSourceLocation(); + S->StmtWithSourceLocBits.Loc = readSourceLocation(); S->ExceptionDecl = readDeclAs(); S->HandlerBlock = Record.readSubStmt(); } @@ -1633,7 +1636,7 @@ VisitStmt(S); assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?"); Record.skipInts(1); - S->TryLoc = readSourceLocation(); + S->CXXTryStmtBits.TryLoc = readSourceLocation(); S->getStmts()[0] = Record.readSubStmt(); for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i) S->getStmts()[i + 1] = Record.readSubStmt(); @@ -1641,7 +1644,7 @@ void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) { VisitStmt(S); - S->ForLoc = readSourceLocation(); + S->StmtWithSourceLocBits.Loc = readSourceLocation(); S->CoawaitLoc = readSourceLocation(); S->ColonLoc = readSourceLocation(); S->RParenLoc = readSourceLocation(); @@ -1657,8 +1660,8 @@ void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) { VisitStmt(S); - S->KeywordLoc = readSourceLocation(); - S->IsIfExists = Record.readInt(); + S->MSDependentExistsStmtBits.KeywordLoc = readSourceLocation(); + S->MSDependentExistsStmtBits.IsIfExists = Record.readInt(); S->QualifierLoc = Record.readNestedNameSpecifierLoc(); S->NameInfo = Record.readDeclarationNameInfo(); S->SubStmt = Record.readSubStmt(); @@ -1700,9 +1703,9 @@ void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) { VisitExpr(E); E->Constructor = readDeclAs(); - E->Loc = readSourceLocation(); - E->ConstructsVirtualBase = Record.readInt(); - E->InheritedFromVirtualBase = Record.readInt(); + E->CXXInheritedCtorInitExprBits.Loc = readSourceLocation(); + E->CXXInheritedCtorInitExprBits.ConstructsVirtualBase = Record.readInt(); + E->CXXInheritedCtorInitExprBits.InheritedFromVirtualBase = Record.readInt(); } void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) { @@ -1821,14 +1824,14 @@ VisitExpr(E); E->Param = readDeclAs(); E->UsedContext = readDeclAs(); - E->CXXDefaultArgExprBits.Loc = readSourceLocation(); + E->ExprWithSourceLocBits.Loc = readSourceLocation(); } void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) { VisitExpr(E); E->Field = readDeclAs(); E->UsedContext = readDeclAs(); - E->CXXDefaultInitExprBits.Loc = readSourceLocation(); + E->ExprWithSourceLocBits.Loc = readSourceLocation(); } void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { @@ -1840,7 +1843,7 @@ void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) { VisitExpr(E); E->TypeInfo = readTypeSourceInfo(); - E->CXXScalarValueInitExprBits.RParenLoc = readSourceLocation(); + E->ExprWithSourceLocBits.Loc = readSourceLocation(); } void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) { @@ -1895,8 +1898,8 @@ VisitExpr(E); E->Base = Record.readSubExpr(); - E->IsArrow = Record.readInt(); - E->OperatorLoc = readSourceLocation(); + E->CXXPseudoDestructorExprBits.IsArrow = Record.readInt(); + E->CXXPseudoDestructorExprBits.OperatorLoc = readSourceLocation(); E->QualifierLoc = Record.readNestedNameSpecifierLoc(); E->ScopeType = readTypeSourceInfo(); E->ColonColonLoc = readSourceLocation(); @@ -2058,10 +2061,10 @@ void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) { VisitExpr(E); - E->ATT = (ArrayTypeTrait)Record.readInt(); + E->ArrayTypeTraitExprBits.ATT = (ArrayTypeTrait)Record.readInt(); E->Value = (unsigned int)Record.readInt(); SourceRange Range = readSourceRange(); - E->Loc = Range.getBegin(); + E->ArrayTypeTraitExprBits.Loc = Range.getBegin(); E->RParen = Range.getEnd(); E->QueriedType = readTypeSourceInfo(); E->Dimension = Record.readSubExpr(); @@ -2070,17 +2073,19 @@ void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) { VisitExpr(E); E->ET = (ExpressionTrait)Record.readInt(); - E->Value = (bool)Record.readInt(); + E->ExpressionTraitExprBits.Value = (bool)Record.readInt(); SourceRange Range = readSourceRange(); E->QueriedExpression = Record.readSubExpr(); - E->Loc = Range.getBegin(); + E->ExpressionTraitExprBits.Loc = Range.getBegin(); E->RParen = Range.getEnd(); } void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) { VisitExpr(E); E->CXXNoexceptExprBits.Value = Record.readInt(); - E->Range = readSourceRange(); + SourceRange R = readSourceRange(); + E->CXXNoexceptExprBits.KeywordLoc = R.getBegin(); + E->RParenLoc = R.getEnd(); E->Operand = Record.readSubExpr(); } @@ -2114,7 +2119,7 @@ VisitExpr(E); E->ParamAndRef.setPointer(readDeclAs()); E->ParamAndRef.setInt(Record.readInt()); - E->SubstNonTypeTemplateParmExprBits.NameLoc = readSourceLocation(); + E->ExprWithSourceLocBits.Loc = readSourceLocation(); E->Replacement = Record.readSubExpr(); } @@ -2152,14 +2157,14 @@ void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) { VisitExpr(E); - E->LParenLoc = readSourceLocation(); + E->CXXFoldExprBits.LParenLoc = readSourceLocation(); E->EllipsisLoc = readSourceLocation(); E->RParenLoc = readSourceLocation(); E->NumExpansions = Record.readInt(); E->SubExprs[0] = Record.readSubExpr(); E->SubExprs[1] = Record.readSubExpr(); E->SubExprs[2] = Record.readSubExpr(); - E->Opcode = (BinaryOperatorKind)Record.readInt(); + E->CXXFoldExprBits.Opcode = Record.readInt(); } void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) { @@ -2176,7 +2181,7 @@ void ASTStmtReader::VisitRecoveryExpr(RecoveryExpr *E) { VisitExpr(E); unsigned NumArgs = Record.readInt(); - E->BeginLoc = readSourceLocation(); + E->RecoveryExprBits.BeginLoc = readSourceLocation(); E->EndLoc = readSourceLocation(); assert((NumArgs + 0LL == std::distance(E->children().begin(), E->children().end())) && @@ -2191,10 +2196,10 @@ //===----------------------------------------------------------------------===// void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) { VisitExpr(E); - E->IsArrow = (Record.readInt() != 0); + E->MSPropertyRefExprBits.IsArrow = (Record.readInt() != 0); E->BaseExpr = Record.readSubExpr(); E->QualifierLoc = Record.readNestedNameSpecifierLoc(); - E->MemberLoc = readSourceLocation(); + E->MSPropertyRefExprBits.MemberLoc = readSourceLocation(); E->TheDecl = readDeclAs(); } @@ -2222,21 +2227,21 @@ void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) { VisitStmt(S); - S->Loc = readSourceLocation(); + S->StmtWithSourceLocBits.Loc = readSourceLocation(); S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt(); S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt(); } void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) { VisitStmt(S); - S->Loc = readSourceLocation(); + S->StmtWithSourceLocBits.Loc = readSourceLocation(); S->Block = Record.readSubStmt(); } void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) { VisitStmt(S); - S->IsCXXTry = Record.readInt(); - S->TryLoc = readSourceLocation(); + S->SEHTryStmtBits.IsCXXTry = Record.readInt(); + S->SEHTryStmtBits.TryLoc = readSourceLocation(); S->Children[SEHTryStmt::TRY] = Record.readSubStmt(); S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt(); } diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -1302,12 +1302,12 @@ void ASTStmtWriter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) { VisitExpr(E); Record.push_back(E->getNumElements()); - Record.push_back(E->HasPackExpansions); + Record.push_back(E->ObjCDictionaryLiteralBits.HasPackExpansions); for (unsigned i = 0; i < E->getNumElements(); i++) { ObjCDictionaryElement Element = E->getKeyValueElement(i); Record.AddStmt(Element.Key); Record.AddStmt(Element.Value); - if (E->HasPackExpansions) { + if (E->ObjCDictionaryLiteralBits.HasPackExpansions) { Record.AddSourceLocation(Element.EllipsisLoc); unsigned NumExpansions = 0; if (Element.NumExpansions) @@ -2063,14 +2063,14 @@ void ASTStmtWriter::VisitCXXFoldExpr(CXXFoldExpr *E) { VisitExpr(E); - Record.AddSourceLocation(E->LParenLoc); + Record.AddSourceLocation(E->getLParenLoc()); Record.AddSourceLocation(E->EllipsisLoc); Record.AddSourceLocation(E->RParenLoc); Record.push_back(E->NumExpansions); Record.AddStmt(E->SubExprs[0]); Record.AddStmt(E->SubExprs[1]); Record.AddStmt(E->SubExprs[2]); - Record.push_back(E->Opcode); + Record.push_back(E->getOperator()); Code = serialization::EXPR_CXX_FOLD; }