Removed the --value-flow flag. ValueFlow analysis will always be enabled from now on.
This commit is contained in:
parent
5721e1d745
commit
30cae358d8
|
@ -302,10 +302,6 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
_settings->_xml = true;
|
||||
}
|
||||
|
||||
// Enable experimental value flow analysis
|
||||
else if (std::strcmp(argv[i], "--value-flow") == 0)
|
||||
_settings->valueFlow = true;
|
||||
|
||||
// Only print something when there are errors
|
||||
else if (std::strcmp(argv[i], "-q") == 0 || std::strcmp(argv[i], "--quiet") == 0)
|
||||
_settings->_errorsOnly = true;
|
||||
|
|
|
@ -751,8 +751,6 @@ void CheckNullPointer::nullPointerStructByDeRefAndChec()
|
|||
|
||||
void CheckNullPointer::nullPointerByDeRefAndChec()
|
||||
{
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
if (!tok->isName() || tok->values.empty())
|
||||
continue;
|
||||
|
|
|
@ -40,8 +40,7 @@ Settings::Settings()
|
|||
enforcedLang(None),
|
||||
reportProgress(false),
|
||||
checkConfiguration(false),
|
||||
checkLibrary(false),
|
||||
valueFlow(false)
|
||||
checkLibrary(false)
|
||||
{
|
||||
// This assumes the code you are checking is for the same architecture this is compiled on.
|
||||
#if defined(_WIN64)
|
||||
|
|
|
@ -251,8 +251,6 @@ public:
|
|||
platformType == Win32W ||
|
||||
platformType == Win64;
|
||||
}
|
||||
|
||||
bool valueFlow;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
|
|
@ -1605,8 +1605,7 @@ bool Tokenizer::tokenize(std::istream &code,
|
|||
|
||||
list.createAst();
|
||||
|
||||
if (_settings->valueFlow)
|
||||
ValueFlow::setValues(&list, _errorLogger, _settings);
|
||||
ValueFlow::setValues(&list, _errorLogger, _settings);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -72,25 +72,6 @@ private:
|
|||
checkBufferOverrun.writeOutsideBufferSize();
|
||||
}
|
||||
|
||||
void checkValueFlow(const char code[]) {
|
||||
// Clear the error buffer..
|
||||
errout.str("");
|
||||
|
||||
Settings settings;
|
||||
settings.valueFlow = true;
|
||||
settings.addEnabled("warning");
|
||||
|
||||
// Tokenize..
|
||||
Tokenizer tokenizer(&settings, this);
|
||||
std::istringstream istr(code);
|
||||
tokenizer.tokenize(istr, "test.cpp");
|
||||
tokenizer.simplifyTokenList2();
|
||||
|
||||
// Check for buffer overruns..
|
||||
CheckBufferOverrun checkBufferOverrun(&tokenizer, &settings, this);
|
||||
checkBufferOverrun.bufferOverrun();
|
||||
}
|
||||
|
||||
void run() {
|
||||
TEST_CASE(noerr1);
|
||||
TEST_CASE(noerr2);
|
||||
|
@ -417,7 +398,8 @@ private:
|
|||
" for (i = 0; i < 100; i++)\n"
|
||||
" sum += val[i];\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer is accessed out of bounds: val\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer is accessed out of bounds: val\n"
|
||||
"[test.cpp:6]: (error) Array 'val[50]' accessed at index 99, which is out of bounds.\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -428,7 +410,8 @@ private:
|
|||
" for (i = 1; i < 100; i++)\n"
|
||||
" sum += val[i];\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer is accessed out of bounds: val\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer is accessed out of bounds: val\n"
|
||||
"[test.cpp:6]: (error) Array 'val[50]' accessed at index 99, which is out of bounds.\n", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1825,7 +1808,8 @@ private:
|
|||
" data[x] = 0;\n"
|
||||
" }"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n"
|
||||
"[test.cpp:5]: (error) Array 'data[2]' accessed at index 9, which is out of bounds.\n", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" char data[2];\n"
|
||||
|
@ -1834,7 +1818,8 @@ private:
|
|||
" data[x] = 0;\n"
|
||||
" }"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n"
|
||||
"[test.cpp:5]: (error) Array 'data[2]' accessed at index 9, which is out of bounds.\n", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" char data[2];\n"
|
||||
|
@ -1843,7 +1828,8 @@ private:
|
|||
" data[x] = 0;\n"
|
||||
" }"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: data\n"
|
||||
"[test.cpp:5]: (error) Array 'data[2]' accessed at index 10, which is out of bounds.\n", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" char data[2];\n"
|
||||
|
@ -2071,11 +2057,11 @@ private:
|
|||
}
|
||||
|
||||
void array_index_valueflow() {
|
||||
checkValueFlow("void f(int i) {\n"
|
||||
" char str[3];\n"
|
||||
" str[i] = 0;\n"
|
||||
" if (i==10) {}\n"
|
||||
"}");
|
||||
check("void f(int i) {\n"
|
||||
" char str[3];\n"
|
||||
" str[i] = 0;\n"
|
||||
" if (i==10) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Array 'str[3]' accessed at index 10, which is out of bounds.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -2614,7 +2600,8 @@ private:
|
|||
" for (size_t i = 0; i <= 4; i++)\n"
|
||||
" dst[i] = src[i];\n"
|
||||
"} } }\n");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer is accessed out of bounds: dst\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Buffer is accessed out of bounds: dst\n"
|
||||
"[test.cpp:6]: (error) Array 'dst[4]' accessed at index 4, which is out of bounds.\n", errout.str());
|
||||
}
|
||||
|
||||
void buffer_overrun_22() { // ticket #3124
|
||||
|
|
|
@ -86,7 +86,6 @@ private:
|
|||
Settings settings;
|
||||
settings.addEnabled("warning");
|
||||
settings.inconclusive = inconclusive;
|
||||
settings.valueFlow = true;
|
||||
|
||||
// cfg
|
||||
const char cfg[] = "<?xml version=\"1.0\"?>\n"
|
||||
|
|
|
@ -210,7 +210,6 @@ private:
|
|||
settings->inconclusive = inconclusive;
|
||||
settings->experimental = experimental;
|
||||
settings->standards.posix = posix;
|
||||
settings->valueFlow = true;
|
||||
|
||||
if (posix) {
|
||||
const char cfg[] = "<?xml version=\"1.0\"?>\n"
|
||||
|
|
|
@ -577,6 +577,16 @@ private:
|
|||
if (simplify)
|
||||
tokenizer.simplifyTokenList2();
|
||||
|
||||
// filter out ValueFlow messages..
|
||||
const std::string debugwarnings = errout.str();
|
||||
errout.str("");
|
||||
std::istringstream istr2(debugwarnings.c_str());
|
||||
std::string line;
|
||||
while (std::getline(istr2,line)) {
|
||||
if (line.find("ValueFlow") == std::string::npos)
|
||||
errout << line << "\n";
|
||||
}
|
||||
|
||||
return tokenizer.tokens()->stringifyList(false, expand, false, true, false, 0, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -3115,7 +3115,8 @@ private:
|
|||
" int a;\n"
|
||||
" do { } a=do_something(); while (a);\n"
|
||||
"}\n", "test.cpp", /*verify=*/true, /*debugwarnings=*/true);
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n"
|
||||
ASSERT_EQUALS("[test.cpp:3]: (debug) ValueFlow bailout: assignment of a\n"
|
||||
"[test.cpp:3]: (error) Uninitialized variable: a\n"
|
||||
"[test.cpp:3]: (debug) assertion failed '} while ('\n", errout.str());
|
||||
|
||||
checkUninitVar2("void f() {\n"
|
||||
|
|
|
@ -41,7 +41,6 @@ private:
|
|||
|
||||
bool testValueOfX(const std::string &code, unsigned int linenr, int value) {
|
||||
Settings settings;
|
||||
settings.valueFlow = true; // temporary flag
|
||||
|
||||
// strcpy cfg
|
||||
const char cfg[] = "<?xml version=\"1.0\"?>\n"
|
||||
|
@ -71,7 +70,6 @@ private:
|
|||
|
||||
void bailout(const char code[]) {
|
||||
Settings settings;
|
||||
settings.valueFlow = true; // temporary flag
|
||||
settings.debugwarnings = true;
|
||||
|
||||
// Tokenize..
|
||||
|
|
Loading…
Reference in New Issue