From: Bruno Ricci Date: Sat, 17 Nov 2018 12:56:30 +0000 (+0000) Subject: [AST][NFC] Pack CXXDefaultArgExpr X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b30b84b85e955a854c75b8f0c9d6ab1d46948577;p=clang [AST][NFC] Pack CXXDefaultArgExpr Use the newly available space in the bit-fields of Stmt. This saves one pointer per CXXDefaultArgExpr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347137 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 847a9fe2a1..3a1755d86a 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -1059,26 +1059,24 @@ public: /// corresponding parameter's default argument, when the call did not /// explicitly supply arguments for all of the parameters. class CXXDefaultArgExpr final : public Expr { + friend class ASTStmtReader; + /// The parameter whose default is being used. ParmVarDecl *Param; - /// The location where the default argument expression was used. - SourceLocation Loc; - - CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param) + CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *Param) : Expr(SC, - param->hasUnparsedDefaultArg() - ? param->getType().getNonReferenceType() - : param->getDefaultArg()->getType(), - param->getDefaultArg()->getValueKind(), - param->getDefaultArg()->getObjectKind(), false, false, false, + Param->hasUnparsedDefaultArg() + ? Param->getType().getNonReferenceType() + : Param->getDefaultArg()->getType(), + Param->getDefaultArg()->getValueKind(), + Param->getDefaultArg()->getObjectKind(), false, false, false, false), - Param(param), Loc(Loc) {} + Param(Param) { + CXXDefaultArgExprBits.Loc = Loc; + } public: - friend class ASTStmtReader; - friend class ASTStmtWriter; - CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {} // \p Param is the parameter whose default argument is used by this @@ -1093,23 +1091,18 @@ public: ParmVarDecl *getParam() { return Param; } // Retrieve the actual argument to the function call. - const Expr *getExpr() const { - return getParam()->getDefaultArg(); - } - Expr *getExpr() { - return getParam()->getDefaultArg(); - } + const Expr *getExpr() const { return getParam()->getDefaultArg(); } + Expr *getExpr() { return getParam()->getDefaultArg(); } - /// Retrieve the location where this default argument was actually - /// used. - SourceLocation getUsedLocation() const { return Loc; } + /// Retrieve the location where this default argument was actually used. + SourceLocation getUsedLocation() const { return CXXDefaultArgExprBits.Loc; } /// Default argument expressions have no representation in the /// source, so they have an empty source range. - SourceLocation getBeginLoc() const LLVM_READONLY { return SourceLocation(); } - SourceLocation getEndLoc() const LLVM_READONLY { return SourceLocation(); } + SourceLocation getBeginLoc() const { return SourceLocation(); } + SourceLocation getEndLoc() const { return SourceLocation(); } - SourceLocation getExprLoc() const LLVM_READONLY { return Loc; } + SourceLocation getExprLoc() const { return getUsedLocation(); } static bool classof(const Stmt *T) { return T->getStmtClass() == CXXDefaultArgExprClass; diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 34667d1df5..258678bdd1 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -548,6 +548,16 @@ protected: SourceLocation ThrowLoc; }; + class CXXDefaultArgExprBitfields { + friend class ASTStmtReader; + friend class CXXDefaultArgExpr; + + unsigned : NumExprBits; + + /// The location where the default argument expression was used. + SourceLocation Loc; + }; + class TypeTraitExprBitfields { friend class ASTStmtReader; friend class ASTStmtWriter; @@ -650,6 +660,7 @@ protected: CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits; CXXThisExprBitfields CXXThisExprBits; CXXThrowExprBitfields CXXThrowExprBits; + CXXDefaultArgExprBitfields CXXDefaultArgExprBits; TypeTraitExprBitfields TypeTraitExprBits; ExprWithCleanupsBitfields ExprWithCleanupsBits; diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index 184ae37223..cf39ccc5e0 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -1481,7 +1481,7 @@ void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) { void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { VisitExpr(E); E->Param = ReadDeclAs(); - E->Loc = ReadSourceLocation(); + E->CXXDefaultArgExprBits.Loc = ReadSourceLocation(); } void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {