From: Akim Demaille Date: Fri, 25 Jul 2008 20:48:42 +0000 (+0200) Subject: Add "%define assert" to variants. X-Git-Tag: v2.7.90~1142 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/2d32fc9fe2e648418f253405f0be19dc903bf8c9?hp=2d32fc9fe2e648418f253405f0be19dc903bf8c9 Add "%define assert" to variants. This is used to help the user catch cases where some value gets ovewritten by a new one. This should not happen, as this will probably leak. Unfortunately this uncovered a bug in the C++ parser itself: the lookahead value was not destroyed between two calls to yylex. For instance if the previous lookahead was a std::string, and then an int, then the value of the std::string was correctly taken (i.e., the lookahead was now an empty string), but std::string structure itself was not reclaimed. This is now done in variant::build(other&) (which is used to take the value of the lookahead): other is not only stolen from its value, it is also destroyed. This incurs a new performance penalty of a few percent, and union becomes faster again. * data/lalr1-fusion.cc (variant::build(other&)): Destroy other. (b4_variant_if): New. (variant::built): New. Use it whereever the status of the variant changes. * etc/bench.pl.in: Check the penalty of %define assert. ---