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;
|
_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
|
// Only print something when there are errors
|
||||||
else if (std::strcmp(argv[i], "-q") == 0 || std::strcmp(argv[i], "--quiet") == 0)
|
else if (std::strcmp(argv[i], "-q") == 0 || std::strcmp(argv[i], "--quiet") == 0)
|
||||||
_settings->_errorsOnly = true;
|
_settings->_errorsOnly = true;
|
||||||
|
@ -751,8 +751,6 @@ void CheckNullPointer::nullPointerStructByDeRefAndChec()
|
|||||||
|
|
||||||
void CheckNullPointer::nullPointerByDeRefAndChec()
|
void CheckNullPointer::nullPointerByDeRefAndChec()
|
||||||
{
|
{
|
||||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
|
||||||
|
|
||||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||||
if (!tok->isName() || tok->values.empty())
|
if (!tok->isName() || tok->values.empty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -40,8 +40,7 @@ Settings::Settings()
|
|||||||
enforcedLang(None),
|
enforcedLang(None),
|
||||||
reportProgress(false),
|
reportProgress(false),
|
||||||
checkConfiguration(false),
|
checkConfiguration(false),
|
||||||
checkLibrary(false),
|
checkLibrary(false)
|
||||||
valueFlow(false)
|
|
||||||
{
|
{
|
||||||
// This assumes the code you are checking is for the same architecture this is compiled on.
|
// This assumes the code you are checking is for the same architecture this is compiled on.
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
|
@ -251,8 +251,6 @@ public:
|
|||||||
platformType == Win32W ||
|
platformType == Win32W ||
|
||||||
platformType == Win64;
|
platformType == Win64;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool valueFlow;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
@ -1605,7 +1605,6 @@ bool Tokenizer::tokenize(std::istream &code,
|
|||||||
|
|
||||||
list.createAst();
|
list.createAst();
|
||||||
|
|
||||||
if (_settings->valueFlow)
|
|
||||||
ValueFlow::setValues(&list, _errorLogger, _settings);
|
ValueFlow::setValues(&list, _errorLogger, _settings);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -72,25 +72,6 @@ private:
|
|||||||
checkBufferOverrun.writeOutsideBufferSize();
|
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() {
|
void run() {
|
||||||
TEST_CASE(noerr1);
|
TEST_CASE(noerr1);
|
||||||
TEST_CASE(noerr2);
|
TEST_CASE(noerr2);
|
||||||
@ -417,7 +398,8 @@ private:
|
|||||||
" for (i = 0; i < 100; i++)\n"
|
" for (i = 0; i < 100; i++)\n"
|
||||||
" sum += val[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"
|
" for (i = 1; i < 100; i++)\n"
|
||||||
" sum += val[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"
|
" 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"
|
check("void f() {\n"
|
||||||
" char data[2];\n"
|
" char data[2];\n"
|
||||||
@ -1834,7 +1818,8 @@ private:
|
|||||||
" data[x] = 0;\n"
|
" 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"
|
check("void f() {\n"
|
||||||
" char data[2];\n"
|
" char data[2];\n"
|
||||||
@ -1843,7 +1828,8 @@ private:
|
|||||||
" data[x] = 0;\n"
|
" 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"
|
check("void f() {\n"
|
||||||
" char data[2];\n"
|
" char data[2];\n"
|
||||||
@ -2071,7 +2057,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void array_index_valueflow() {
|
void array_index_valueflow() {
|
||||||
checkValueFlow("void f(int i) {\n"
|
check("void f(int i) {\n"
|
||||||
" char str[3];\n"
|
" char str[3];\n"
|
||||||
" str[i] = 0;\n"
|
" str[i] = 0;\n"
|
||||||
" if (i==10) {}\n"
|
" if (i==10) {}\n"
|
||||||
@ -2614,7 +2600,8 @@ private:
|
|||||||
" for (size_t i = 0; i <= 4; i++)\n"
|
" for (size_t i = 0; i <= 4; i++)\n"
|
||||||
" dst[i] = src[i];\n"
|
" dst[i] = src[i];\n"
|
||||||
"} } }\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
|
void buffer_overrun_22() { // ticket #3124
|
||||||
|
@ -86,7 +86,6 @@ private:
|
|||||||
Settings settings;
|
Settings settings;
|
||||||
settings.addEnabled("warning");
|
settings.addEnabled("warning");
|
||||||
settings.inconclusive = inconclusive;
|
settings.inconclusive = inconclusive;
|
||||||
settings.valueFlow = true;
|
|
||||||
|
|
||||||
// cfg
|
// cfg
|
||||||
const char cfg[] = "<?xml version=\"1.0\"?>\n"
|
const char cfg[] = "<?xml version=\"1.0\"?>\n"
|
||||||
|
@ -210,7 +210,6 @@ private:
|
|||||||
settings->inconclusive = inconclusive;
|
settings->inconclusive = inconclusive;
|
||||||
settings->experimental = experimental;
|
settings->experimental = experimental;
|
||||||
settings->standards.posix = posix;
|
settings->standards.posix = posix;
|
||||||
settings->valueFlow = true;
|
|
||||||
|
|
||||||
if (posix) {
|
if (posix) {
|
||||||
const char cfg[] = "<?xml version=\"1.0\"?>\n"
|
const char cfg[] = "<?xml version=\"1.0\"?>\n"
|
||||||
|
@ -577,6 +577,16 @@ private:
|
|||||||
if (simplify)
|
if (simplify)
|
||||||
tokenizer.simplifyTokenList2();
|
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);
|
return tokenizer.tokens()->stringifyList(false, expand, false, true, false, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3115,7 +3115,8 @@ private:
|
|||||||
" int a;\n"
|
" int a;\n"
|
||||||
" do { } a=do_something(); while (a);\n"
|
" do { } a=do_something(); while (a);\n"
|
||||||
"}\n", "test.cpp", /*verify=*/true, /*debugwarnings=*/true);
|
"}\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());
|
"[test.cpp:3]: (debug) assertion failed '} while ('\n", errout.str());
|
||||||
|
|
||||||
checkUninitVar2("void f() {\n"
|
checkUninitVar2("void f() {\n"
|
||||||
|
@ -41,7 +41,6 @@ private:
|
|||||||
|
|
||||||
bool testValueOfX(const std::string &code, unsigned int linenr, int value) {
|
bool testValueOfX(const std::string &code, unsigned int linenr, int value) {
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.valueFlow = true; // temporary flag
|
|
||||||
|
|
||||||
// strcpy cfg
|
// strcpy cfg
|
||||||
const char cfg[] = "<?xml version=\"1.0\"?>\n"
|
const char cfg[] = "<?xml version=\"1.0\"?>\n"
|
||||||
@ -71,7 +70,6 @@ private:
|
|||||||
|
|
||||||
void bailout(const char code[]) {
|
void bailout(const char code[]) {
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.valueFlow = true; // temporary flag
|
|
||||||
settings.debugwarnings = true;
|
settings.debugwarnings = true;
|
||||||
|
|
||||||
// Tokenize..
|
// Tokenize..
|
||||||
|
Loading…
x
Reference in New Issue
Block a user