If the match compiler uses the 'verify' mode and we
compile with -O2, some tests comparing the on-the-fly-parser
to the compiled match fail.
Small functions are inlined by the -O2 compile flag.
If we disable function inlining and still compile with -O2,
everything is back to normal.
gdb didn't show anything useful during the mismatch
since the needed variables are optimized out. Once
we start printing them, the problem vanishes, too.
-> Can only be diagnosed at the x86 assembly level.
The problem vanished by switching the invocation order
of Token::Match() and the compiled match, so just swap them.
Also add commented out helper code
to better diagnose mismatch problems.
Use tok->isOp() instead of doing it "manually".
This fixes false positives for the C++ template case since
the brackets in "template < something >" are not comparison operators.
Profiling showed using tok->isOp() is actually faster than before (-O2).
When the %op% operator is the first element
of a multicompare, it properly executes Token::isOp().
Otherwise it uses it's "internal implementation".
Workaround inspired by Edoardo Prezioso.
The result of the %op% operator is wrong in the multicompare
case for C++ templates. Detected by comparing the output
of the compiled matches with the on-the-fly match parser.
Verify mode runs the same ::Match pattern on a token
using the on-the-fly parser and the compiled match parser.
The result is compared and we abort on mismatch.
Already detected an error in our test suite, needs investigation.
Now the 'sin^2+cos^2=1' and the 'sinh^2-cosh^2=-1' code can handle, for example: sin^4+cos^4=1, sinh^10-cosh^10=-1.
Also, the arguments can be also multitokens, so that it's possible to simplify, for example: 'sin^2(k())+cos^2(k())=1'.
1)The SymbolDatabase::findScope code is moved to the const-version. The non-const version is reimplemented as the combination with const_cast and static_cast.
2)Unrelated: change style of the declaration of some functions (the '*' is moved near the function name).
1)The non-const version of Token::tokAt and Token::linkAt now will use a combination of const_cast and static_cast to remove duplicate code.
2)The non-const versions of Token::find(simple)match are added, in order to avoid the usage of const_cast outside the Token code.
3)As a consequence of 2), an useless const_cast applied to a call of Token::findsimplematch in Tokenizer code is removed.