This is an archive of the discontinued LLVM Phabricator instance.

[AST] Don't store data for GNU range case statement if not needed.
ClosedPublic

Authored by riccibruno on Oct 23 2018, 1:44 PM.

Details

Summary

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.

Diff Detail

Repository
rC Clang

Event Timeline

riccibruno created this revision.Oct 23 2018, 1:44 PM
rjmccall added inline comments.Oct 24 2018, 6:14 PM
include/clang/AST/Stmt.h
974

ELLIPSISLOC is dead.

Much like the other patch, I'm not sure it's okay to reorder the children here. Using a dynamic offset for extracting the sub-statement is probably fine. If you're worried about that cost, StmtIterator is already pretty complicated, and it's not frequently-used by the compiler; I think it would be fine to find ways to get it to visit the elements of an array out of order.

Reworked so that the order of the children is kept the same.

rjmccall accepted this revision.Oct 25 2018, 9:45 PM

LGTM.

This revision is now accepted and ready to land.Oct 25 2018, 9:45 PM
riccibruno added a reviewer: rsmith.

Add a flag in the output of -ast-dump to indicate that
a CaseStmt is a GNU range case statement, following
rsmith's comment in D53717

This revision was automatically updated to reflect the committed changes.