[AST] Store the string data in StringLiteral in a trailing array of chars
authorBruno Ricci <riccibrun@gmail.com>
Thu, 15 Nov 2018 17:31:16 +0000 (17:31 +0000)
committerBruno Ricci <riccibrun@gmail.com>
Thu, 15 Nov 2018 17:31:16 +0000 (17:31 +0000)
commitb94ad1e1d383630f45c3e3d67d8a61a01d8045ed
tree90c5c2a854bbe7f4d276c9db2d7f036bfbd4cd7c
parentbc56b2432d83d12168680e6b2b50f261d1ff2ded
[AST] Store the string data in StringLiteral in a trailing array of chars

Use the newly available space in the bit-fields of Stmt and store the
string data in a trailing array of chars 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.

This patch should have no other functional changes apart from this.

A concern was raised during review about the interaction between
this patch and serialization abbreviations. I believe however that
there is currently no abbreviation defined for StringLiteral.
The only statements/expressions which have abbreviations are currently
DeclRefExpr, IntegerLiteral, CharacterLiteral and ImplicitCastExpr.

Differential Revision: https://reviews.llvm.org/D54166

Reviewed By: dblaikie, rjmccall

llvm-svn: 346969
clang/include/clang/AST/Expr.h
clang/include/clang/AST/Stmt.h
clang/lib/AST/Expr.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp