зеркало из https://github.com/mozilla/gecko-dev.git
Bug 920318 - Add a user-provided constructor to Token, so that the tokens() member initializer of TokenStream will zero the memory used by those tokens in MSVC 2013. (This is a compiler bug.) r=luke
This commit is contained in:
Родитель
56087fd7d8
Коммит
0c952040c6
|
@ -235,7 +235,8 @@ struct TokenPos {
|
|||
|
||||
enum DecimalPoint { NoDecimal = false, HasDecimal = true };
|
||||
|
||||
struct Token {
|
||||
struct Token
|
||||
{
|
||||
TokenKind type; // char value or above enumerator
|
||||
TokenPos pos; // token position in file
|
||||
union {
|
||||
|
@ -251,6 +252,24 @@ struct Token {
|
|||
// regexp chars
|
||||
} u;
|
||||
|
||||
// This constructor is necessary only for MSVC 2013 and how it compiles the
|
||||
// initialization of TokenStream::tokens. That field is initialized as
|
||||
// tokens() in the constructor init-list. This *should* zero the entire
|
||||
// array, then (because Token has a non-trivial constructor, because
|
||||
// TokenPos has a user-provided constructor) call the implicit Token
|
||||
// constructor on each element, which would call the TokenPos constructor
|
||||
// for Token::pos and do nothing. (All of which is equivalent to just
|
||||
// zeroing TokenStream::tokens.) But MSVC 2013 (2010/2012 don't have this
|
||||
// bug) doesn't zero out each element, so we need this extra constructor to
|
||||
// make it do the right thing. (Token is used primarily by reference or
|
||||
// pointer, and it's only initialized a very few places, so having a
|
||||
// user-defined constructor won't hurt perf.) See also bug 920318.
|
||||
Token()
|
||||
: type(TOK_ERROR),
|
||||
pos(0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
// Mutators
|
||||
|
||||
void setName(PropertyName *name) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче