void ThreadResult::reportErr(const ErrorLogger::ErrorMessage &msg) { QMutexLocker locker(&mutex); QList<unsigned int> lines; QStringList files; for (std::list<ErrorLogger::ErrorMessage::FileLocation>::const_iterator tok = msg._callStack.begin(); tok != msg._callStack.end(); ++tok) { files << QString((*tok).getfile(false).c_str()); lines << (*tok).line; } ErrorItem item; item.file = QString(callStackToString(msg._callStack).c_str()); item.files = files; item.id = QString(msg._id.c_str()); item.lines = lines; item.summary = QString::fromStdString(msg.shortMessage()); item.message = QString::fromStdString(msg.verboseMessage()); item.severity = msg._severity; item.inconclusive = msg._inconclusive; if (msg._severity != Severity::debug) emit Error(item); else emit DebugError(item); }
void xml() { // Test the errorlogger.. ErrorLogger::ErrorMessage errmsg; errmsg._msg = "ab<cd>ef"; ASSERT_EQUALS("<error id=\"\" severity=\"\" msg=\"ab<cd>ef\"/>", errmsg.toXML()); }
int ThreadExecutor::handleRead(int rpipe, unsigned int &result) { char type = 0; if (read(rpipe, &type, 1) <= 0) { if (errno == EAGAIN) return 0; return -1; } if (type != REPORT_OUT && type != REPORT_ERROR && type != REPORT_INFO && type != CHILD_END) { std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl; exit(0); } unsigned int len = 0; if (read(rpipe, &len, sizeof(len)) <= 0) { std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl; exit(0); } char *buf = new char[len]; if (read(rpipe, buf, len) <= 0) { std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl; exit(0); } if (type == REPORT_OUT) { _errorLogger.reportOut(buf); } else if (type == REPORT_ERROR || type == REPORT_INFO) { ErrorLogger::ErrorMessage msg; msg.deserialize(buf); std::string file; unsigned int line(0); if (!msg._callStack.empty()) { file = msg._callStack.back().getfile(false); line = msg._callStack.back().line; } if (!_settings.nomsg.isSuppressed(msg._id, file, line)) { // Alert only about unique errors std::string errmsg = msg.toString(_settings._verbose); if (std::find(_errorList.begin(), _errorList.end(), errmsg) == _errorList.end()) { _errorList.push_back(errmsg); if (type == REPORT_ERROR) _errorLogger.reportErr(msg); else _errorLogger.reportInfo(msg); } } } else if (type == CHILD_END) { std::istringstream iss(buf); unsigned int fileResult = 0; iss >> fileResult; result += fileResult; delete [] buf; return -1; }
void include() { ErrorLogger::ErrorMessage errmsg; ErrorLogger::ErrorMessage::FileLocation loc; loc.file = "ab/cd/../ef.h"; errmsg._callStack.push_back(loc); ASSERT_EQUALS("<error file=\"ab/ef.h\" line=\"0\" id=\"\" severity=\"\" msg=\"\"/>", errmsg.toXML()); ASSERT_EQUALS("[ab/ef.h:0]: ", errmsg.toText()); }
void CppCheckExecutor::reportErr(const ErrorLogger::ErrorMessage &msg) { if (errorlist) { reportOut(msg.toXML(false, _settings->_xml_version)); } else if (_settings->_xml) { reportErr(msg.toXML(_settings->_verbose, _settings->_xml_version)); } else { reportErr(msg.toString(_settings->_verbose, _settings->_outputFormat)); } }
void CppCheckExecutor::reportErr(const ErrorLogger::ErrorMessage &msg) { if (_settings._xml) { reportErr(msg.toXML()); } else { reportErr(msg.toText()); } }
bool ThreadExecutor::handleRead(unsigned int &result) { char type = 0; if (read(_pipe[0], &type, 1) <= 0) { return false; } if (type != '1' && type != '2' && type != '3') { std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl; exit(0); } unsigned int len = 0; if (read(_pipe[0], &len, sizeof(len)) <= 0) { std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl; exit(0); } char *buf = new char[len]; if (read(_pipe[0], buf, len) <= 0) { std::cerr << "#### You found a bug from cppcheck.\nThreadExecutor::handleRead error, type was:" << type << std::endl; exit(0); } if (type == '1') { _errorLogger.reportOut(buf); } else if (type == '2') { ErrorLogger::ErrorMessage msg; msg.deserialize(buf); // Alert only about unique errors std::string errmsg = msg.toText(); if (std::find(_errorList.begin(), _errorList.end(), errmsg) == _errorList.end()) { _errorList.push_back(errmsg); _errorLogger.reportErr(msg); } } else if (type == '3') { _fileCount++; std::istringstream iss(buf); unsigned int fileResult = 0; iss >> fileResult; result += fileResult; _errorLogger.reportStatus(_fileCount, _filenames.size()); }
void TestPatternSearchReplace(const std::string& idPlaceholder, const std::string& id) const { const std::string plainText = "text"; ErrorLogger::ErrorMessage message; message._id = id; std::string serialized = message.toString(true, idPlaceholder + plainText + idPlaceholder); ASSERT_EQUALS(id + plainText + id, serialized); serialized = message.toString(true, idPlaceholder + idPlaceholder); ASSERT_EQUALS(id + id, serialized); serialized = message.toString(true, plainText + idPlaceholder + plainText); ASSERT_EQUALS(plainText + id + plainText, serialized); }
ErrorItem::ErrorItem(const ErrorLogger::ErrorMessage &errmsg) : errorId(QString::fromStdString(errmsg._id)) , severity(errmsg._severity) , inconclusive(errmsg._inconclusive) , summary(QString::fromStdString(errmsg.shortMessage())) , message(QString::fromStdString(errmsg.verboseMessage())) , cwe(errmsg._cwe.id) , symbolNames(QString::fromStdString(errmsg.symbolNames())) { for (std::list<ErrorLogger::ErrorMessage::FileLocation>::const_iterator loc = errmsg._callStack.begin(); loc != errmsg._callStack.end(); ++loc) { errorPath << QErrorPathItem(*loc); } }
void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg) { if (!_settings.library.reportErrors(msg.file0)) return; const std::string errmsg = msg.toString(_settings.verbose); if (errmsg.empty()) return; // Alert only about unique errors if (std::find(_errorList.begin(), _errorList.end(), errmsg) != _errorList.end()) return; std::string file; unsigned int line(0); if (!msg._callStack.empty()) { file = msg._callStack.back().getfile(false); line = msg._callStack.back().line; } if (_useGlobalSuppressions) { if (_settings.nomsg.isSuppressed(msg._id, file, line)) return; } else { if (_settings.nomsg.isSuppressedLocal(msg._id, file, line)) return; } if (!_settings.nofail.isSuppressed(msg._id, file, line)) exitcode = 1; _errorList.push_back(errmsg); _errorLogger.reportErr(msg); }
void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg) { mSuppressInternalErrorFound = false; if (!mSettings.library.reportErrors(msg.file0)) return; const std::string errmsg = msg.toString(mSettings.verbose); if (errmsg.empty()) return; // Alert only about unique errors if (std::find(mErrorList.begin(), mErrorList.end(), errmsg) != mErrorList.end()) return; const Suppressions::ErrorMessage errorMessage = msg.toSuppressionsErrorMessage(); if (mUseGlobalSuppressions) { if (mSettings.nomsg.isSuppressed(errorMessage)) { mSuppressInternalErrorFound = true; return; } } else { if (mSettings.nomsg.isSuppressedLocal(errorMessage)) { mSuppressInternalErrorFound = true; return; } } if (!mSettings.nofail.isSuppressed(errorMessage) && (mUseGlobalSuppressions || !mSettings.nomsg.isSuppressed(errorMessage))) mExitCode = 1; mErrorList.push_back(errmsg); mErrorLogger.reportErr(msg); mAnalyzerInformation.reportErr(msg, mSettings.verbose); if (!mSettings.plistOutput.empty() && plistFile.is_open()) { plistFile << ErrorLogger::plistData(msg); } }
void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg) { const std::string errmsg = msg.toString(_settings._verbose); if (errmsg.empty()) return; if (_settings.debugFalsePositive) { // Don't print out error _errorList.push_back(errmsg); return; } // Alert only about unique errors if (std::find(_errorList.begin(), _errorList.end(), errmsg) != _errorList.end()) return; std::string file; unsigned int line(0); if (!msg._callStack.empty()) { file = msg._callStack.back().getfile(false); line = msg._callStack.back().line; } if (_useGlobalSuppressions) { if (_settings.nomsg.isSuppressed(msg._id, file, line)) return; } else { if (_settings.nomsg.isSuppressedLocal(msg._id, file, line)) return; } if (!_settings.nofail.isSuppressed(msg._id, file, line)) exitcode = 1; _errorList.push_back(errmsg); std::string errmsg2(errmsg); if (_settings._verbose) { errmsg2 += "\n Defines=\'" + cfg + "\'\n"; } _errorLogger.reportErr(msg); _errout << errmsg2 << std::endl; }
void TscThreadExecutor::report(const ErrorLogger::ErrorMessage &msg, MessageType msgType) { std::string file; unsigned int line(0); if (!msg._callStack.empty()) { file = msg._callStack.back().getfile(false); line = msg._callStack.back().line; } if (_settings.nomsg.isSuppressed(msg._id, file, line)) return; // Alert only about unique errors bool reportError = false; std::string errmsg = msg.toString(_settings._verbose); TSC_LOCK_ENTER(&_errorSync); if (std::find(_errorList.begin(), _errorList.end(), errmsg) == _errorList.end()) { _errorList.push_back(errmsg); reportError = true; } TSC_LOCK_LEAVE(&_errorSync); if (reportError) { TSC_LOCK_ENTER(&_reportSync); switch (msgType) { case REPORT_ERROR: _errorLogger.reportErr(msg); break; case REPORT_INFO: _errorLogger.reportInfo(msg); break; } TSC_LOCK_LEAVE(&_reportSync); } }
void TestFixture::reportErr(const ErrorLogger::ErrorMessage &msg) { errout << msg.toText() << std::endl; }
void Check::reportError(const ErrorLogger::ErrorMessage &errmsg) { std::cout << errmsg.toXML(true, 1) << std::endl; }
void reportErr(const ErrorLogger::ErrorMessage &msg) { const std::string str(msg.toXML(true,2U)); printf("%s\n", str.c_str()); }
void CppCheck::reportInfo(const ErrorLogger::ErrorMessage &msg) { const Suppressions::ErrorMessage &errorMessage = msg.toSuppressionsErrorMessage(); if (!mSettings.nomsg.isSuppressed(errorMessage)) mErrorLogger.reportInfo(msg); }
void AnalyzerInformation::reportErr(const ErrorLogger::ErrorMessage &msg, bool verbose) { if (fout.is_open()) fout << msg.toXML(verbose,2) << '\n'; }
void TestFixture::reportErr(const ErrorLogger::ErrorMessage &msg) { const std::string errormessage(msg.toString(false)); if (errout.str().find(errormessage) == std::string::npos) errout << errormessage << std::endl; }