From bbd3a992b88f828f878d2c5a517b62c76bb711fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 25 Sep 2020 19:04:22 +0200 Subject: [PATCH] Fix output when note contains --- lib/checkother.cpp | 2 +- lib/errorlogger.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index b099dcf86..762673125 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1457,7 +1457,7 @@ void CheckOther::constVariableError(const Variable *var, const Function *functio std::string message = "$symbol:" + varname + "\n" + vartype + " '$symbol' can be declared with const"; errorPath.push_back(ErrorPathItem(var ? var->nameToken() : nullptr, message)); if (var && var->isArgument() && function && function->functionPointerUsage) { - errorPath.push_back(ErrorPathItem(function->functionPointerUsage, "You might need to cast the function pointer here")); + errorPath.push_front(ErrorPathItem(function->functionPointerUsage, "You might need to cast the function pointer here")); id += "Callback"; message += ". However it seems that '" + function->name() + "' is a callback function, if '$symbol' is declared with const you might also need to cast function pointer(s)."; } diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 6ef4b28d4..2e598d46b 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -151,7 +151,13 @@ ErrorMessage::ErrorMessage(const ErrorPath &errorPath, const TokenList *tokenLis // Format callstack for (const ErrorPathItem& e: errorPath) { const Token *tok = e.first; - const std::string &info = e.second; + std::string info = e.second; + + if (info.compare(0,8,"$symbol:") == 0 && info.find("\n") < info.size()) { + const std::string::size_type pos = info.find("\n"); + const std::string &symbolName = info.substr(8, pos - 8); + info = replaceStr(info.substr(pos+1), "$symbol", symbolName); + } // --errorlist can provide null values here if (tok)