MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / setmsg

Method setmsg

lib/errorlogger.cpp:221–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221void ErrorMessage::setmsg(const std::string &msg)
222{
223 // If a message ends to a '\n' and contains only a one '\n'
224 // it will cause the mVerboseMessage to be empty which will show
225 // as an empty message to the user if --verbose is used.
226 // Even this doesn't cause problems with messages that have multiple
227 // lines, none of the error messages should end into it.
228 assert(!endsWith(msg,'\n'));
229
230 // The summary and verbose message are separated by a newline
231 // If there is no newline then both the summary and verbose messages
232 // are the given message
233 const std::string::size_type pos = msg.find('\n');
234 const std::string symbolName = mSymbolNames.empty() ? std::string() : mSymbolNames.substr(0, mSymbolNames.find('\n'));
235 if (pos == std::string::npos) {
236 mShortMessage = replaceStr(msg, "$symbol", symbolName);
237 mVerboseMessage = replaceStr(msg, "$symbol", symbolName);
238 } else if (startsWith(msg,"$symbol:")) {
239 mSymbolNames += msg.substr(8, pos-7);
240 setmsg(msg.substr(pos + 1));
241 } else {
242 mShortMessage = replaceStr(msg.substr(0, pos), "$symbol", symbolName);
243 mVerboseMessage = replaceStr(msg.substr(pos + 1), "$symbol", symbolName);
244 }
245}
246
247static void serializeString(std::string &oss, const std::string & str)
248{

Callers 3

executeAddonsMethod · 0.80
analyseClangTidyMethod · 0.80
writeCheckersReportMethod · 0.80

Calls 5

replaceStrFunction · 0.85
endsWithFunction · 0.70
startsWithFunction · 0.70
findMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected