diff options
author | Bruno Ricci <riccibrun@gmail.com> | 2018-10-28 12:30:53 +0000 |
---|---|---|
committer | Bruno Ricci <riccibrun@gmail.com> | 2018-10-28 12:30:53 +0000 |
commit | e3d558fc477543faaf67cda05d1c4a0cf501486d (patch) | |
tree | 61981702e03b6f0cfbd2e76e4546034a06fe7f83 /lib/Serialization | |
parent | f69e619d8ac2b982265d710362ffb506202bf0f0 (diff) | |
download | clang-e3d558fc477543faaf67cda05d1c4a0cf501486d.tar.gz |
[AST] Don't store data for GNU range case statement if not needed
Don't store the data for case statements of the form LHS ... RHS if not
needed. This cuts the size of CaseStmt by 1 pointer + 1 SourceLocation in
the common case.
Also use the newly available space in the bit-fields of Stmt to store the
keyword location of SwitchCase and move the small accessor
SwitchCase::getSubStmt to the header.
Differential Revision: https://reviews.llvm.org/D53609
Reviewed By: rjmccall
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345472 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization')
-rw-r--r-- | lib/Serialization/ASTReaderStmt.cpp | 11 | ||||
-rw-r--r-- | lib/Serialization/ASTWriterStmt.cpp | 7 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index f7f3f05cf3..466dfa5f53 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -177,10 +177,13 @@ void ASTStmtReader::VisitSwitchCase(SwitchCase *S) { void ASTStmtReader::VisitCaseStmt(CaseStmt *S) { VisitSwitchCase(S); + bool CaseStmtIsGNURange = Record.readInt(); S->setLHS(Record.readSubExpr()); - S->setRHS(Record.readSubExpr()); S->setSubStmt(Record.readSubStmt()); - S->setEllipsisLoc(ReadSourceLocation()); + if (CaseStmtIsGNURange) { + S->setRHS(Record.readSubExpr()); + S->setEllipsisLoc(ReadSourceLocation()); + } } void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) { @@ -2277,7 +2280,9 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { break; case STMT_CASE: - S = new (Context) CaseStmt(Empty); + S = CaseStmt::CreateEmpty( + Context, + /*CaseStmtIsGNURange*/ Record[ASTStmtReader::NumStmtFields + 3]); break; case STMT_DEFAULT: diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp index ef2e06a941..3fce69142d 100644 --- a/lib/Serialization/ASTWriterStmt.cpp +++ b/lib/Serialization/ASTWriterStmt.cpp @@ -96,10 +96,13 @@ void ASTStmtWriter::VisitSwitchCase(SwitchCase *S) { void ASTStmtWriter::VisitCaseStmt(CaseStmt *S) { VisitSwitchCase(S); + Record.push_back(S->caseStmtIsGNURange()); Record.AddStmt(S->getLHS()); - Record.AddStmt(S->getRHS()); Record.AddStmt(S->getSubStmt()); - Record.AddSourceLocation(S->getEllipsisLoc()); + if (S->caseStmtIsGNURange()) { + Record.AddStmt(S->getRHS()); + Record.AddSourceLocation(S->getEllipsisLoc()); + } Code = serialization::STMT_CASE; } |