diff --git a/lib/check.cpp b/lib/check.cpp index 6dc506e81..94d555dbf 100644 --- a/lib/check.cpp +++ b/lib/check.cpp @@ -75,3 +75,21 @@ std::string Check::getMessageId(const ValueFlow::Value &value, const char id[]) return std::string("safe") + (char)std::toupper(id[0]) + (id + 1); return id; } + +ErrorPath Check::getErrorPath(const Token* errtok, const ValueFlow::Value* value, const std::string& bug) const +{ + ErrorPath errorPath; + if (!value) { + errorPath.emplace_back(errtok, bug); + } else if (mSettings->verbose || mSettings->xml || !mSettings->templateLocation.empty()) { + errorPath = value->errorPath; + errorPath.emplace_back(errtok, bug); + } else { + if (value->condition) + errorPath.emplace_back(value->condition, "condition '" + value->condition->expressionString() + "'"); + //else if (!value->isKnown() || value->defaultArg) + // errorPath = value->callstack; + errorPath.emplace_back(errtok, bug); + } + return errorPath; +} \ No newline at end of file diff --git a/lib/check.h b/lib/check.h index e2784f086..ace4c24f1 100644 --- a/lib/check.h +++ b/lib/check.h @@ -162,22 +162,7 @@ protected: reportError(errmsg); } - ErrorPath getErrorPath(const Token *errtok, const ValueFlow::Value *value, const std::string &bug) const { - ErrorPath errorPath; - if (!value) { - errorPath.emplace_back(errtok,bug); - } else if (mSettings->verbose || mSettings->xml || !mSettings->templateLocation.empty()) { - errorPath = value->errorPath; - errorPath.emplace_back(errtok,bug); - } else { - if (value->condition) - errorPath.emplace_back(value->condition, "condition '" + value->condition->expressionString() + "'"); - //else if (!value->isKnown() || value->defaultArg) - // errorPath = value->callstack; - errorPath.emplace_back(errtok,bug); - } - return errorPath; - } + ErrorPath getErrorPath(const Token* errtok, const ValueFlow::Value* value, const std::string& bug) const; /** * Use WRONG_DATA in checkers when you check for wrong data. That