Skip to content

Commit 30cae35

Browse files
committed
Removed the --value-flow flag. ValueFlow analysis will always be enabled from now on.
1 parent 5721e1d commit 30cae35

11 files changed

Lines changed: 31 additions & 47 deletions

cli/cmdlineparser.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,6 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
302302
_settings->_xml = true;
303303
}
304304

305-
// Enable experimental value flow analysis
306-
else if (std::strcmp(argv[i], "--value-flow") == 0)
307-
_settings->valueFlow = true;
308-
309305
// Only print something when there are errors
310306
else if (std::strcmp(argv[i], "-q") == 0 || std::strcmp(argv[i], "--quiet") == 0)
311307
_settings->_errorsOnly = true;

lib/checknullpointer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,6 @@ void CheckNullPointer::nullPointerStructByDeRefAndChec()
751751

752752
void CheckNullPointer::nullPointerByDeRefAndChec()
753753
{
754-
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
755-
756754
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
757755
if (!tok->isName() || tok->values.empty())
758756
continue;

lib/settings.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ Settings::Settings()
4040
enforcedLang(None),
4141
reportProgress(false),
4242
checkConfiguration(false),
43-
checkLibrary(false),
44-
valueFlow(false)
43+
checkLibrary(false)
4544
{
4645
// This assumes the code you are checking is for the same architecture this is compiled on.
4746
#if defined(_WIN64)

lib/settings.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ class CPPCHECKLIB Settings {
251251
platformType == Win32W ||
252252
platformType == Win64;
253253
}
254-
255-
bool valueFlow;
256254
};
257255

258256
/// @}

lib/tokenize.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,8 +1605,7 @@ bool Tokenizer::tokenize(std::istream &code,
16051605

16061606
list.createAst();
16071607

1608-
if (_settings->valueFlow)
1609-
ValueFlow::setValues(&list, _errorLogger, _settings);
1608+
ValueFlow::setValues(&list, _errorLogger, _settings);
16101609

16111610
return true;
16121611
}

test/testbufferoverrun.cpp

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,6 @@ class TestBufferOverrun : public TestFixture {
7272
checkBufferOverrun.writeOutsideBufferSize();
7373
}
7474

75-
void checkValueFlow(const char code[]) {
76-
// Clear the error buffer..
77-
errout.str("");
78-
79-
Settings settings;
80-
settings.valueFlow = true;
81-
settings.addEnabled("warning");
82-
83-
// Tokenize..
84-
Tokenizer tokenizer(&settings, this);
85-
std::istringstream istr(code);
86-
tokenizer.tokenize(istr, "test.cpp");
87-
tokenizer.simplifyTokenList2();
88-
89-
// Check for buffer overruns..
90-
CheckBufferOverrun checkBufferOverrun(&tokenizer, &settings, this);
91-
checkBufferOverrun.bufferOverrun();
92-
}
93-
9475
void run() {
9576
TEST_CASE(noerr1);
9677
TEST_CASE(noerr2);
@@ -417,7 +398,8 @@ class TestBufferOverrun : public TestFixture {
417398
" for (i = 0; i < 100; i++)\n"
418399
" sum += val[i];\n"
419400
"}");
420-
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer is accessed out of bounds: val\n", errout.str());
401+
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer is accessed out of bounds: val\n"
402+
"[test.cpp:6]: (error) Array 'val[50]' accessed at index 99, which is out of bounds.\n", errout.str());
421403
}
422404

423405
{
@@ -428,7 +410,8 @@ class TestBufferOverrun : public TestFixture {
428410
" for (i = 1; i < 100; i++)\n"
429411
" sum += val[i];\n"
430412
"}");
431-
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer is accessed out of bounds: val\n", errout.str());
413+
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer is accessed out of bounds: val\n"
414+
"[test.cpp:6]: (error) Array 'val[50]' accessed at index 99, which is out of bounds.\n", errout.str());
432415
}
433416

434417

@@ -1825,7 +1808,8 @@ class TestBufferOverrun : public TestFixture {
18251808
" data[x] = 0;\n"
18261809
" }"
18271810
"}");
1828-
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n", errout.str());
1811+
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n"
1812+
"[test.cpp:5]: (error) Array 'data[2]' accessed at index 9, which is out of bounds.\n", errout.str());
18291813

18301814
check("void f() {\n"
18311815
" char data[2];\n"
@@ -1834,7 +1818,8 @@ class TestBufferOverrun : public TestFixture {
18341818
" data[x] = 0;\n"
18351819
" }"
18361820
"}");
1837-
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n", errout.str());
1821+
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n"
1822+
"[test.cpp:5]: (error) Array 'data[2]' accessed at index 9, which is out of bounds.\n", errout.str());
18381823

18391824
check("void f() {\n"
18401825
" char data[2];\n"
@@ -1843,7 +1828,8 @@ class TestBufferOverrun : public TestFixture {
18431828
" data[x] = 0;\n"
18441829
" }"
18451830
"}");
1846-
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n", errout.str());
1831+
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n"
1832+
"[test.cpp:5]: (error) Array 'data[2]' accessed at index 10, which is out of bounds.\n", errout.str());
18471833

18481834
check("void f() {\n"
18491835
" char data[2];\n"
@@ -2071,11 +2057,11 @@ class TestBufferOverrun : public TestFixture {
20712057
}
20722058

20732059
void array_index_valueflow() {
2074-
checkValueFlow("void f(int i) {\n"
2075-
" char str[3];\n"
2076-
" str[i] = 0;\n"
2077-
" if (i==10) {}\n"
2078-
"}");
2060+
check("void f(int i) {\n"
2061+
" char str[3];\n"
2062+
" str[i] = 0;\n"
2063+
" if (i==10) {}\n"
2064+
"}");
20792065
ASSERT_EQUALS("[test.cpp:3]: (error) Array 'str[3]' accessed at index 10, which is out of bounds.\n", errout.str());
20802066
}
20812067

@@ -2614,7 +2600,8 @@ class TestBufferOverrun : public TestFixture {
26142600
" for (size_t i = 0; i <= 4; i++)\n"
26152601
" dst[i] = src[i];\n"
26162602
"} } }\n");
2617-
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer is accessed out of bounds: dst\n", errout.str());
2603+
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer is accessed out of bounds: dst\n"
2604+
"[test.cpp:6]: (error) Array 'dst[4]' accessed at index 4, which is out of bounds.\n", errout.str());
26182605
}
26192606

26202607
void buffer_overrun_22() { // ticket #3124

test/testnullpointer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ class TestNullPointer : public TestFixture {
8686
Settings settings;
8787
settings.addEnabled("warning");
8888
settings.inconclusive = inconclusive;
89-
settings.valueFlow = true;
9089

9190
// cfg
9291
const char cfg[] = "<?xml version=\"1.0\"?>\n"

test/testother.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ class TestOther : public TestFixture {
210210
settings->inconclusive = inconclusive;
211211
settings->experimental = experimental;
212212
settings->standards.posix = posix;
213-
settings->valueFlow = true;
214213

215214
if (posix) {
216215
const char cfg[] = "<?xml version=\"1.0\"?>\n"

test/testtokenize.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,16 @@ class TestTokenizer : public TestFixture {
577577
if (simplify)
578578
tokenizer.simplifyTokenList2();
579579

580+
// filter out ValueFlow messages..
581+
const std::string debugwarnings = errout.str();
582+
errout.str("");
583+
std::istringstream istr2(debugwarnings.c_str());
584+
std::string line;
585+
while (std::getline(istr2,line)) {
586+
if (line.find("ValueFlow") == std::string::npos)
587+
errout << line << "\n";
588+
}
589+
580590
return tokenizer.tokens()->stringifyList(false, expand, false, true, false, 0, 0);
581591
}
582592

test/testuninitvar.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3115,7 +3115,8 @@ class TestUninitVar : public TestFixture {
31153115
" int a;\n"
31163116
" do { } a=do_something(); while (a);\n"
31173117
"}\n", "test.cpp", /*verify=*/true, /*debugwarnings=*/true);
3118-
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n"
3118+
ASSERT_EQUALS("[test.cpp:3]: (debug) ValueFlow bailout: assignment of a\n"
3119+
"[test.cpp:3]: (error) Uninitialized variable: a\n"
31193120
"[test.cpp:3]: (debug) assertion failed '} while ('\n", errout.str());
31203121

31213122
checkUninitVar2("void f() {\n"

0 commit comments

Comments
 (0)