summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorAkim Demaille <demaille@gostai.com>2008-07-25 22:48:42 +0200
committerAkim Demaille <demaille@gostai.com>2008-11-07 21:38:06 +0100
commit2d32fc9fe2e648418f253405f0be19dc903bf8c9 (patch)
tree4fb7de613f9d93e589692505ff5a69dc70dc28a5 /etc
parentf6038cb8c35c6b1a827fd3f6356d8cc9a002abe0 (diff)
downloadbison-2d32fc9fe2e648418f253405f0be19dc903bf8c9.tar.gz
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.
Diffstat (limited to 'etc')
-rwxr-xr-xetc/bench.pl.in1
1 files changed, 1 insertions, 0 deletions
diff --git a/etc/bench.pl.in b/etc/bench.pl.in
index f4f5a7e5..97facb51 100755
--- a/etc/bench.pl.in
+++ b/etc/bench.pl.in
@@ -816,6 +816,7 @@ sub bench_variant_parser ()
"f-var-deb" => ['%skeleton "lalr1-fusion.cc"', '%debug', '%define variant'],
"f-var-dtr" => ['%skeleton "lalr1-fusion.cc"', '%define variant', "%code {\n#define VARIANT_DESTROY\n}"],
"f-var-deb-dtr" => ['%skeleton "lalr1-fusion.cc"', '%debug', '%define variant', "%code {\n#define VARIANT_DESTROY\n}"],
+ "f-var-deb-dtr-ass" => ['%skeleton "lalr1-fusion.cc"', '%debug', '%define variant', "%code {\n#define VARIANT_DESTROY\n}", "%define assert"],
)
);
}