diff options
author | Bruno Ricci <riccibrun@gmail.com> | 2018-10-29 16:12:37 +0000 |
---|---|---|
committer | Bruno Ricci <riccibrun@gmail.com> | 2018-10-29 16:12:37 +0000 |
commit | e2806f857b772d2f15b39e95685a1c99bdb8aaa7 (patch) | |
tree | a5a238a0c54b7ebf90eb52a514b0780a270f6000 /clang/lib/Serialization/ASTWriterStmt.cpp | |
parent | e92567601b4b457d7f68a31ee21d2c2769c8de3b (diff) | |
download | bcm5719-llvm-e2806f857b772d2f15b39e95685a1c99bdb8aaa7.tar.gz bcm5719-llvm-e2806f857b772d2f15b39e95685a1c99bdb8aaa7.zip |
[AST] Only store the needed data in SwitchStmt
Don't store the data for the init statement and condition variable
if not needed. This cuts the size of SwitchStmt by up to 2 pointers.
The order of the children is intentionally kept the same.
Also use the newly available space in the bit-fields of Stmt
to store the bit representing whether all enums have been covered
instead of using a PointerIntPair.
Differential Revision: https://reviews.llvm.org/D53714
Reviewed By: rjmccall
llvm-svn: 345510
Diffstat (limited to 'clang/lib/Serialization/ASTWriterStmt.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriterStmt.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index e7f9f35dcc2..396cc1c2d05 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -159,12 +159,22 @@ void ASTStmtWriter::VisitIfStmt(IfStmt *S) { void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) { VisitStmt(S); - Record.AddStmt(S->getInit()); - Record.AddDeclRef(S->getConditionVariable()); + + bool HasInit = S->getInit() != nullptr; + bool HasVar = S->getConditionVariableDeclStmt() != nullptr; + Record.push_back(HasInit); + Record.push_back(HasVar); + Record.push_back(S->isAllEnumCasesCovered()); + Record.AddStmt(S->getCond()); Record.AddStmt(S->getBody()); + if (HasInit) + Record.AddStmt(S->getInit()); + if (HasVar) + Record.AddDeclRef(S->getConditionVariable()); + Record.AddSourceLocation(S->getSwitchLoc()); - Record.push_back(S->isAllEnumCasesCovered()); + for (SwitchCase *SC = S->getSwitchCaseList(); SC; SC = SC->getNextSwitchCase()) Record.push_back(Writer.RecordSwitchCaseID(SC)); |