r347064 - [AST][NFC] Pack CXXThisExpr
Bruno Ricci via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 16 09:38:35 PST 2018
Author: brunoricci
Date: Fri Nov 16 09:38:35 2018
New Revision: 347064
URL: http://llvm.org/viewvc/llvm-project?rev=347064&view=rev
Log:
[AST][NFC] Pack CXXThisExpr
Use the newly available space in the bit-fields of Stmt.
This saves 8 bytes per CXXThisExpr.
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=347064&r1=347063&r2=347064&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Fri Nov 16 09:38:35 2018
@@ -962,29 +962,28 @@ public:
/// };
/// \endcode
class CXXThisExpr : public Expr {
- SourceLocation Loc;
- bool Implicit : 1;
-
public:
- CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit)
- : Expr(CXXThisExprClass, Type, VK_RValue, OK_Ordinary,
+ CXXThisExpr(SourceLocation L, QualType Ty, bool IsImplicit)
+ : Expr(CXXThisExprClass, Ty, VK_RValue, OK_Ordinary,
// 'this' is type-dependent if the class type of the enclosing
// member function is dependent (C++ [temp.dep.expr]p2)
- Type->isDependentType(), Type->isDependentType(),
- Type->isInstantiationDependentType(),
- /*ContainsUnexpandedParameterPack=*/false),
- Loc(L), Implicit(isImplicit) {}
+ Ty->isDependentType(), Ty->isDependentType(),
+ Ty->isInstantiationDependentType(),
+ /*ContainsUnexpandedParameterPack=*/false) {
+ CXXThisExprBits.IsImplicit = IsImplicit;
+ CXXThisExprBits.Loc = L;
+ }
CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
- SourceLocation getLocation() const { return Loc; }
- void setLocation(SourceLocation L) { Loc = L; }
+ SourceLocation getLocation() const { return CXXThisExprBits.Loc; }
+ void setLocation(SourceLocation L) { CXXThisExprBits.Loc = L; }
- SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
- SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
+ SourceLocation getBeginLoc() const { return getLocation(); }
+ SourceLocation getEndLoc() const { return getLocation(); }
- bool isImplicit() const { return Implicit; }
- void setImplicit(bool I) { Implicit = I; }
+ bool isImplicit() const { return CXXThisExprBits.IsImplicit; }
+ void setImplicit(bool I) { CXXThisExprBits.IsImplicit = I; }
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXThisExprClass;
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=347064&r1=347063&r2=347064&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Nov 16 09:38:35 2018
@@ -523,6 +523,18 @@ protected:
SourceLocation Loc;
};
+ class CXXThisExprBitfields {
+ friend class CXXThisExpr;
+
+ unsigned : NumExprBits;
+
+ /// Whether this is an implicit "this".
+ unsigned IsImplicit : 1;
+
+ /// The location of the "this".
+ SourceLocation Loc;
+ };
+
class TypeTraitExprBitfields {
friend class ASTStmtReader;
friend class ASTStmtWriter;
@@ -623,6 +635,7 @@ protected:
// C++ Expressions
CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits;
CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits;
+ CXXThisExprBitfields CXXThisExprBits;
TypeTraitExprBitfields TypeTraitExprBits;
ExprWithCleanupsBitfields ExprWithCleanupsBits;
More information about the cfe-commits
mailing list