ValueFlow: omit unnecessary location information from `valueFlowBailoutIncompleteVar` (#5583)
This is unnecessary since we only issue it from a single location. It also leads to a lot of unnecessary noise in the daca diff reports.
This commit is contained in:
parent
b58a6b6911
commit
a765a1310d
|
@ -132,8 +132,9 @@ static void bailoutInternal(const std::string& type, TokenList &tokenlist, Error
|
|||
if (function.find("operator") != std::string::npos)
|
||||
function = "(valueFlow)";
|
||||
std::list<ErrorMessage::FileLocation> callstack(1, ErrorMessage::FileLocation(tok, &tokenlist));
|
||||
const std::string location = Path::stripDirectoryPart(file) + ":" + std::to_string(line) + ":";
|
||||
ErrorMessage errmsg(callstack, tokenlist.getSourceFilePath(), Severity::debug,
|
||||
Path::stripDirectoryPart(file) + ":" + std::to_string(line) + ":" + function + " bailout: " + what, type, Certainty::normal);
|
||||
(file.empty() ? "" : location) + function + " bailout: " + what, type, Certainty::normal);
|
||||
errorLogger->reportErr(errmsg);
|
||||
}
|
||||
|
||||
|
@ -141,7 +142,7 @@ static void bailoutInternal(const std::string& type, TokenList &tokenlist, Error
|
|||
|
||||
#define bailout(tokenlist, errorLogger, tok, what) bailout2("valueFlowBailout", tokenlist, errorLogger, tok, what)
|
||||
|
||||
#define bailoutIncompleteVar(tokenlist, errorLogger, tok, what) bailout2("valueFlowBailoutIncompleteVar", tokenlist, errorLogger, tok, what)
|
||||
#define bailoutIncompleteVar(tokenlist, errorLogger, tok, what) bailoutInternal("valueFlowBailoutIncompleteVar", tokenlist, errorLogger, tok, what, "", 0, __func__)
|
||||
|
||||
static std::string debugString(const ValueFlow::Value& v)
|
||||
{
|
||||
|
|
|
@ -201,13 +201,14 @@ private:
|
|||
|
||||
(void)simplify;
|
||||
|
||||
// TODO: should be handled in a better way
|
||||
// filter out ValueFlow messages..
|
||||
const std::string debugwarnings = errout.str();
|
||||
errout.str("");
|
||||
std::istringstream istr2(debugwarnings);
|
||||
std::string line;
|
||||
while (std::getline(istr2,line)) {
|
||||
if (line.find("valueflow.cpp") == std::string::npos)
|
||||
if (line.find("bailout") == std::string::npos)
|
||||
errout << line << "\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -1949,7 +1949,7 @@ private:
|
|||
"( ( int * * * ) global [ 6 ] ) ( \"assoc\" , \"eggdrop\" , 106 , 0 ) ; "
|
||||
"}";
|
||||
ASSERT_EQUALS(expected, tok(code));
|
||||
ASSERT_EQUALS_WITHOUT_LINENUMBERS("[test.cpp:3]: (debug) valueflow.cpp:1319:valueFlowConditionExpressions bailout: Skipping function due to incomplete variable global\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable global\n", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef68() { // ticket #2355
|
||||
|
|
|
@ -3129,8 +3129,8 @@ private:
|
|||
// ticket #2991 - segmentation fault
|
||||
check("::y(){x}");
|
||||
|
||||
ASSERT_EQUALS_WITHOUT_LINENUMBERS("[test.cpp:1]: (debug) Executable scope 'y' with unknown function.\n"
|
||||
"[test.cpp:1]: (debug) valueflow.cpp:1321:valueFlowConditionExpressions bailout: Skipping function due to incomplete variable x\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:1]: (debug) Executable scope 'y' with unknown function.\n"
|
||||
"[test.cpp:1]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable x\n", errout.str());
|
||||
}
|
||||
|
||||
void symboldatabase20() {
|
||||
|
|
|
@ -459,13 +459,14 @@ private:
|
|||
std::istringstream istr(code);
|
||||
ASSERT_LOC(tokenizer.tokenize(istr, filename), file, linenr);
|
||||
|
||||
// TODO: handle in a better way
|
||||
// filter out ValueFlow messages..
|
||||
const std::string debugwarnings = errout.str();
|
||||
errout.str("");
|
||||
std::istringstream istr2(debugwarnings);
|
||||
std::string line;
|
||||
while (std::getline(istr2,line)) {
|
||||
if (line.find("valueflow.cpp") == std::string::npos)
|
||||
if (line.find("bailout") == std::string::npos)
|
||||
errout << line << "\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -1571,8 +1571,8 @@ private:
|
|||
" x = y;\n"
|
||||
" if (x == 123) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS_WITHOUT_LINENUMBERS(
|
||||
"[test.cpp:2]: (debug) valueflow.cpp::valueFlowConditionExpressions bailout: Skipping function due to incomplete variable y\n",
|
||||
ASSERT_EQUALS(
|
||||
"[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable y\n",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
|
@ -1695,8 +1695,8 @@ private:
|
|||
bailout("void f(int x) {\n"
|
||||
" y = ((x<0) ? x : ((x==2)?3:4));\n"
|
||||
"}");
|
||||
ASSERT_EQUALS_WITHOUT_LINENUMBERS(
|
||||
"[test.cpp:2]: (debug) valueflow.cpp::valueFlowConditionExpressions bailout: Skipping function due to incomplete variable y\n",
|
||||
ASSERT_EQUALS(
|
||||
"[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable y\n",
|
||||
errout.str());
|
||||
|
||||
bailout("int f(int x) {\n"
|
||||
|
@ -1760,8 +1760,8 @@ private:
|
|||
" if (x != 123) { b = x; }\n"
|
||||
" if (x == 123) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS_WITHOUT_LINENUMBERS(
|
||||
"[test.cpp:2]: (debug) valueflow.cpp::valueFlowConditionExpressions bailout: Skipping function due to incomplete variable b\n",
|
||||
ASSERT_EQUALS(
|
||||
"[test.cpp:2]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable b\n",
|
||||
errout.str());
|
||||
|
||||
code = "void f(int x, bool abc) {\n"
|
||||
|
@ -1809,8 +1809,8 @@ private:
|
|||
" case 2: if (x==5) {} break;\n"
|
||||
" };\n"
|
||||
"}");
|
||||
ASSERT_EQUALS_WITHOUT_LINENUMBERS(
|
||||
"[test.cpp:3]: (debug) valueflow.cpp::valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n",
|
||||
ASSERT_EQUALS(
|
||||
"[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n",
|
||||
errout.str());
|
||||
|
||||
bailout("void f(int x, int y) {\n"
|
||||
|
@ -1819,8 +1819,8 @@ private:
|
|||
" case 2: if (x==5) {} break;\n"
|
||||
" };\n"
|
||||
"}");
|
||||
ASSERT_EQUALS_WITHOUT_LINENUMBERS(
|
||||
"[test.cpp:3]: (debug) valueflow.cpp::valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n",
|
||||
ASSERT_EQUALS(
|
||||
"[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
|
@ -1832,7 +1832,7 @@ private:
|
|||
" M;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS_WITHOUT_LINENUMBERS(
|
||||
"[test.cpp:3]: (debug) valueflow.cpp::valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n"
|
||||
"[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n"
|
||||
"[test.cpp:4]: (debug) valueflow.cpp:1260:(valueFlow) bailout: variable 'x', condition is defined in macro\n",
|
||||
errout.str());
|
||||
|
||||
|
@ -1842,7 +1842,7 @@ private:
|
|||
" FREE(x);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS_WITHOUT_LINENUMBERS(
|
||||
"[test.cpp:3]: (debug) valueflow.cpp::valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n"
|
||||
"[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n"
|
||||
"[test.cpp:4]: (debug) valueflow.cpp:1260:(valueFlow) bailout: variable 'x', condition is defined in macro\n",
|
||||
errout.str());
|
||||
}
|
||||
|
@ -1856,7 +1856,7 @@ private:
|
|||
" if (x==123){}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS_WITHOUT_LINENUMBERS(
|
||||
"[test.cpp:3]: (debug) valueflow.cpp::valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n"
|
||||
"[test.cpp:3]: (debug) valueFlowConditionExpressions bailout: Skipping function due to incomplete variable a\n"
|
||||
"[test.cpp:2]: (debug) valueflow.cpp::(valueFlow) bailout: valueFlowAfterCondition: bailing in conditional block\n",
|
||||
errout.str());
|
||||
|
||||
|
|
Loading…
Reference in New Issue