diff options
| author | Bruno Ricci <riccibrun@gmail.com> | 2018-11-16 17:38:35 +0000 |
|---|---|---|
| committer | Bruno Ricci <riccibrun@gmail.com> | 2018-11-16 17:38:35 +0000 |
| commit | beca398a90eda0440e6287ecebb11e376115f7fc (patch) | |
| tree | 09d857d7416f053d54f74e754c355a4dcd245e65 | |
| parent | 7bc1ff9cdc351df69f324ea10345369ed49f4a60 (diff) | |
| download | bcm5719-llvm-beca398a90eda0440e6287ecebb11e376115f7fc.tar.gz bcm5719-llvm-beca398a90eda0440e6287ecebb11e376115f7fc.zip | |
[AST][NFC] Pack CXXThisExpr
Use the newly available space in the bit-fields of Stmt.
This saves 8 bytes per CXXThisExpr.
llvm-svn: 347064
| -rw-r--r-- | clang/include/clang/AST/ExprCXX.h | 29 | ||||
| -rw-r--r-- | clang/include/clang/AST/Stmt.h | 13 |
2 files changed, 27 insertions, 15 deletions
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 1529551e336..94fba581c1b 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -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; diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index 37616207c0e..b3394a81f47 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -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; |

