From: Bruno Ricci Date: Mon, 7 Jan 2019 13:39:26 +0000 (+0000) Subject: [AST][NFC] Pack OpaqueValueExpr X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=550f5b09756692e2f47cb2d54b42ee9436b91c8d;p=clang [AST][NFC] Pack OpaqueValueExpr Use the newly available space in the bit-fields of Stmt. This saves 1 pointer per OpaqueValueExpr. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350519 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 025ef0642a..1c757b5330 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -945,7 +945,6 @@ public: class OpaqueValueExpr : public Expr { friend class ASTStmtReader; Expr *SourceExpr; - SourceLocation Loc; public: OpaqueValueExpr(SourceLocation Loc, QualType T, ExprValueKind VK, @@ -959,8 +958,9 @@ public: T->isInstantiationDependentType() || (SourceExpr && SourceExpr->isInstantiationDependent()), false), - SourceExpr(SourceExpr), Loc(Loc) { + SourceExpr(SourceExpr) { setIsUnique(false); + OpaqueValueExprBits.Loc = Loc; } /// Given an expression which invokes a copy constructor --- i.e. a @@ -969,20 +969,19 @@ public: static const OpaqueValueExpr *findInCopyConstruct(const Expr *expr); explicit OpaqueValueExpr(EmptyShell Empty) - : Expr(OpaqueValueExprClass, Empty) { } + : Expr(OpaqueValueExprClass, Empty) {} /// Retrieve the location of this expression. - SourceLocation getLocation() const { return Loc; } + SourceLocation getLocation() const { return OpaqueValueExprBits.Loc; } SourceLocation getBeginLoc() const LLVM_READONLY { - return SourceExpr ? SourceExpr->getBeginLoc() : Loc; + return SourceExpr ? SourceExpr->getBeginLoc() : getLocation(); } SourceLocation getEndLoc() const LLVM_READONLY { - return SourceExpr ? SourceExpr->getEndLoc() : Loc; + return SourceExpr ? SourceExpr->getEndLoc() : getLocation(); } SourceLocation getExprLoc() const LLVM_READONLY { - if (SourceExpr) return SourceExpr->getExprLoc(); - return Loc; + return SourceExpr ? SourceExpr->getExprLoc() : getLocation(); } child_range children() { diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 9d8a297487..c83af51626 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -706,13 +706,16 @@ protected: //===--- Clang Extensions bitfields classes ---===// class OpaqueValueExprBitfields { + friend class ASTStmtReader; friend class OpaqueValueExpr; unsigned : NumExprBits; - /// The OVE is a unique semantic reference to its source expressio if this + /// The OVE is a unique semantic reference to its source expression if this /// bit is set to true. unsigned IsUnique : 1; + + SourceLocation Loc; }; union { diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index 83b4fcd1d9..f2c623eb6b 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -1773,7 +1773,7 @@ void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) { void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) { VisitExpr(E); E->SourceExpr = Record.readSubExpr(); - E->Loc = ReadSourceLocation(); + E->OpaqueValueExprBits.Loc = ReadSourceLocation(); E->setIsUnique(Record.readInt()); }