r347062 - [AST][NFC] Pack CXXBoolLiteralExpr
Bruno Ricci via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 16 08:54:17 PST 2018
Author: brunoricci
Date: Fri Nov 16 08:54:17 2018
New Revision: 347062
URL: http://llvm.org/viewvc/llvm-project?rev=347062&view=rev
Log:
[AST][NFC] Pack CXXBoolLiteralExpr
Use the newly available space in Stmt.
This saves 8 bytes per CXXBoolLiteralExpr.
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=347062&r1=347061&r2=347062&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Fri Nov 16 08:54:17 2018
@@ -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;
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=347062&r1=347061&r2=347062&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Nov 16 08:54:17 2018
@@ -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;
More information about the cfe-commits
mailing list