Refactoring: Changed pointer to reference
This commit is contained in:
parent
7c2c1445ed
commit
599b04afbf
|
@ -45,8 +45,8 @@
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
CppCheck::CppCheck(ErrorLogger &errorLogger)
|
CppCheck::CppCheck(ErrorLogger &errorLogger)
|
||||||
|
: _errorLogger(errorLogger)
|
||||||
{
|
{
|
||||||
_errorLogger = &errorLogger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CppCheck::~CppCheck()
|
CppCheck::~CppCheck()
|
||||||
|
@ -397,7 +397,7 @@ unsigned int CppCheck::check()
|
||||||
std::string fname = _filenames[c];
|
std::string fname = _filenames[c];
|
||||||
|
|
||||||
if (_settings._errorsOnly == false)
|
if (_settings._errorsOnly == false)
|
||||||
_errorLogger->reportOut(std::string("Checking ") + fname + std::string("..."));
|
_errorLogger.reportOut(std::string("Checking ") + fname + std::string("..."));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -428,19 +428,19 @@ unsigned int CppCheck::check()
|
||||||
if (!_settings._force && checkCount > 11)
|
if (!_settings._force && checkCount > 11)
|
||||||
{
|
{
|
||||||
if (_settings._errorsOnly == false)
|
if (_settings._errorsOnly == false)
|
||||||
_errorLogger->reportOut(std::string("Bailing out from checking ") + fname + ": Too many configurations. Recheck this file with --force if you want to check them all.");
|
_errorLogger.reportOut(std::string("Bailing out from checking ") + fname + ": Too many configurations. Recheck this file with --force if you want to check them all.");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg = *it;
|
cfg = *it;
|
||||||
TIMER_START();
|
TIMER_START();
|
||||||
const std::string codeWithoutCfg = Preprocessor::getcode(filedata, *it, fname, _errorLogger);
|
const std::string codeWithoutCfg = Preprocessor::getcode(filedata, *it, fname, &_errorLogger);
|
||||||
TIMER_END("Preprocessor::getcode");
|
TIMER_END("Preprocessor::getcode");
|
||||||
|
|
||||||
// If only errors are printed, print filename after the check
|
// If only errors are printed, print filename after the check
|
||||||
if (_settings._errorsOnly == false && it != configurations.begin())
|
if (_settings._errorsOnly == false && it != configurations.begin())
|
||||||
_errorLogger->reportOut(std::string("Checking ") + fname + ": " + cfg + std::string("..."));
|
_errorLogger.reportOut(std::string("Checking ") + fname + ": " + cfg + std::string("..."));
|
||||||
|
|
||||||
checkFile(codeWithoutCfg + _settings.append(), _filenames[c].c_str());
|
checkFile(codeWithoutCfg + _settings.append(), _filenames[c].c_str());
|
||||||
++checkCount;
|
++checkCount;
|
||||||
|
@ -449,10 +449,10 @@ unsigned int CppCheck::check()
|
||||||
catch (std::runtime_error &e)
|
catch (std::runtime_error &e)
|
||||||
{
|
{
|
||||||
// Exception was thrown when checking this file..
|
// Exception was thrown when checking this file..
|
||||||
_errorLogger->reportOut("Bailing out from checking " + fname + ": " + e.what());
|
_errorLogger.reportOut("Bailing out from checking " + fname + ": " + e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
_errorLogger->reportStatus(c + 1, (unsigned int)_filenames.size());
|
_errorLogger.reportStatus(c + 1, (unsigned int)_filenames.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// This generates false positives - especially for libraries
|
// This generates false positives - especially for libraries
|
||||||
|
@ -461,7 +461,7 @@ unsigned int CppCheck::check()
|
||||||
{
|
{
|
||||||
_errout.str("");
|
_errout.str("");
|
||||||
if (_settings._errorsOnly == false)
|
if (_settings._errorsOnly == false)
|
||||||
_errorLogger->reportOut("Checking usage of global functions..");
|
_errorLogger.reportOut("Checking usage of global functions..");
|
||||||
|
|
||||||
_checkUnusedFunctions.check();
|
_checkUnusedFunctions.check();
|
||||||
}
|
}
|
||||||
|
@ -559,14 +559,14 @@ void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg)
|
||||||
errmsg2 += "\n Defines=\'" + cfg + "\'\n";
|
errmsg2 += "\n Defines=\'" + cfg + "\'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
_errorLogger->reportErr(msg);
|
_errorLogger.reportErr(msg);
|
||||||
|
|
||||||
_errout << errmsg2 << std::endl;
|
_errout << errmsg2 << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppCheck::reportOut(const std::string &outmsg)
|
void CppCheck::reportOut(const std::string &outmsg)
|
||||||
{
|
{
|
||||||
_errorLogger->reportOut(outmsg);
|
_errorLogger.reportOut(outmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::string> &CppCheck::filenames() const
|
const std::vector<std::string> &CppCheck::filenames() const
|
||||||
|
|
|
@ -142,7 +142,7 @@ private:
|
||||||
/** Key is file name, and value is the content of the file */
|
/** Key is file name, and value is the content of the file */
|
||||||
std::map<std::string, std::string> _fileContents;
|
std::map<std::string, std::string> _fileContents;
|
||||||
CheckUnusedFunctions _checkUnusedFunctions;
|
CheckUnusedFunctions _checkUnusedFunctions;
|
||||||
ErrorLogger *_errorLogger;
|
ErrorLogger &_errorLogger;
|
||||||
|
|
||||||
/** Current configuration */
|
/** Current configuration */
|
||||||
std::string cfg;
|
std::string cfg;
|
||||||
|
|
Loading…
Reference in New Issue