Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Oct 4, 2023
1 parent f371924 commit a229bbf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7258,7 +7258,8 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
}

bool stopOnCondition(const Token* /*condTok*/) const override {
return isConditional();
// TODO fix false negatives
return true; // isConditional();
}

bool updateScope(const Token* endBlock, bool /*modified*/) const override {
Expand Down
11 changes: 6 additions & 5 deletions test/teststl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2386,11 +2386,12 @@ class TestStl : public TestFixture {
"void g(const std::vector<int>& w) {\n"
" f(-1, w);\n"
"}\n");
ASSERT_EQUALS("test.cpp:5:warning:Array index -1 is out of bounds.\n"
"test.cpp:8:note:Calling function 'f', 1st argument '-1' value is -1\n"
"test.cpp:3:note:Assuming condition is false\n"
"test.cpp:5:note:Negative array index\n",
errout.str());
TODO_ASSERT_EQUALS("test.cpp:5:warning:Array index -1 is out of bounds.\n"
"test.cpp:8:note:Calling function 'f', 1st argument '-1' value is -1\n"
"test.cpp:3:note:Assuming condition is false\n"
"test.cpp:5:note:Negative array index\n",
"",
errout.str());

settings = oldSettings;
}
Expand Down
2 changes: 1 addition & 1 deletion test/testuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6490,7 +6490,7 @@ class TestUninitVar : public TestFixture {
" bool copied_all = true;\n"
" g(&copied_all, 5, 6, &bytesCopied);\n"
"}");
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:2]: (warning) Uninitialized variable: *buflen\n", errout.str());
TODO_ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:2]: (warning) Uninitialized variable: *buflen\n", "", errout.str());

// # 9953
valueFlowUninit("uint32_t f(uint8_t *mem) {\n"
Expand Down
2 changes: 1 addition & 1 deletion test/testvalueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4517,7 +4517,7 @@ class TestValueFlow : public TestFixture {
"void f(Object *obj) {\n"
" if (valid(obj, K0)) {}\n"
"}\n";
ASSERT_EQUALS(true, testValueOfX(code, 7U, 0));
TODO_ASSERT_EQUALS(true, false, testValueOfX(code, 7U, 0));
ASSERT_EQUALS(false, testValueOfXKnown(code, 7U, 0));

code = "int f(int i) {\n"
Expand Down

0 comments on commit a229bbf

Please sign in to comment.