Comment out code in valueFlowArray. There was too many false positives.

This commit is contained in:
Daniel Marjamäki 2019-01-02 19:57:11 +01:00
parent 39a96a5a16
commit 39ceb53578
2 changed files with 6 additions and 3 deletions

View File

@ -1019,7 +1019,9 @@ static void valueFlowArray(TokenList *tokenlist)
!tok->variable()->isStlType()) {
ValueFlow::Value value{1};
value.setKnown();
setTokenValue(tok, value, tokenlist->getSettings());
// TODO : this leads to too many false positives so it is commented out.
// See for instance https://github.com/danmar/cppcheck/commit/025881cf35fdde1299d16a09059e7305f8c9bd13
// setTokenValue(tok, value, tokenlist->getSettings());
}
const std::map<unsigned int, const Token *>::const_iterator it = constantArrays.find(tok->varId());
if (it != constantArrays.end()) {

View File

@ -2158,7 +2158,8 @@ private:
" X(do);\n"
" if (x > 100) {}\n"
"}");
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (style) Condition 'x>100' is always false\n", errout.str());
// TODO: we should probably throw unknownMacro InternalError. Complain that the macro X must be defined. We cant check the code well without the definition.
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (style) Condition 'x>100' is always false\n", "", errout.str());
check("void f(const int *i) {\n"
" if (!i) return;\n"
@ -2524,7 +2525,7 @@ private:
" int buf[42];\n"
" if( buf != 0) {}\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (style) Condition 'buf!=0' is always true\n", errout.str());
TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Condition 'buf!=0' is always true\n", "", errout.str()); // #8924
// Avoid FP when condition comes from macro
check("#define NOT !\n"