[PATCH] D54166: [AST] Store the string data in StringLiteral in a trailing array of chars
Bruno Ricci via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 6 11:14:58 PST 2018
riccibruno created this revision.
riccibruno added a reviewer: rsmith.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.
Use the newly available space in the bit-fields of `Stmt` and store the
string data in a trailing array of `char`s after the trailing array
of `SourceLocation`. This cuts the size of `StringLiteral` by 2 pointers.
Also refactor slightly `StringLiteral::Create` and `StringLiteral::CreateEmpty`
so that `StringLiteral::Create` is just responsible for the allocation, and the
constructor is responsible for doing all the initialization. This match what
is done for the other classes in general.
Two points I am wondering about:
The original version used type punning through an union. Here I am just
`reinterpret_cast`ing back and forth between `char *` and `uint16_t *`/`uint32_t *`.
There is a FIXME in `ASTWriterStmt.cpp` (see the end of the diff) which says that
storing the string past the `StringLiteral` would cause problems with abbreviations.
The note dates from 2009 and everything *seems* to be working just fine. However
I am not familiar with this and it is possible I am missing something here.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 25085 bytes
Desc: not available
More information about the cfe-commits