summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Ricci <riccibrun@gmail.com>2018-11-17 13:02:47 +0000
committerBruno Ricci <riccibrun@gmail.com>2018-11-17 13:02:47 +0000
commitfd66eb86a53efdfad0a23bd79ebcc945bc71504a (patch)
treeed9bc91709ee9a68905106f9b97c7b9495590b0f
parentb7093e1c2495362c95e5906b22ed074f12efd812 (diff)
downloadbcm5719-llvm-fd66eb86a53efdfad0a23bd79ebcc945bc71504a.tar.gz
bcm5719-llvm-fd66eb86a53efdfad0a23bd79ebcc945bc71504a.zip
[AST][NFC] Pack CXXDefaultInitExpr
Use the newly available space in the bit-fields of Stmt. This saves one pointer per CXXDefaultInitExpr. llvm-svn: 347138
-rw-r--r--clang/include/clang/AST/ExprCXX.h21
-rw-r--r--clang/include/clang/AST/Stmt.h11
-rw-r--r--clang/lib/AST/ExprCXX.cpp11
-rw-r--r--clang/lib/Serialization/ASTReaderStmt.cpp2
4 files changed, 27 insertions, 18 deletions
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index 3a1755d86a7..a525490092e 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -1123,26 +1123,23 @@ public:
/// (C++11 [class.base.init]p8) or in aggregate initialization
/// (C++1y [dcl.init.aggr]p7).
class CXXDefaultInitExpr : public Expr {
+ friend class ASTReader;
+ friend class ASTStmtReader;
+
/// The field whose default is being used.
FieldDecl *Field;
- /// The location where the default initializer expression was used.
- SourceLocation Loc;
-
- CXXDefaultInitExpr(const ASTContext &C, SourceLocation Loc, FieldDecl *Field,
- QualType T);
+ CXXDefaultInitExpr(const ASTContext &Ctx, SourceLocation Loc,
+ FieldDecl *Field, QualType Ty);
CXXDefaultInitExpr(EmptyShell Empty) : Expr(CXXDefaultInitExprClass, Empty) {}
public:
- friend class ASTReader;
- friend class ASTStmtReader;
-
/// \p Field is the non-static data member whose default initializer is used
/// by this expression.
- static CXXDefaultInitExpr *Create(const ASTContext &C, SourceLocation Loc,
+ static CXXDefaultInitExpr *Create(const ASTContext &Ctx, SourceLocation Loc,
FieldDecl *Field) {
- return new (C) CXXDefaultInitExpr(C, Loc, Field, Field->getType());
+ return new (Ctx) CXXDefaultInitExpr(Ctx, Loc, Field, Field->getType());
}
/// Get the field whose initializer will be used.
@@ -1159,8 +1156,8 @@ public:
return Field->getInClassInitializer();
}
- SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
- SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
+ SourceLocation getBeginLoc() const { return CXXDefaultInitExprBits.Loc; }
+ SourceLocation getEndLoc() const { return CXXDefaultInitExprBits.Loc; }
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXDefaultInitExprClass;
diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 258678bdd19..4dd7ab79f72 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -558,6 +558,16 @@ protected:
SourceLocation Loc;
};
+ class CXXDefaultInitExprBitfields {
+ friend class ASTStmtReader;
+ friend class CXXDefaultInitExpr;
+
+ unsigned : NumExprBits;
+
+ /// The location where the default initializer expression was used.
+ SourceLocation Loc;
+ };
+
class TypeTraitExprBitfields {
friend class ASTStmtReader;
friend class ASTStmtWriter;
@@ -661,6 +671,7 @@ protected:
CXXThisExprBitfields CXXThisExprBits;
CXXThrowExprBitfields CXXThrowExprBits;
CXXDefaultArgExprBitfields CXXDefaultArgExprBits;
+ CXXDefaultInitExprBitfields CXXDefaultInitExprBits;
TypeTraitExprBitfields TypeTraitExprBits;
ExprWithCleanupsBitfields ExprWithCleanupsBits;
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 00a460758ef..a58b0f7fa2b 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -749,14 +749,15 @@ const IdentifierInfo *UserDefinedLiteral::getUDSuffix() const {
return cast<FunctionDecl>(getCalleeDecl())->getLiteralIdentifier();
}
-CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &C, SourceLocation Loc,
- FieldDecl *Field, QualType T)
- : Expr(CXXDefaultInitExprClass, T.getNonLValueExprType(C),
- T->isLValueReferenceType() ? VK_LValue : T->isRValueReferenceType()
+CXXDefaultInitExpr::CXXDefaultInitExpr(const ASTContext &Ctx, SourceLocation Loc,
+ FieldDecl *Field, QualType Ty)
+ : Expr(CXXDefaultInitExprClass, Ty.getNonLValueExprType(Ctx),
+ Ty->isLValueReferenceType() ? VK_LValue : Ty->isRValueReferenceType()
? VK_XValue
: VK_RValue,
/*FIXME*/ OK_Ordinary, false, false, false, false),
- Field(Field), Loc(Loc) {
+ Field(Field) {
+ CXXDefaultInitExprBits.Loc = Loc;
assert(Field->hasInClassInitializer());
}
diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index cf39ccc5e00..db790c5ebf7 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -1487,7 +1487,7 @@ void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
VisitExpr(E);
E->Field = ReadDeclAs<FieldDecl>();
- E->Loc = ReadSourceLocation();
+ E->CXXDefaultInitExprBits.Loc = ReadSourceLocation();
}
void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
OpenPOWER on IntegriCloud