fixed #11342 - cache `Library::getFunctionName()` calls in `Token`
cppcheck: build/token.cpp:3128: const std::string &Token::funcname(const Library &) const: Assertion `*mImpl->mFuncName == library.getFunctionName(this)' failed.
Internal error: cppcheck received signal SIGABRT - abort or assertion
Callstack:
#0 0x562da7e19d1c in Token::funcname[abi:cxx11](Library const&) const
#1 0x562da7d8cb93 in Library::returnValueType[abi:cxx11](Token const*) const
#2 0x562da7bb086e in SymbolDatabase::setValueTypeInTokenList(bool, Token*)
#3 0x562da7ba70bb in SymbolDatabase::SymbolDatabase(Tokenizer&, Settings const&, ErrorLogger&)
Library::returnValueType() checks if the given token isNotLibraryFunction(). This looks wrong to me because I would expect that the given token is supposed to be a type. Or is the wrong token passed into this?
Library::returnValueType()checks if the given tokenisNotLibraryFunction(). This looks wrong to me because I would expect that the given token is supposed to be a type. Or is the wrong token passed into this?
Still that shouldn't produce different results on subsequent calls on the same token. Since the library is immutable it seems like this is caused by some tokenizing/simplification.
The problem is that the astParent() is set on later calls.
From TestClass::memsetOnClass:
000001FE7416C2E0 astParent: 0000000000000000 previous: 000001FE7416DBA0 size
[...]
000001FE7416C2E0 astParent: 000001FE7416DBA0 previous: 000001FE7416DBA0 size std::vector::size
Assertion failed: *mImpl->mFuncName == library.getFunctionName(this), file S:\GitHub\cppcheck-fw\lib\token.cpp, line 273
I assume there is speedup but do you see it also?
I assume there is speedup but do you see it also?
Since it is still a draft (and not working as expected) I did not provide performance data yet. It is about 2-4% of the total Ir - that is also mentioned in the ticket.