Skip to content

Conversation

@chrchr-github
Copy link
Collaborator

@chrchr-github chrchr-github commented Feb 24, 2023

It seems we cannot trigger this warning in any test, since setValueTypeInTokenList() is only called with reportDebugWarnings == true by simplifyTokens1().

@firewave
Copy link
Collaborator

firewave commented Feb 24, 2023

We could still add a TODO test case with a note about that.

But that looks like it might be unintended.

SymbolDatabase::setValueTypeInTokenList(false) is called in the SymbolDatabase constructor.

Tokenizer::simplifyTokens1() calls SymbolDatabase::setValueTypeInTokenList(true) explicitly after it called Tokenizer::createSymbolDatabase() which invokes the constructor.

So it looks like we call it again just to get the timing information and the potential debug warnings.

@firewave
Copy link
Collaborator

The constructor also calls setValueTypeInTokenList(false) twice but I guess that is intentional and necessary.

@firewave
Copy link
Collaborator

Removing the explicit call and changing the parameter of the second one in the constructor to true only leads to very few and quite subtle and strange differences in the test.

S:\GitHub\cppcheck-fw\test\testautovariables.cpp:2306(TestAutoVariables::danglingLifetimeContainer): Assertion failed.
Expected:
[test.cpp:3] -> [test.cpp:4] -> [test.cpp:2] -> [test.cpp:4]: (error) Returning pointer to local variable 'v' that will be invalid when returning.\n

Actual:
[test.cpp:3] -> [test.cpp:4] -> [test.cpp:2] -> [test.cpp:4]: (error) Returning object that points to local variable 'v' that will be invalid when returning.\n

_____
S:\GitHub\cppcheck-fw\test\testautovariables.cpp:3957(TestAutoVariables::danglingLifetimeClassMemberFunctions): Assertion failed.
Expected:
[test.cpp:4] -> [test.cpp:4] -> [test.cpp:7] -> [test.cpp:7]: (error) Returning pointer that will be invalid when returning.\n

Actual:
[test.cpp:4] -> [test.cpp:4] -> [test.cpp:7] -> [test.cpp:7]: (error) Returning object that will be invalid when returning.\n

_____
S:\GitHub\cppcheck-fw\test\testother.cpp:5303(TestOther::clarifyCalculation): Assertion failed.
Expected:

Actual:
[test.cpp:1]: (style) Clarify calculation precedence for '&' and '?'.\n

_____
S:\GitHub\cppcheck-fw\test\teststl.cpp:1849(TestStl::iteratorExpression): Assertion failed.
Expected:
[test.cpp:6]: (error) Iterators of different containers 'A().f()' and 'A().g()' are used together.\n

Actual:
[test.cpp:6]: (warning) Iterators to containers from different expressions 'A().f()' and 'A().g()' are used together.\n

_____
S:\GitHub\cppcheck-fw\test\testsymboldatabase.cpp:7013(TestSymbolDatabase::findFunction44): Assertion failed.
_____
S:\GitHub\cppcheck-fw\test\testsymboldatabase.cpp:7073(TestSymbolDatabase::findFunction46): Assertion failed.

@chrchr-github
Copy link
Collaborator Author

That could still indicate serious wreckage...

@firewave
Copy link
Collaborator

It definitely needs some documentation (i.e. comments) why are we doing multiple calls of it.

@chrchr-github
Copy link
Collaborator Author

Can we merge this?

@danmar danmar merged commit e2b2fc2 into danmar:main Mar 12, 2023
@chrchr-github chrchr-github deleted the chr_AutoNoType branch March 13, 2023 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants