summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriterStmt.cpp
diff options
context:
space:
mode:
authorBruno Ricci <riccibrun@gmail.com>2018-10-30 13:42:41 +0000
committerBruno Ricci <riccibrun@gmail.com>2018-10-30 13:42:41 +0000
commitbacf751add8304789a452fc01c78e73771c8d72e (patch)
treee1dbb3b2aa4b5416a45a267bae996e753202ac5b /clang/lib/Serialization/ASTWriterStmt.cpp
parentaf8e036c29ee7ef7cffb55be0d42e578d9d0aa79 (diff)
downloadbcm5719-llvm-bacf751add8304789a452fc01c78e73771c8d72e.tar.gz
bcm5719-llvm-bacf751add8304789a452fc01c78e73771c8d72e.zip
[AST] Only store the needed data in WhileStmt
Don't store the data for the condition variable if not needed. This cuts the size of WhileStmt by up to a pointer. The order of the children is kept the same. Differential Revision: https://reviews.llvm.org/D53715 Reviewed By: rjmccall llvm-svn: 345597
Diffstat (limited to 'clang/lib/Serialization/ASTWriterStmt.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriterStmt.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index 396cc1c2d05..3d0297153d8 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -183,9 +183,15 @@ void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) {
void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) {
VisitStmt(S);
- Record.AddDeclRef(S->getConditionVariable());
+
+ bool HasVar = S->getConditionVariableDeclStmt() != nullptr;
+ Record.push_back(HasVar);
+
Record.AddStmt(S->getCond());
Record.AddStmt(S->getBody());
+ if (HasVar)
+ Record.AddDeclRef(S->getConditionVariable());
+
Record.AddSourceLocation(S->getWhileLoc());
Code = serialization::STMT_WHILE;
}
OpenPOWER on IntegriCloud