summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Ricci <riccibrun@gmail.com>2019-01-07 13:39:26 +0000
committerBruno Ricci <riccibrun@gmail.com>2019-01-07 13:39:26 +0000
commit76ab9d4589fc59c7f00f512ae86c73303ccb0f4a (patch)
tree8c6c1249d7f2a21c8ee1b5e038fec963b1a716b0
parent7a27c1886f0133171415f7f63d3d02ce1f0aaaf1 (diff)
downloadbcm5719-llvm-76ab9d4589fc59c7f00f512ae86c73303ccb0f4a.tar.gz
bcm5719-llvm-76ab9d4589fc59c7f00f512ae86c73303ccb0f4a.zip
[AST][NFC] Pack OpaqueValueExpr
Use the newly available space in the bit-fields of Stmt. This saves 1 pointer per OpaqueValueExpr. NFC. llvm-svn: 350519
-rw-r--r--clang/include/clang/AST/Expr.h15
-rw-r--r--clang/include/clang/AST/Stmt.h5
-rw-r--r--clang/lib/Serialization/ASTReaderStmt.cpp2
3 files changed, 12 insertions, 10 deletions
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 025ef0642a1..1c757b53308 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/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/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 9d8a2974870..c83af516264 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/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/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp
index 83b4fcd1d9a..f2c623eb6b0 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/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());
}
OpenPOWER on IntegriCloud