From: Bruno Ricci Date: Fri, 16 Nov 2018 16:54:17 +0000 (+0000) Subject: [AST][NFC] Pack CXXBoolLiteralExpr X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=430214e3ab7ec72224d1d42eb0c09357c86fdcd4;p=clang [AST][NFC] Pack CXXBoolLiteralExpr Use the newly available space in Stmt. This saves 8 bytes per CXXBoolLiteralExpr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347062 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 13ece0d6d3..ea07052346 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -548,26 +548,25 @@ public: /// A boolean literal, per ([C++ lex.bool] Boolean literals). class CXXBoolLiteralExpr : public Expr { - bool Value; - SourceLocation Loc; - public: - CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) + CXXBoolLiteralExpr(bool Val, QualType Ty, SourceLocation Loc) : Expr(CXXBoolLiteralExprClass, Ty, VK_RValue, OK_Ordinary, false, false, - false, false), - Value(val), Loc(l) {} + false, false) { + CXXBoolLiteralExprBits.Value = Val; + CXXBoolLiteralExprBits.Loc = Loc; + } explicit CXXBoolLiteralExpr(EmptyShell Empty) : Expr(CXXBoolLiteralExprClass, Empty) {} - bool getValue() const { return Value; } - void setValue(bool V) { Value = V; } + bool getValue() const { return CXXBoolLiteralExprBits.Value; } + void setValue(bool V) { CXXBoolLiteralExprBits.Value = V; } - SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; } - SourceLocation getEndLoc() const LLVM_READONLY { return Loc; } + SourceLocation getBeginLoc() const { return getLocation(); } + SourceLocation getEndLoc() const { return getLocation(); } - SourceLocation getLocation() const { return Loc; } - void setLocation(SourceLocation L) { Loc = L; } + SourceLocation getLocation() const { return CXXBoolLiteralExprBits.Loc; } + void setLocation(SourceLocation L) { CXXBoolLiteralExprBits.Loc = L; } static bool classof(const Stmt *T) { return T->getStmtClass() == CXXBoolLiteralExprClass; diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 79a6646040..ad77c27e2c 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -502,6 +502,18 @@ protected: //===--- C++ Expression bitfields classes ---===// + class CXXBoolLiteralExprBitfields { + friend class CXXBoolLiteralExpr; + + unsigned : NumExprBits; + + /// The value of the boolean literal. + unsigned Value : 1; + + /// The location of the boolean literal. + SourceLocation Loc; + }; + class TypeTraitExprBitfields { friend class ASTStmtReader; friend class ASTStmtWriter; @@ -600,6 +612,7 @@ protected: PseudoObjectExprBitfields PseudoObjectExprBits; // C++ Expressions + CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits; TypeTraitExprBitfields TypeTraitExprBits; ExprWithCleanupsBitfields ExprWithCleanupsBits;