From: Bruno Ricci Date: Tue, 20 Nov 2018 16:03:33 +0000 (+0000) Subject: [AST][NFC] Pack ArraySubscriptExpr X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b03ce7b86b90fbdfd4f08e304f3f963ce9bfbe6f;p=clang [AST][NFC] Pack ArraySubscriptExpr Use the newly available space in the bit-fields of Stmt. This saves one pointer per ArraySubscriptExpr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347317 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 004631019c..fbf8bc4cf2 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -2315,9 +2315,9 @@ public: /// ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting. class ArraySubscriptExpr : public Expr { - enum { LHS, RHS, END_EXPR=2 }; - Stmt* SubExprs[END_EXPR]; - SourceLocation RBracketLoc; + enum { LHS, RHS, END_EXPR }; + Stmt *SubExprs[END_EXPR]; + public: ArraySubscriptExpr(Expr *lhs, Expr *rhs, QualType t, ExprValueKind VK, ExprObjectKind OK, @@ -2328,10 +2328,10 @@ public: (lhs->isInstantiationDependent() || rhs->isInstantiationDependent()), (lhs->containsUnexpandedParameterPack() || - rhs->containsUnexpandedParameterPack())), - RBracketLoc(rbracketloc) { + rhs->containsUnexpandedParameterPack())) { SubExprs[LHS] = lhs; SubExprs[RHS] = rhs; + ArraySubscriptExprBits.RBracketLoc = rbracketloc; } /// Create an empty array subscript expression. @@ -2374,10 +2374,14 @@ public: SourceLocation getBeginLoc() const LLVM_READONLY { return getLHS()->getBeginLoc(); } - SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; } + SourceLocation getEndLoc() const { return getRBracketLoc(); } - SourceLocation getRBracketLoc() const { return RBracketLoc; } - void setRBracketLoc(SourceLocation L) { RBracketLoc = L; } + SourceLocation getRBracketLoc() const { + return ArraySubscriptExprBits.RBracketLoc; + } + void setRBracketLoc(SourceLocation L) { + ArraySubscriptExprBits.RBracketLoc = L; + } SourceLocation getExprLoc() const LLVM_READONLY { return getBase()->getExprLoc(); diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 4dd7ab79f7..4883aa71e0 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -416,6 +416,14 @@ protected: unsigned IsType : 1; // true if operand is a type, false if an expression. }; + class ArraySubscriptExprBitfields { + friend class ArraySubscriptExpr; + + unsigned : NumExprBits; + + SourceLocation RBracketLoc; + }; + class CallExprBitfields { friend class CallExpr; @@ -658,6 +666,7 @@ protected: CharacterLiteralBitfields CharacterLiteralBits; UnaryOperatorBitfields UnaryOperatorBits; UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits; + ArraySubscriptExprBitfields ArraySubscriptExprBits; CallExprBitfields CallExprBits; MemberExprBitfields MemberExprBits; CastExprBitfields CastExprBits;