Skip to content

Commit

Permalink
Remove source lines in debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jun 24, 2023
1 parent 143b948 commit d9eeb0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
11 changes: 4 additions & 7 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,14 @@
#include <unordered_set>
#include <vector>

static void bailoutInternal(const std::string& type, TokenList *tokenlist, ErrorLogger *errorLogger, const Token *tok, const std::string &what, const std::string &file, int line, std::string function)
static void bailoutInternal(const std::string& type, TokenList *tokenlist, ErrorLogger *errorLogger, const Token *tok, const std::string &what)
{
if (function.find("operator") != std::string::npos)
function = "(valueFlow)";
std::list<ErrorMessage::FileLocation> callstack(1, ErrorMessage::FileLocation(tok, tokenlist));
ErrorMessage errmsg(callstack, tokenlist->getSourceFilePath(), Severity::debug,
Path::stripDirectoryPart(file) + ":" + MathLib::toString(line) + ":" + function + " bailout: " + what, type, Certainty::normal);
ErrorMessage errmsg(callstack, tokenlist->getSourceFilePath(), Severity::debug, "bailout: " + what, type, Certainty::normal);
errorLogger->reportErr(errmsg);
}

#define bailout2(type, tokenlist, errorLogger, tok, what) bailoutInternal(type, tokenlist, errorLogger, tok, what, __FILE__, __LINE__, __func__)
#define bailout2(type, tokenlist, errorLogger, tok, what) bailoutInternal(type, tokenlist, errorLogger, tok, what)

#define bailout(tokenlist, errorLogger, tok, what) bailout2("valueFlowBailout", tokenlist, errorLogger, tok, what)

Expand Down Expand Up @@ -5243,7 +5240,7 @@ static void valueFlowConditionExpressions(TokenList *tokenlist, const SymbolData
if (const Token* incompleteTok = findIncompleteVar(scope->bodyStart, scope->bodyEnd)) {
if (incompleteTok->isIncompleteVar()) {
if (settings.debugwarnings)
bailoutIncompleteVar(tokenlist, errorLogger, incompleteTok, "Skipping function due to incomplete variable " + incompleteTok->str());
bailoutIncompleteVar(tokenlist, errorLogger, incompleteTok, __func__ + (": Skipping function due to incomplete variable " + incompleteTok->str()));
break;
}
}
Expand Down
12 changes: 6 additions & 6 deletions test/testfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1948,8 +1948,8 @@ class TestFunctions : public TestFixture {
" it->g(0);\n"
"}\n", "test.cpp", &s);
TODO_ASSERT_EQUALS("",
"[test.cpp:4]: (debug) valueflow.cpp:6270:(valueFlow) bailout: variable 'it' used in loop\n"
"[test.cpp:4]: (debug) valueflow.cpp:6294:(valueFlow) bailout: variable 'l.end()' used in loop\n",
"[test.cpp:4]: (debug) bailout: variable 'it' used in loop\n"
"[test.cpp:4]: (debug) bailout: variable 'l.end()' used in loop\n",
errout.str());

check("auto f() {\n"
Expand Down Expand Up @@ -1978,7 +1978,7 @@ class TestFunctions : public TestFixture {
" if (t.find(\"abc\") != t.end()) {}\n"
"}\n", "test.cpp", &s);
TODO_ASSERT_EQUALS("",
"[test.cpp:6]: (debug) valueflow.cpp:6571:(valueFlow) bailout: valueFlowAfterCondition: bailing in conditional block\n",
"[test.cpp:6]: (debug) bailout: valueFlowAfterCondition: bailing in conditional block\n",
errout.str());

check("void f(std::vector<std::unordered_map<int, std::unordered_set<int>>>& v, int i, int j) {\n"
Expand Down Expand Up @@ -2027,9 +2027,9 @@ class TestFunctions : public TestFixture {
" if (t.at(0)) {}\n"
"};\n", "test.cpp", &s);
TODO_ASSERT_EQUALS("",
"[test.cpp:2]: (debug) valueflow.cpp:5246:valueFlowConditionExpressions bailout: Skipping function due to incomplete variable string\n"
"[test.cpp:4]: (debug) valueflow.cpp:6571:(valueFlow) bailout: valueFlowAfterCondition: bailing in conditional block\n"
"[test.cpp:7]: (debug) valueflow.cpp:6571:(valueFlow) bailout: valueFlowAfterCondition: bailing in conditional block\n",
"[test.cpp:2]: (debug) bailout: valueFlowConditionExpressions: Skipping function due to incomplete variable string\n"
"[test.cpp:4]: (debug) bailout: valueFlowAfterCondition: bailing in conditional block\n"
"[test.cpp:7]: (debug) bailout: valueFlowAfterCondition: bailing in conditional block\n",
errout.str());
}

Expand Down

0 comments on commit d9eeb0f

Please sign in to comment.