Settings: Remove '_' prefix for public member variables
This commit is contained in:
parent
8dccbfefcf
commit
79e663dd6f
|
@ -228,30 +228,30 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
// Enables inline suppressions.
|
||||
else if (std::strcmp(argv[i], "--inline-suppr") == 0)
|
||||
_settings->_inlineSuppressions = true;
|
||||
_settings->inlineSuppressions = true;
|
||||
|
||||
// Verbose error messages (configuration info)
|
||||
else if (std::strcmp(argv[i], "-v") == 0 || std::strcmp(argv[i], "--verbose") == 0)
|
||||
_settings->_verbose = true;
|
||||
_settings->verbose = true;
|
||||
|
||||
// Force checking of files that have "too many" configurations
|
||||
else if (std::strcmp(argv[i], "-f") == 0 || std::strcmp(argv[i], "--force") == 0)
|
||||
_settings->_force = true;
|
||||
_settings->force = true;
|
||||
|
||||
// Output relative paths
|
||||
else if (std::strcmp(argv[i], "-rp") == 0 || std::strcmp(argv[i], "--relative-paths") == 0)
|
||||
_settings->_relativePaths = true;
|
||||
_settings->relativePaths = true;
|
||||
else if (std::strncmp(argv[i], "-rp=", 4) == 0 || std::strncmp(argv[i], "--relative-paths=", 17) == 0) {
|
||||
_settings->_relativePaths = true;
|
||||
_settings->relativePaths = true;
|
||||
if (argv[i][argv[i][3]=='='?4:17] != 0) {
|
||||
std::string paths = argv[i]+(argv[i][3]=='='?4:17);
|
||||
for (;;) {
|
||||
std::string::size_type pos = paths.find(';');
|
||||
if (pos == std::string::npos) {
|
||||
_settings->_basePaths.push_back(Path::fromNativeSeparators(paths));
|
||||
_settings->basePaths.push_back(Path::fromNativeSeparators(paths));
|
||||
break;
|
||||
} else {
|
||||
_settings->_basePaths.push_back(Path::fromNativeSeparators(paths.substr(0, pos)));
|
||||
_settings->basePaths.push_back(Path::fromNativeSeparators(paths.substr(0, pos)));
|
||||
paths.erase(0, pos + 1);
|
||||
}
|
||||
}
|
||||
|
@ -263,26 +263,26 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
// Write results in results.xml
|
||||
else if (std::strcmp(argv[i], "--xml") == 0)
|
||||
_settings->_xml = true;
|
||||
_settings->xml = true;
|
||||
|
||||
// Define the XML file version (and enable XML output)
|
||||
else if (std::strncmp(argv[i], "--xml-version=", 14) == 0) {
|
||||
std::string numberString(argv[i]+14);
|
||||
|
||||
std::istringstream iss(numberString);
|
||||
if (!(iss >> _settings->_xml_version)) {
|
||||
if (!(iss >> _settings->xml_version)) {
|
||||
PrintMessage("cppcheck: argument to '--xml-version' is not a number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_settings->_xml_version < 0 || _settings->_xml_version > 2) {
|
||||
if (_settings->xml_version < 0 || _settings->xml_version > 2) {
|
||||
// We only have xml versions 1 and 2
|
||||
PrintMessage("cppcheck: '--xml-version' can only be 1 or 2.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enable also XML if version is set
|
||||
_settings->_xml = true;
|
||||
_settings->xml = true;
|
||||
}
|
||||
|
||||
// Only print something when there are errors
|
||||
|
@ -326,8 +326,8 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
else if (std::strncmp(argv[i], "--error-exitcode=", 17) == 0) {
|
||||
std::string temp = argv[i]+17;
|
||||
std::istringstream iss(temp);
|
||||
if (!(iss >> _settings->_exitCode)) {
|
||||
_settings->_exitCode = 0;
|
||||
if (!(iss >> _settings->exitCode)) {
|
||||
_settings->exitCode = 0;
|
||||
PrintMessage("cppcheck: Argument must be an integer. Try something like '--error-exitcode=1'.");
|
||||
return false;
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
if (path.back() != '/')
|
||||
path += '/';
|
||||
|
||||
_settings->_includePaths.push_back(path);
|
||||
_settings->includePaths.push_back(path);
|
||||
} else if (std::strncmp(argv[i], "--include=", 10) == 0) {
|
||||
std::string path = argv[i] + 10;
|
||||
|
||||
|
@ -423,7 +423,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
_settings->userIncludes.push_back(path);
|
||||
} else if (std::strncmp(argv[i], "--includes-file=", 16) == 0) {
|
||||
// open this file and read every input file (1 file name per line)
|
||||
AddInclPathsToList(16 + argv[i], &_settings->_includePaths);
|
||||
AddInclPathsToList(16 + argv[i], &_settings->includePaths);
|
||||
} else if (std::strncmp(argv[i], "--config-exclude=",17) ==0) {
|
||||
std::string path = argv[i] + 17;
|
||||
path = Path::fromNativeSeparators(path);
|
||||
|
@ -503,21 +503,21 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
std::strncmp(argv[i], "--template=", 11) == 0) {
|
||||
// "--template path/"
|
||||
if (argv[i][10] == '=')
|
||||
_settings->_outputFormat = argv[i] + 11;
|
||||
_settings->outputFormat = argv[i] + 11;
|
||||
else if ((i+1) < argc && argv[i+1][0] != '-') {
|
||||
++i;
|
||||
_settings->_outputFormat = argv[i];
|
||||
_settings->outputFormat = argv[i];
|
||||
} else {
|
||||
PrintMessage("cppcheck: argument to '--template' is missing.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_settings->_outputFormat == "gcc")
|
||||
_settings->_outputFormat = "{file}:{line}: {severity}: {message}";
|
||||
else if (_settings->_outputFormat == "vs")
|
||||
_settings->_outputFormat = "{file}({line}): {severity}: {message}";
|
||||
else if (_settings->_outputFormat == "edit")
|
||||
_settings->_outputFormat = "{file} +{line}: {severity}: {message}";
|
||||
if (_settings->outputFormat == "gcc")
|
||||
_settings->outputFormat = "{file}:{line}: {severity}: {message}";
|
||||
else if (_settings->outputFormat == "vs")
|
||||
_settings->outputFormat = "{file}({line}): {severity}: {message}";
|
||||
else if (_settings->outputFormat == "edit")
|
||||
_settings->outputFormat = "{file} +{line}: {severity}: {message}";
|
||||
}
|
||||
|
||||
// Checking threads
|
||||
|
@ -540,12 +540,12 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
numberString = argv[i]+2;
|
||||
|
||||
std::istringstream iss(numberString);
|
||||
if (!(iss >> _settings->_jobs)) {
|
||||
if (!(iss >> _settings->jobs)) {
|
||||
PrintMessage("cppcheck: argument to '-j' is not a number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_settings->_jobs > 10000) {
|
||||
if (_settings->jobs > 10000) {
|
||||
// This limit is here just to catch typos. If someone has
|
||||
// need for more jobs, this value should be increased.
|
||||
PrintMessage("cppcheck: argument for '-j' is allowed to be 10000 at max.");
|
||||
|
@ -570,7 +570,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
numberString = argv[i]+2;
|
||||
|
||||
std::istringstream iss(numberString);
|
||||
if (!(iss >> _settings->_loadAverage)) {
|
||||
if (!(iss >> _settings->loadAverage)) {
|
||||
PrintMessage("cppcheck: argument to '-l' is not a number.");
|
||||
return false;
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
// print all possible error messages..
|
||||
else if (std::strcmp(argv[i], "--errorlist") == 0) {
|
||||
_showErrorMessages = true;
|
||||
_settings->_xml = true;
|
||||
_settings->xml = true;
|
||||
_exitAfterPrint = true;
|
||||
}
|
||||
|
||||
|
@ -604,13 +604,13 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
else if (std::strncmp(argv[i], "--showtime=", 11) == 0) {
|
||||
const std::string showtimeMode = argv[i] + 11;
|
||||
if (showtimeMode == "file")
|
||||
_settings->_showtime = SHOWTIME_FILE;
|
||||
_settings->showtime = SHOWTIME_FILE;
|
||||
else if (showtimeMode == "summary")
|
||||
_settings->_showtime = SHOWTIME_SUMMARY;
|
||||
_settings->showtime = SHOWTIME_SUMMARY;
|
||||
else if (showtimeMode == "top5")
|
||||
_settings->_showtime = SHOWTIME_TOP5;
|
||||
_settings->showtime = SHOWTIME_TOP5;
|
||||
else if (showtimeMode.empty())
|
||||
_settings->_showtime = SHOWTIME_NONE;
|
||||
_settings->showtime = SHOWTIME_NONE;
|
||||
else {
|
||||
std::string message("cppcheck: error: unrecognized showtime mode: \"");
|
||||
message += showtimeMode;
|
||||
|
@ -694,15 +694,15 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
// Set maximum number of #ifdef configurations to check
|
||||
else if (std::strncmp(argv[i], "--max-configs=", 14) == 0) {
|
||||
_settings->_force = false;
|
||||
_settings->force = false;
|
||||
|
||||
std::istringstream iss(14+argv[i]);
|
||||
if (!(iss >> _settings->_maxConfigs)) {
|
||||
if (!(iss >> _settings->maxConfigs)) {
|
||||
PrintMessage("cppcheck: argument to '--max-configs=' is not a number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_settings->_maxConfigs < 1) {
|
||||
if (_settings->maxConfigs < 1) {
|
||||
PrintMessage("cppcheck: argument to '--max-configs=' must be greater than 0.");
|
||||
return false;
|
||||
}
|
||||
|
@ -734,17 +734,17 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (_settings->_force)
|
||||
_settings->_maxConfigs = ~0U;
|
||||
if (_settings->force)
|
||||
_settings->maxConfigs = ~0U;
|
||||
|
||||
else if ((def || _settings->preprocessOnly) && !maxconfigs)
|
||||
_settings->_maxConfigs = 1U;
|
||||
_settings->maxConfigs = 1U;
|
||||
|
||||
if (_settings->isEnabled("unusedFunction") && _settings->_jobs > 1) {
|
||||
if (_settings->isEnabled("unusedFunction") && _settings->jobs > 1) {
|
||||
PrintMessage("cppcheck: unusedFunction check can't be used with '-j' option. Disabling unusedFunction check.");
|
||||
}
|
||||
|
||||
if (_settings->inconclusive && _settings->_xml && _settings->_xml_version == 1U) {
|
||||
if (_settings->inconclusive && _settings->xml && _settings->xml_version == 1U) {
|
||||
PrintMessage("cppcheck: inconclusive messages will not be shown, because the old xml format is not compatible. It's recommended to use the new xml format (use --xml-version=2).");
|
||||
}
|
||||
|
||||
|
@ -765,8 +765,8 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
}
|
||||
|
||||
// Use paths _pathnames if no base paths for relative path output are given
|
||||
if (_settings->_basePaths.empty() && _settings->_relativePaths)
|
||||
_settings->_basePaths = _pathnames;
|
||||
if (_settings->basePaths.empty() && _settings->relativePaths)
|
||||
_settings->basePaths = _pathnames;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -94,9 +94,9 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
|||
|
||||
if (parser.GetShowErrorMessages()) {
|
||||
errorlist = true;
|
||||
std::cout << ErrorLogger::ErrorMessage::getXMLHeader(settings._xml_version);
|
||||
std::cout << ErrorLogger::ErrorMessage::getXMLHeader(settings.xml_version);
|
||||
cppcheck->getErrorMessages();
|
||||
std::cout << ErrorLogger::ErrorMessage::getXMLFooter(settings._xml_version) << std::endl;
|
||||
std::cout << ErrorLogger::ErrorMessage::getXMLFooter(settings.xml_version) << std::endl;
|
||||
}
|
||||
|
||||
if (parser.ExitAfterPrinting()) {
|
||||
|
@ -110,8 +110,8 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
|||
// Check that all include paths exist
|
||||
{
|
||||
std::list<std::string>::iterator iter;
|
||||
for (iter = settings._includePaths.begin();
|
||||
iter != settings._includePaths.end();
|
||||
for (iter = settings.includePaths.begin();
|
||||
iter != settings.includePaths.end();
|
||||
) {
|
||||
const std::string path(Path::toNativeSeparators(*iter));
|
||||
if (FileLister::isDirectory(path))
|
||||
|
@ -119,7 +119,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
|||
else {
|
||||
// If the include path is not found, warn user and remove the non-existing path from the list.
|
||||
std::cout << "cppcheck: warning: Couldn't find path given by -I '" << path << '\'' << std::endl;
|
||||
iter = settings._includePaths.erase(iter);
|
||||
iter = settings.includePaths.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -800,12 +800,12 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
|
|||
if (settings.reportProgress)
|
||||
time1 = std::time(0);
|
||||
|
||||
if (settings._xml) {
|
||||
reportErr(ErrorLogger::ErrorMessage::getXMLHeader(settings._xml_version));
|
||||
if (settings.xml) {
|
||||
reportErr(ErrorLogger::ErrorMessage::getXMLHeader(settings.xml_version));
|
||||
}
|
||||
|
||||
unsigned int returnValue = 0;
|
||||
if (settings._jobs == 1) {
|
||||
if (settings.jobs == 1) {
|
||||
// Single process
|
||||
settings.jointSuppressionReport = true;
|
||||
|
||||
|
@ -878,13 +878,13 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
|
|||
}
|
||||
}
|
||||
|
||||
if (settings._xml) {
|
||||
reportErr(ErrorLogger::ErrorMessage::getXMLFooter(settings._xml_version));
|
||||
if (settings.xml) {
|
||||
reportErr(ErrorLogger::ErrorMessage::getXMLFooter(settings.xml_version));
|
||||
}
|
||||
|
||||
_settings = 0;
|
||||
if (returnValue)
|
||||
return settings._exitCode;
|
||||
return settings.exitCode;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -947,11 +947,11 @@ void CppCheckExecutor::reportStatus(std::size_t fileindex, std::size_t filecount
|
|||
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));
|
||||
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));
|
||||
reportErr(msg.toString(_settings->verbose, _settings->outputFormat));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
|
|||
|
||||
if (!_settings.nomsg.isSuppressed(msg._id, file, line)) {
|
||||
// Alert only about unique errors
|
||||
std::string errmsg = msg.toString(_settings._verbose);
|
||||
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)
|
||||
|
@ -146,7 +146,7 @@ bool ThreadExecutor::checkLoadAverage(size_t nchildren)
|
|||
#if defined(__CYGWIN__) || defined(__QNX__) // getloadavg() is unsupported on Cygwin, Qnx.
|
||||
return true;
|
||||
#else
|
||||
if (!nchildren || !_settings._loadAverage) {
|
||||
if (!nchildren || !_settings.loadAverage) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ bool ThreadExecutor::checkLoadAverage(size_t nchildren)
|
|||
if (getloadavg(&sample, 1) != 1) {
|
||||
// disable load average checking on getloadavg error
|
||||
return true;
|
||||
} else if (sample < _settings._loadAverage) {
|
||||
} else if (sample < _settings.loadAverage) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -179,7 +179,7 @@ unsigned int ThreadExecutor::check()
|
|||
for (;;) {
|
||||
// Start a new child
|
||||
size_t nchildren = rpipes.size();
|
||||
if (i != _files.end() && nchildren < _settings._jobs && checkLoadAverage(nchildren)) {
|
||||
if (i != _files.end() && nchildren < _settings.jobs && checkLoadAverage(nchildren)) {
|
||||
int pipes[2];
|
||||
if (pipe(pipes) == -1) {
|
||||
std::cerr << "pipe() failed: "<< std::strerror(errno) << std::endl;
|
||||
|
@ -348,7 +348,7 @@ void ThreadExecutor::addFileContent(const std::string &path, const std::string &
|
|||
|
||||
unsigned int ThreadExecutor::check()
|
||||
{
|
||||
HANDLE *threadHandles = new HANDLE[_settings._jobs];
|
||||
HANDLE *threadHandles = new HANDLE[_settings.jobs];
|
||||
|
||||
_itNextFile = _files.begin();
|
||||
|
||||
|
@ -364,7 +364,7 @@ unsigned int ThreadExecutor::check()
|
|||
InitializeCriticalSection(&_errorSync);
|
||||
InitializeCriticalSection(&_reportSync);
|
||||
|
||||
for (unsigned int i = 0; i < _settings._jobs; ++i) {
|
||||
for (unsigned int i = 0; i < _settings.jobs; ++i) {
|
||||
threadHandles[i] = (HANDLE)_beginthreadex(nullptr, 0, threadProc, this, 0, nullptr);
|
||||
if (!threadHandles[i]) {
|
||||
std::cerr << "#### .\nThreadExecutor::check error, errno :" << errno << std::endl;
|
||||
|
@ -372,7 +372,7 @@ unsigned int ThreadExecutor::check()
|
|||
}
|
||||
}
|
||||
|
||||
DWORD waitResult = WaitForMultipleObjects(_settings._jobs, threadHandles, TRUE, INFINITE);
|
||||
DWORD waitResult = WaitForMultipleObjects(_settings.jobs, threadHandles, TRUE, INFINITE);
|
||||
if (waitResult != WAIT_OBJECT_0) {
|
||||
if (waitResult == WAIT_FAILED) {
|
||||
std::cerr << "#### .\nThreadExecutor::check wait failed, result: " << waitResult << " error: " << GetLastError() << std::endl;
|
||||
|
@ -384,7 +384,7 @@ unsigned int ThreadExecutor::check()
|
|||
}
|
||||
|
||||
unsigned int result = 0;
|
||||
for (unsigned int i = 0; i < _settings._jobs; ++i) {
|
||||
for (unsigned int i = 0; i < _settings.jobs; ++i) {
|
||||
DWORD exitCode;
|
||||
|
||||
if (!GetExitCodeThread(threadHandles[i], &exitCode)) {
|
||||
|
@ -488,7 +488,7 @@ void ThreadExecutor::report(const ErrorLogger::ErrorMessage &msg, MessageType ms
|
|||
|
||||
// Alert only about unique errors
|
||||
bool reportError = false;
|
||||
std::string errmsg = msg.toString(_settings._verbose);
|
||||
std::string errmsg = msg.toString(_settings.verbose);
|
||||
|
||||
EnterCriticalSection(&_errorSync);
|
||||
if (std::find(_errorList.begin(), _errorList.end(), errmsg) == _errorList.end()) {
|
||||
|
|
|
@ -546,7 +546,7 @@ void MainWindow::AddIncludeDirs(const QStringList &includeDirs, Settings &result
|
|||
// include paths must end with '/'
|
||||
if (!incdir.endsWith("/"))
|
||||
incdir += "/";
|
||||
result._includePaths.push_back(incdir.toStdString());
|
||||
result.includePaths.push_back(incdir.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -667,7 +667,7 @@ Settings MainWindow::GetCppcheckSettings()
|
|||
|
||||
// Only check the given -D configuration
|
||||
if (!defines.isEmpty())
|
||||
result._maxConfigs = 1;
|
||||
result.maxConfigs = 1;
|
||||
}
|
||||
|
||||
// Include directories (and files) are searched in listed order.
|
||||
|
@ -688,11 +688,11 @@ Settings MainWindow::GetCppcheckSettings()
|
|||
result.debug = false;
|
||||
result.debugwarnings = mSettings->value(SETTINGS_SHOW_DEBUG_WARNINGS, false).toBool();
|
||||
result.quiet = false;
|
||||
result._verbose = true;
|
||||
result._force = mSettings->value(SETTINGS_CHECK_FORCE, 1).toBool();
|
||||
result._xml = false;
|
||||
result._jobs = mSettings->value(SETTINGS_CHECK_THREADS, 1).toInt();
|
||||
result._inlineSuppressions = mSettings->value(SETTINGS_INLINE_SUPPRESSIONS, false).toBool();
|
||||
result.verbose = true;
|
||||
result.force = mSettings->value(SETTINGS_CHECK_FORCE, 1).toBool();
|
||||
result.xml = false;
|
||||
result.jobs = mSettings->value(SETTINGS_CHECK_THREADS, 1).toInt();
|
||||
result.inlineSuppressions = mSettings->value(SETTINGS_INLINE_SUPPRESSIONS, false).toBool();
|
||||
result.inconclusive = mSettings->value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool();
|
||||
result.platformType = (Settings::PlatformType) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt();
|
||||
result.standards.cpp = mSettings->value(SETTINGS_STD_CPP11, true).toBool() ? Standards::CPP11 : Standards::CPP03;
|
||||
|
@ -711,8 +711,8 @@ Settings MainWindow::GetCppcheckSettings()
|
|||
if (!std || !posix || !windows)
|
||||
QMessageBox::critical(this, tr("Error"), tr("Failed to load %1. Your Cppcheck installation is broken. You can use --data-dir=<directory> at the command line to specify where this file is located.").arg(!std ? "std.cfg" : !posix ? "posix.cfg" : "windows.cfg"));
|
||||
|
||||
if (result._jobs <= 1) {
|
||||
result._jobs = 1;
|
||||
if (result.jobs <= 1) {
|
||||
result.jobs = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -67,13 +67,13 @@ void ThreadHandler::SetCheckFiles(QStringList files)
|
|||
|
||||
void ThreadHandler::Check(const Settings &settings, bool all)
|
||||
{
|
||||
if (mResults.GetFileCount() == 0 || mRunningThreadCount > 0 || settings._jobs == 0) {
|
||||
if (mResults.GetFileCount() == 0 || mRunningThreadCount > 0 || settings.jobs == 0) {
|
||||
qDebug() << "Can't start checking if there's no files to check or if check is in progress.";
|
||||
emit Done();
|
||||
return;
|
||||
}
|
||||
|
||||
SetThreadCount(settings._jobs);
|
||||
SetThreadCount(settings.jobs);
|
||||
|
||||
mRunningThreadCount = mThreads.size();
|
||||
|
||||
|
|
|
@ -2017,7 +2017,7 @@ void CheckMemoryLeakInFunction::checkScope(const Token *startTok, const std::str
|
|||
|
||||
simplifycode(tok);
|
||||
|
||||
if (_settings->debug && _settings->_verbose) {
|
||||
if (_settings->debug && _settings->verbose) {
|
||||
tok->printOut(("Checkmemoryleak: simplifycode result for: " + varname).c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ void CheckUnusedFunctions::unusedFunctionError(ErrorLogger * const errorLogger,
|
|||
|
||||
Check::FileInfo *CheckUnusedFunctions::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const
|
||||
{
|
||||
if (settings->isEnabled("unusedFunction") && settings->_jobs == 1)
|
||||
if (settings->isEnabled("unusedFunction") && settings->jobs == 1)
|
||||
instance.parseTokens(*tokenizer, tokenizer->list.getFiles().front().c_str(), settings);
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ CppCheck::~CppCheck()
|
|||
delete fileInfo.back();
|
||||
fileInfo.pop_back();
|
||||
}
|
||||
S_timerResults.ShowResults(_settings._showtime);
|
||||
S_timerResults.ShowResults(_settings.showtime);
|
||||
}
|
||||
|
||||
const char * CppCheck::version()
|
||||
|
@ -100,8 +100,8 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
|
|||
std::string filedata;
|
||||
|
||||
{
|
||||
Timer t("Preprocessor::preprocess", _settings._showtime, &S_timerResults);
|
||||
preprocessor.preprocess(fileStream, filedata, configurations, filename, _settings._includePaths);
|
||||
Timer t("Preprocessor::preprocess", _settings.showtime, &S_timerResults);
|
||||
preprocessor.preprocess(fileStream, filedata, configurations, filename, _settings.includePaths);
|
||||
}
|
||||
|
||||
if (_settings.checkConfiguration) {
|
||||
|
@ -130,12 +130,12 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
|
|||
}
|
||||
}
|
||||
|
||||
if (!_settings.userDefines.empty() && _settings._maxConfigs==1U) {
|
||||
if (!_settings.userDefines.empty() && _settings.maxConfigs==1U) {
|
||||
configurations.clear();
|
||||
configurations.push_back(_settings.userDefines);
|
||||
}
|
||||
|
||||
if (!_settings._force && configurations.size() > _settings._maxConfigs) {
|
||||
if (!_settings.force && configurations.size() > _settings.maxConfigs) {
|
||||
if (_settings.isEnabled("information")) {
|
||||
tooManyConfigsError(Path::toNativeSeparators(filename),configurations.size());
|
||||
} else {
|
||||
|
@ -163,7 +163,7 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
|
|||
|
||||
// Check only a few configurations (default 12), after that bail out, unless --force
|
||||
// was used.
|
||||
if (!_settings._force && ++checkCount > _settings._maxConfigs)
|
||||
if (!_settings.force && ++checkCount > _settings.maxConfigs)
|
||||
break;
|
||||
|
||||
cfg = *it;
|
||||
|
@ -181,7 +181,7 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
|
|||
cfg = _settings.userDefines + cfg;
|
||||
}
|
||||
|
||||
Timer t("Preprocessor::getcode", _settings._showtime, &S_timerResults);
|
||||
Timer t("Preprocessor::getcode", _settings.showtime, &S_timerResults);
|
||||
std::string codeWithoutCfg = preprocessor.getcode(filedata, cfg, filename);
|
||||
t.Stop();
|
||||
|
||||
|
@ -204,13 +204,13 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
|
|||
}
|
||||
|
||||
Tokenizer _tokenizer(&_settings, this);
|
||||
if (_settings._showtime != SHOWTIME_NONE)
|
||||
if (_settings.showtime != SHOWTIME_NONE)
|
||||
_tokenizer.setTimerResults(&S_timerResults);
|
||||
|
||||
try {
|
||||
// Create tokens, skip rest of iteration if failed
|
||||
std::istringstream istr(codeWithoutCfg);
|
||||
Timer timer("Tokenizer::createTokens", _settings._showtime, &S_timerResults);
|
||||
Timer timer("Tokenizer::createTokens", _settings.showtime, &S_timerResults);
|
||||
bool result = _tokenizer.createTokens(istr, filename.c_str());
|
||||
timer.Stop();
|
||||
if (!result)
|
||||
|
@ -224,7 +224,7 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
|
|||
checkRawTokens(_tokenizer);
|
||||
|
||||
// Simplify tokens into normal form, skip rest of iteration if failed
|
||||
Timer timer2("Tokenizer::simplifyTokens1", _settings._showtime, &S_timerResults);
|
||||
Timer timer2("Tokenizer::simplifyTokens1", _settings.showtime, &S_timerResults);
|
||||
result = _tokenizer.simplifyTokens1(cfg);
|
||||
timer2.Stop();
|
||||
if (!result)
|
||||
|
@ -238,7 +238,7 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
|
|||
}
|
||||
|
||||
// Skip if we already met the same simplified token list
|
||||
if (_settings._force || _settings._maxConfigs > 1) {
|
||||
if (_settings.force || _settings.maxConfigs > 1) {
|
||||
const unsigned long long checksum = _tokenizer.list.calculateChecksum();
|
||||
if (checksums.find(checksum) != checksums.end())
|
||||
continue;
|
||||
|
@ -251,7 +251,7 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
|
|||
// simplify more if required, skip rest of iteration if failed
|
||||
if (_simplify) {
|
||||
// if further simplification fails then skip rest of iteration
|
||||
Timer timer3("Tokenizer::simplifyTokenList2", _settings._showtime, &S_timerResults);
|
||||
Timer timer3("Tokenizer::simplifyTokenList2", _settings.showtime, &S_timerResults);
|
||||
result = _tokenizer.simplifyTokenList2();
|
||||
timer3.Stop();
|
||||
if (!result)
|
||||
|
@ -262,7 +262,7 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
|
|||
}
|
||||
|
||||
} catch (const InternalError &e) {
|
||||
if (_settings.isEnabled("information") && (_settings.debug || _settings._verbose))
|
||||
if (_settings.isEnabled("information") && (_settings.debug || _settings.verbose))
|
||||
purgedConfigurationMessage(filename, cfg);
|
||||
internalErrorFound=true;
|
||||
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
|
||||
|
@ -356,7 +356,7 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
|
|||
if (_settings.terminated())
|
||||
return;
|
||||
|
||||
Timer timerRunChecks((*it)->name() + "::runChecks", _settings._showtime, &S_timerResults);
|
||||
Timer timerRunChecks((*it)->name() + "::runChecks", _settings.showtime, &S_timerResults);
|
||||
(*it)->runChecks(&tokenizer, &_settings, this);
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ void CppCheck::checkSimplifiedTokens(const Tokenizer &tokenizer)
|
|||
if (_settings.terminated())
|
||||
return;
|
||||
|
||||
Timer timerSimpleChecks((*it)->name() + "::runSimplifiedChecks", _settings._showtime, &S_timerResults);
|
||||
Timer timerSimpleChecks((*it)->name() + "::runSimplifiedChecks", _settings.showtime, &S_timerResults);
|
||||
(*it)->runSimplifiedChecks(&tokenizer, &_settings, this);
|
||||
timerSimpleChecks.Stop();
|
||||
}
|
||||
|
@ -500,8 +500,8 @@ void CppCheck::tooManyConfigsError(const std::string &file, const std::size_t nu
|
|||
}
|
||||
|
||||
std::ostringstream msg;
|
||||
msg << "Too many #ifdef configurations - cppcheck only checks " << _settings._maxConfigs;
|
||||
if (numberOfConfigurations > _settings._maxConfigs)
|
||||
msg << "Too many #ifdef configurations - cppcheck only checks " << _settings.maxConfigs;
|
||||
if (numberOfConfigurations > _settings.maxConfigs)
|
||||
msg << " of " << numberOfConfigurations << " configurations. Use --force to check all configurations.\n";
|
||||
if (file.empty())
|
||||
msg << " configurations. Use --force to check all configurations. For more details, use --enable=information.\n";
|
||||
|
@ -553,7 +553,7 @@ void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg)
|
|||
if (!_settings.library.reportErrors(msg.file0))
|
||||
return;
|
||||
|
||||
const std::string errmsg = msg.toString(_settings._verbose);
|
||||
const std::string errmsg = msg.toString(_settings.verbose);
|
||||
if (errmsg.empty())
|
||||
return;
|
||||
|
||||
|
@ -648,5 +648,5 @@ void CppCheck::analyseWholeProgram()
|
|||
|
||||
bool CppCheck::unusedFunctionCheckIsEnabled() const
|
||||
{
|
||||
return (_settings._jobs == 1 && _settings.isEnabled("unusedFunction"));
|
||||
return (_settings.jobs == 1 && _settings.isEnabled("unusedFunction"));
|
||||
}
|
||||
|
|
|
@ -535,7 +535,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
|
|||
break;
|
||||
std::string comment(str, commentStart, i - commentStart);
|
||||
|
||||
if (_settings._inlineSuppressions) {
|
||||
if (_settings.inlineSuppressions) {
|
||||
std::istringstream iss(comment);
|
||||
std::string word;
|
||||
iss >> word;
|
||||
|
@ -572,7 +572,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
|
|||
fallThroughComment = true;
|
||||
}
|
||||
|
||||
if (_settings._inlineSuppressions) {
|
||||
if (_settings.inlineSuppressions) {
|
||||
std::istringstream iss(comment);
|
||||
std::string word;
|
||||
iss >> word;
|
||||
|
@ -641,9 +641,9 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
|
|||
if (!suppressionIDs.empty()) {
|
||||
// Relative filename
|
||||
std::string relativeFilename(filename);
|
||||
if (_settings._relativePaths) {
|
||||
for (std::size_t j = 0U; j < _settings._basePaths.size(); ++j) {
|
||||
const std::string bp = _settings._basePaths[j] + "/";
|
||||
if (_settings.relativePaths) {
|
||||
for (std::size_t j = 0U; j < _settings.basePaths.size(); ++j) {
|
||||
const std::string bp = _settings.basePaths[j] + "/";
|
||||
if (relativeFilename.compare(0,bp.size(),bp)==0) {
|
||||
relativeFilename = relativeFilename.substr(bp.size());
|
||||
}
|
||||
|
@ -1036,7 +1036,7 @@ void Preprocessor::preprocess(std::istream &srcCodeStream, std::string &processe
|
|||
|
||||
std::map<std::string, std::string> defs(getcfgmap(_settings.userDefines, &_settings, filename));
|
||||
|
||||
if (_settings._maxConfigs == 1U) {
|
||||
if (_settings.maxConfigs == 1U) {
|
||||
std::set<std::string> pragmaOnce;
|
||||
std::list<std::string> includes;
|
||||
processedFile = handleIncludes(processedFile, filename, includePaths, defs, pragmaOnce, includes);
|
||||
|
@ -1917,7 +1917,7 @@ std::string Preprocessor::getcode(const std::string &filedata, const std::string
|
|||
|
||||
// #error => return ""
|
||||
if (match && line.compare(0, 6, "#error") == 0) {
|
||||
if (!_settings.userDefines.empty() && !_settings._force) {
|
||||
if (!_settings.userDefines.empty() && !_settings.force) {
|
||||
error(Path::simplifyPath(filenames.top()), lineno, line);
|
||||
}
|
||||
return "";
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <set>
|
||||
|
||||
Settings::Settings()
|
||||
: _terminate(false),
|
||||
: _terminated(false),
|
||||
debug(false),
|
||||
debugnormal(false),
|
||||
debugwarnings(false),
|
||||
|
@ -34,17 +34,17 @@ Settings::Settings()
|
|||
jointSuppressionReport(false),
|
||||
experimental(false),
|
||||
quiet(false),
|
||||
_inlineSuppressions(false),
|
||||
_verbose(false),
|
||||
_force(false),
|
||||
_relativePaths(false),
|
||||
_xml(false), _xml_version(1),
|
||||
_jobs(1),
|
||||
_loadAverage(0),
|
||||
_exitCode(0),
|
||||
_showtime(SHOWTIME_NONE),
|
||||
inlineSuppressions(false),
|
||||
verbose(false),
|
||||
force(false),
|
||||
relativePaths(false),
|
||||
xml(false), xml_version(1),
|
||||
jobs(1),
|
||||
loadAverage(0),
|
||||
exitCode(0),
|
||||
showtime(SHOWTIME_NONE),
|
||||
preprocessOnly(false),
|
||||
_maxConfigs(12),
|
||||
maxConfigs(12),
|
||||
enforcedLang(None),
|
||||
reportProgress(false),
|
||||
checkConfiguration(false),
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
std::set<std::string> _enabled;
|
||||
|
||||
/** @brief terminate checking */
|
||||
bool _terminate;
|
||||
bool _terminated;
|
||||
|
||||
public:
|
||||
Settings();
|
||||
|
@ -90,60 +90,60 @@ public:
|
|||
bool quiet;
|
||||
|
||||
/** @brief Is --inline-suppr given? */
|
||||
bool _inlineSuppressions;
|
||||
bool inlineSuppressions;
|
||||
|
||||
/** @brief Is --verbose given? */
|
||||
bool _verbose;
|
||||
bool verbose;
|
||||
|
||||
/** @brief Request termination of checking */
|
||||
void terminate() {
|
||||
_terminate = true;
|
||||
_terminated = true;
|
||||
}
|
||||
|
||||
/** @brief termination requested? */
|
||||
bool terminated() const {
|
||||
return _terminate;
|
||||
return _terminated;
|
||||
}
|
||||
|
||||
/** @brief Force checking the files with "too many" configurations (--force). */
|
||||
bool _force;
|
||||
bool force;
|
||||
|
||||
/** @brief Use relative paths in output. */
|
||||
bool _relativePaths;
|
||||
bool relativePaths;
|
||||
|
||||
/** @brief Paths used as base for conversion to relative paths. */
|
||||
std::vector<std::string> _basePaths;
|
||||
std::vector<std::string> basePaths;
|
||||
|
||||
/** @brief write XML results (--xml) */
|
||||
bool _xml;
|
||||
bool xml;
|
||||
|
||||
/** @brief XML version (--xmlver=..) */
|
||||
int _xml_version;
|
||||
int xml_version;
|
||||
|
||||
/** @brief How many processes/threads should do checking at the same
|
||||
time. Default is 1. (-j N) */
|
||||
unsigned int _jobs;
|
||||
unsigned int jobs;
|
||||
|
||||
/** @brief Load average value */
|
||||
unsigned int _loadAverage;
|
||||
unsigned int loadAverage;
|
||||
|
||||
/** @brief If errors are found, this value is returned from main().
|
||||
Default value is 0. */
|
||||
int _exitCode;
|
||||
int exitCode;
|
||||
|
||||
/** @brief The output format in which the errors are printed in text mode,
|
||||
e.g. "{severity} {file}:{line} {message} {id}" */
|
||||
std::string _outputFormat;
|
||||
std::string outputFormat;
|
||||
|
||||
/** @brief show timing information (--showtime=file|summary|top5) */
|
||||
SHOWTIME_MODES _showtime;
|
||||
SHOWTIME_MODES showtime;
|
||||
|
||||
/** @brief Using -E for debugging purposes */
|
||||
bool preprocessOnly;
|
||||
|
||||
/** @brief List of include paths, e.g. "my/includes/" which should be used
|
||||
for finding include files inside source files. (-I) */
|
||||
std::list<std::string> _includePaths;
|
||||
std::list<std::string> includePaths;
|
||||
|
||||
/** @brief assign append code (--append) */
|
||||
bool append(const std::string &filename);
|
||||
|
@ -153,7 +153,7 @@ public:
|
|||
|
||||
/** @brief Maximum number of configurations to check before bailing.
|
||||
Default is 12. (--max-configs=N) */
|
||||
unsigned int _maxConfigs;
|
||||
unsigned int maxConfigs;
|
||||
|
||||
/**
|
||||
* @brief Returns true if given id is in the list of
|
||||
|
@ -299,7 +299,6 @@ public:
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
|
|
@ -1698,7 +1698,7 @@ bool Tokenizer::createTokens(std::istream &code,
|
|||
// make sure settings specified
|
||||
assert(_settings);
|
||||
|
||||
return list.createTokens(code, Path::getRelativePath(Path::simplifyPath(FileName), _settings->_basePaths));
|
||||
return list.createTokens(code, Path::getRelativePath(Path::simplifyPath(FileName), _settings->basePaths));
|
||||
}
|
||||
|
||||
bool Tokenizer::simplifyTokens1(const std::string &configuration,
|
||||
|
@ -3523,7 +3523,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
|||
|
||||
// typedef..
|
||||
if (m_timerResults) {
|
||||
Timer t("Tokenizer::tokenize::simplifyTypedef", _settings->_showtime, m_timerResults);
|
||||
Timer t("Tokenizer::tokenize::simplifyTypedef", _settings->showtime, m_timerResults);
|
||||
simplifyTypedef();
|
||||
} else {
|
||||
simplifyTypedef();
|
||||
|
@ -3638,7 +3638,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
|||
validate(); // #6772 "segmentation fault (invalid code) in Tokenizer::setVarId"
|
||||
|
||||
if (m_timerResults) {
|
||||
Timer t("Tokenizer::tokenize::setVarId", _settings->_showtime, m_timerResults);
|
||||
Timer t("Tokenizer::tokenize::setVarId", _settings->showtime, m_timerResults);
|
||||
setVarId();
|
||||
} else {
|
||||
setVarId();
|
||||
|
@ -3846,22 +3846,22 @@ void Tokenizer::printDebugOutput(unsigned int simplification) const
|
|||
if (debug && list.front()) {
|
||||
list.front()->printOut(0, list.getFiles());
|
||||
|
||||
if (_settings->_xml)
|
||||
if (_settings->xml)
|
||||
std::cout << "<debug>" << std::endl;
|
||||
|
||||
if (_symbolDatabase) {
|
||||
if (_settings->_xml)
|
||||
if (_settings->xml)
|
||||
_symbolDatabase->printXml(std::cout);
|
||||
else if (_settings->_verbose)
|
||||
else if (_settings->verbose)
|
||||
_symbolDatabase->printOut("Symbol database");
|
||||
}
|
||||
|
||||
if (_settings->_verbose)
|
||||
list.front()->printAst(_settings->_verbose, _settings->_xml, std::cout);
|
||||
if (_settings->verbose)
|
||||
list.front()->printAst(_settings->verbose, _settings->xml, std::cout);
|
||||
|
||||
list.front()->printValueFlow(_settings->_xml, std::cout);
|
||||
list.front()->printValueFlow(_settings->xml, std::cout);
|
||||
|
||||
if (_settings->_xml)
|
||||
if (_settings->xml)
|
||||
std::cout << "</debug>" << std::endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ bool TokenList::createTokens(std::istream &code, const std::string& file0)
|
|||
Token::assignProgressValues(_front);
|
||||
|
||||
for (std::size_t i = 1; i < _files.size(); i++)
|
||||
_files[i] = Path::getRelativePath(_files[i], _settings->_basePaths);
|
||||
_files[i] = Path::getRelativePath(_files[i], _settings->basePaths);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -204,17 +204,17 @@ private:
|
|||
void verboseshort() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "-v", "file.cpp"};
|
||||
settings._verbose = false;
|
||||
settings.verbose = false;
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT_EQUALS(true, settings._verbose);
|
||||
ASSERT_EQUALS(true, settings.verbose);
|
||||
}
|
||||
|
||||
void verboselong() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--verbose", "file.cpp"};
|
||||
settings._verbose = false;
|
||||
settings.verbose = false;
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT_EQUALS(true, settings._verbose);
|
||||
ASSERT_EQUALS(true, settings.verbose);
|
||||
}
|
||||
|
||||
void debug() {
|
||||
|
@ -236,52 +236,52 @@ private:
|
|||
void forceshort() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "-f", "file.cpp"};
|
||||
settings._force = false;
|
||||
settings.force = false;
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT_EQUALS(true, settings._force);
|
||||
ASSERT_EQUALS(true, settings.force);
|
||||
}
|
||||
|
||||
void forcelong() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--force", "file.cpp"};
|
||||
settings._force = false;
|
||||
settings.force = false;
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT_EQUALS(true, settings._force);
|
||||
ASSERT_EQUALS(true, settings.force);
|
||||
}
|
||||
|
||||
void relativePaths() {
|
||||
REDIRECT;
|
||||
settings._relativePaths = false;
|
||||
settings.relativePaths = false;
|
||||
|
||||
const char *argvs[] = {"cppcheck", "-rp", "file.cpp"};
|
||||
ASSERT(defParser.ParseFromArgs(3, argvs));
|
||||
ASSERT_EQUALS(true, settings._relativePaths);
|
||||
ASSERT_EQUALS(true, settings.relativePaths);
|
||||
|
||||
settings._relativePaths = false;
|
||||
settings.relativePaths = false;
|
||||
|
||||
const char *argvl[] = {"cppcheck", "--relative-paths", "file.cpp"};
|
||||
ASSERT(defParser.ParseFromArgs(3, argvl));
|
||||
ASSERT_EQUALS(true, settings._relativePaths);
|
||||
ASSERT_EQUALS(true, settings.relativePaths);
|
||||
|
||||
settings._relativePaths = false;
|
||||
settings._basePaths.clear();
|
||||
settings.relativePaths = false;
|
||||
settings.basePaths.clear();
|
||||
|
||||
const char *argvsp[] = {"cppcheck", "-rp=C:/foo;C:\\bar", "file.cpp"};
|
||||
ASSERT(defParser.ParseFromArgs(3, argvsp));
|
||||
ASSERT_EQUALS(true, settings._relativePaths);
|
||||
ASSERT_EQUALS(2, settings._basePaths.size());
|
||||
ASSERT_EQUALS("C:/foo", settings._basePaths[0]);
|
||||
ASSERT_EQUALS("C:/bar", settings._basePaths[1]);
|
||||
ASSERT_EQUALS(true, settings.relativePaths);
|
||||
ASSERT_EQUALS(2, settings.basePaths.size());
|
||||
ASSERT_EQUALS("C:/foo", settings.basePaths[0]);
|
||||
ASSERT_EQUALS("C:/bar", settings.basePaths[1]);
|
||||
|
||||
settings._relativePaths = false;
|
||||
settings._basePaths.clear();
|
||||
settings.relativePaths = false;
|
||||
settings.basePaths.clear();
|
||||
|
||||
const char *argvlp[] = {"cppcheck", "--relative-paths=C:/foo;C:\\bar", "file.cpp"};
|
||||
ASSERT(defParser.ParseFromArgs(3, argvlp));
|
||||
ASSERT_EQUALS(true, settings._relativePaths);
|
||||
ASSERT_EQUALS(2, settings._basePaths.size());
|
||||
ASSERT_EQUALS("C:/foo", settings._basePaths[0]);
|
||||
ASSERT_EQUALS("C:/bar", settings._basePaths[1]);
|
||||
ASSERT_EQUALS(true, settings.relativePaths);
|
||||
ASSERT_EQUALS(2, settings.basePaths.size());
|
||||
ASSERT_EQUALS("C:/foo", settings.basePaths[0]);
|
||||
ASSERT_EQUALS("C:/bar", settings.basePaths[1]);
|
||||
}
|
||||
|
||||
void quietshort() {
|
||||
|
@ -403,50 +403,50 @@ private:
|
|||
void includes() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "-I", "include", "file.cpp"};
|
||||
settings._includePaths.clear();
|
||||
settings.includePaths.clear();
|
||||
ASSERT(defParser.ParseFromArgs(4, argv));
|
||||
ASSERT_EQUALS("include/", settings._includePaths.front());
|
||||
ASSERT_EQUALS("include/", settings.includePaths.front());
|
||||
}
|
||||
|
||||
void includesslash() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "-I", "include/", "file.cpp"};
|
||||
settings._includePaths.clear();
|
||||
settings.includePaths.clear();
|
||||
ASSERT(defParser.ParseFromArgs(4, argv));
|
||||
ASSERT_EQUALS("include/", settings._includePaths.front());
|
||||
ASSERT_EQUALS("include/", settings.includePaths.front());
|
||||
}
|
||||
|
||||
void includesbackslash() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "-I", "include\\", "file.cpp"};
|
||||
settings._includePaths.clear();
|
||||
settings.includePaths.clear();
|
||||
ASSERT(defParser.ParseFromArgs(4, argv));
|
||||
ASSERT_EQUALS("include/", settings._includePaths.front());
|
||||
ASSERT_EQUALS("include/", settings.includePaths.front());
|
||||
}
|
||||
|
||||
void includesnospace() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "-Iinclude", "file.cpp"};
|
||||
settings._includePaths.clear();
|
||||
settings.includePaths.clear();
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT_EQUALS("include/", settings._includePaths.front());
|
||||
ASSERT_EQUALS("include/", settings.includePaths.front());
|
||||
}
|
||||
|
||||
void includes2() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "-I", "include/", "-I", "framework/", "file.cpp"};
|
||||
settings._includePaths.clear();
|
||||
settings.includePaths.clear();
|
||||
ASSERT(defParser.ParseFromArgs(6, argv));
|
||||
ASSERT_EQUALS("include/", settings._includePaths.front());
|
||||
settings._includePaths.pop_front();
|
||||
ASSERT_EQUALS("framework/", settings._includePaths.front());
|
||||
ASSERT_EQUALS("include/", settings.includePaths.front());
|
||||
settings.includePaths.pop_front();
|
||||
ASSERT_EQUALS("framework/", settings.includePaths.front());
|
||||
}
|
||||
|
||||
void includesFile() {
|
||||
// TODO: Fails since cannot open the file
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--includes-file=inclpaths.txt", "file.cpp"};
|
||||
settings._includePaths.clear();
|
||||
settings.includePaths.clear();
|
||||
ASSERT_EQUALS(true, defParser.ParseFromArgs(3, argv));
|
||||
}
|
||||
|
||||
|
@ -551,15 +551,15 @@ private:
|
|||
void errorExitcode() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--error-exitcode=5", "file.cpp"};
|
||||
settings._exitCode = 0;
|
||||
settings.exitCode = 0;
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT_EQUALS(5, settings._exitCode);
|
||||
ASSERT_EQUALS(5, settings.exitCode);
|
||||
}
|
||||
|
||||
void errorExitcodeMissing() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--error-exitcode=", "file.cpp"};
|
||||
settings._exitCode = 0;
|
||||
settings.exitCode = 0;
|
||||
// Fails since exit code not given
|
||||
ASSERT_EQUALS(false, defParser.ParseFromArgs(3, argv));
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ private:
|
|||
void errorExitcodeStr() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--error-exitcode=foo", "file.cpp"};
|
||||
settings._exitCode = 0;
|
||||
settings.exitCode = 0;
|
||||
// Fails since invalid exit code
|
||||
ASSERT_EQUALS(false, defParser.ParseFromArgs(3, argv));
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ private:
|
|||
// TODO: Fails since cannot open the file
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--exitcode-suppressions", "suppr.txt", "file.cpp"};
|
||||
settings._exitCode = 0;
|
||||
settings.exitCode = 0;
|
||||
TODO_ASSERT_EQUALS(true, false, defParser.ParseFromArgs(4, argv));
|
||||
}
|
||||
|
||||
|
@ -584,7 +584,7 @@ private:
|
|||
// TODO: Fails since cannot open the file
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--exitcode-suppressions=suppr.txt", "file.cpp"};
|
||||
settings._exitCode = 0;
|
||||
settings.exitCode = 0;
|
||||
TODO_ASSERT_EQUALS(true, false, defParser.ParseFromArgs(3, argv));
|
||||
}
|
||||
|
||||
|
@ -592,7 +592,7 @@ private:
|
|||
// TODO: Fails since cannot open the file
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--exitcode-suppressions", "file.cpp"};
|
||||
settings._exitCode = 0;
|
||||
settings.exitCode = 0;
|
||||
TODO_ASSERT_EQUALS(true, false, defParser.ParseFromArgs(3, argv));
|
||||
}
|
||||
|
||||
|
@ -620,15 +620,15 @@ private:
|
|||
void jobs() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "-j", "3", "file.cpp"};
|
||||
settings._jobs = 0;
|
||||
settings.jobs = 0;
|
||||
ASSERT(defParser.ParseFromArgs(4, argv));
|
||||
ASSERT_EQUALS(3, settings._jobs);
|
||||
ASSERT_EQUALS(3, settings.jobs);
|
||||
}
|
||||
|
||||
void jobsMissingCount() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "-j", "file.cpp"};
|
||||
settings._jobs = 0;
|
||||
settings.jobs = 0;
|
||||
// Fails since -j is missing thread count
|
||||
ASSERT_EQUALS(false, defParser.ParseFromArgs(3, argv));
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ private:
|
|||
void jobsInvalid() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "-j", "e", "file.cpp"};
|
||||
settings._jobs = 0;
|
||||
settings.jobs = 0;
|
||||
// Fails since invalid count given for -j
|
||||
ASSERT_EQUALS(false, defParser.ParseFromArgs(4, argv));
|
||||
}
|
||||
|
@ -644,11 +644,11 @@ private:
|
|||
void maxConfigs() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "-f", "--max-configs=12", "file.cpp"};
|
||||
settings._force = false;
|
||||
settings._maxConfigs = 12;
|
||||
settings.force = false;
|
||||
settings.maxConfigs = 12;
|
||||
ASSERT(defParser.ParseFromArgs(4, argv));
|
||||
ASSERT_EQUALS(12, settings._maxConfigs);
|
||||
ASSERT_EQUALS(false, settings._force);
|
||||
ASSERT_EQUALS(12, settings.maxConfigs);
|
||||
ASSERT_EQUALS(false, settings.force);
|
||||
}
|
||||
|
||||
void maxConfigsMissingCount() {
|
||||
|
@ -787,83 +787,83 @@ private:
|
|||
void templates() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--template", "{file}:{line},{severity},{id},{message}", "file.cpp"};
|
||||
settings._outputFormat.clear();
|
||||
settings.outputFormat.clear();
|
||||
ASSERT(defParser.ParseFromArgs(4, argv));
|
||||
ASSERT_EQUALS("{file}:{line},{severity},{id},{message}", settings._outputFormat);
|
||||
ASSERT_EQUALS("{file}:{line},{severity},{id},{message}", settings.outputFormat);
|
||||
}
|
||||
|
||||
void templatesGcc() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--template", "gcc", "file.cpp"};
|
||||
settings._outputFormat.clear();
|
||||
settings.outputFormat.clear();
|
||||
ASSERT(defParser.ParseFromArgs(4, argv));
|
||||
ASSERT_EQUALS("{file}:{line}: {severity}: {message}", settings._outputFormat);
|
||||
ASSERT_EQUALS("{file}:{line}: {severity}: {message}", settings.outputFormat);
|
||||
}
|
||||
|
||||
void templatesVs() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--template", "vs", "file.cpp"};
|
||||
settings._outputFormat.clear();
|
||||
settings.outputFormat.clear();
|
||||
ASSERT(defParser.ParseFromArgs(4, argv));
|
||||
ASSERT_EQUALS("{file}({line}): {severity}: {message}", settings._outputFormat);
|
||||
ASSERT_EQUALS("{file}({line}): {severity}: {message}", settings.outputFormat);
|
||||
}
|
||||
|
||||
void templatesEdit() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--template", "edit", "file.cpp"};
|
||||
settings._outputFormat.clear();
|
||||
settings.outputFormat.clear();
|
||||
ASSERT(defParser.ParseFromArgs(4, argv));
|
||||
ASSERT_EQUALS("{file} +{line}: {severity}: {message}", settings._outputFormat);
|
||||
ASSERT_EQUALS("{file} +{line}: {severity}: {message}", settings.outputFormat);
|
||||
}
|
||||
|
||||
void xml() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--xml", "file.cpp"};
|
||||
settings._xml_version = 1;
|
||||
settings._xml = false;
|
||||
settings.xml_version = 1;
|
||||
settings.xml = false;
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(settings._xml);
|
||||
ASSERT_EQUALS(1, settings._xml_version);
|
||||
ASSERT(settings.xml);
|
||||
ASSERT_EQUALS(1, settings.xml_version);
|
||||
}
|
||||
|
||||
void xmlver1() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--xml-version=1", "file.cpp"};
|
||||
settings._xml_version = 1;
|
||||
settings._xml = false;
|
||||
settings.xml_version = 1;
|
||||
settings.xml = false;
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(settings._xml);
|
||||
ASSERT_EQUALS(1, settings._xml_version);
|
||||
ASSERT(settings.xml);
|
||||
ASSERT_EQUALS(1, settings.xml_version);
|
||||
}
|
||||
|
||||
void xmlver2() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--xml-version=2", "file.cpp"};
|
||||
settings._xml_version = 1;
|
||||
settings._xml = false;
|
||||
settings.xml_version = 1;
|
||||
settings.xml = false;
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(settings._xml);
|
||||
ASSERT_EQUALS(2, settings._xml_version);
|
||||
ASSERT(settings.xml);
|
||||
ASSERT_EQUALS(2, settings.xml_version);
|
||||
}
|
||||
|
||||
void xmlver2both() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--xml", "--xml-version=2", "file.cpp"};
|
||||
settings._xml_version = 1;
|
||||
settings._xml = false;
|
||||
settings.xml_version = 1;
|
||||
settings.xml = false;
|
||||
ASSERT(defParser.ParseFromArgs(4, argv));
|
||||
ASSERT(settings._xml);
|
||||
ASSERT_EQUALS(2, settings._xml_version);
|
||||
ASSERT(settings.xml);
|
||||
ASSERT_EQUALS(2, settings.xml_version);
|
||||
}
|
||||
|
||||
void xmlver2both2() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--xml-version=2", "--xml", "file.cpp"};
|
||||
settings._xml_version = 1;
|
||||
settings._xml = false;
|
||||
settings.xml_version = 1;
|
||||
settings.xml = false;
|
||||
ASSERT(defParser.ParseFromArgs(4, argv));
|
||||
ASSERT(settings._xml);
|
||||
ASSERT_EQUALS(2, settings._xml_version);
|
||||
ASSERT(settings.xml);
|
||||
ASSERT_EQUALS(2, settings.xml_version);
|
||||
}
|
||||
|
||||
void xmlverunknown() {
|
||||
|
@ -890,9 +890,9 @@ private:
|
|||
void showtime() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--showtime=summary"};
|
||||
settings._showtime = SHOWTIME_NONE;
|
||||
settings.showtime = SHOWTIME_NONE;
|
||||
ASSERT(defParser.ParseFromArgs(2, argv));
|
||||
ASSERT(settings._showtime == SHOWTIME_SUMMARY);
|
||||
ASSERT(settings.showtime == SHOWTIME_SUMMARY);
|
||||
}
|
||||
|
||||
void errorlist1() {
|
||||
|
@ -905,17 +905,17 @@ private:
|
|||
void errorlistverbose1() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--verbose", "--errorlist"};
|
||||
settings._verbose = false;
|
||||
settings.verbose = false;
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(settings._verbose);
|
||||
ASSERT(settings.verbose);
|
||||
}
|
||||
|
||||
void errorlistverbose2() {
|
||||
REDIRECT;
|
||||
const char *argv[] = {"cppcheck", "--errorlist", "--verbose"};
|
||||
settings._verbose = false;
|
||||
settings.verbose = false;
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(settings._verbose);
|
||||
ASSERT(settings.verbose);
|
||||
}
|
||||
|
||||
void ignorepathsnopath() {
|
||||
|
|
|
@ -235,7 +235,7 @@ private:
|
|||
std::list<std::string> configurations;
|
||||
std::string filedata = "";
|
||||
std::istringstream fin(precode);
|
||||
preprocessor.preprocess(fin, filedata, configurations, filename, settings._includePaths);
|
||||
preprocessor.preprocess(fin, filedata, configurations, filename, settings.includePaths);
|
||||
const std::string code = preprocessor.getcode(filedata, "", filename);
|
||||
|
||||
// Tokenize..
|
||||
|
|
|
@ -746,7 +746,7 @@ private:
|
|||
std::istringstream istr(filedata);
|
||||
std::map<std::string, std::string> actual;
|
||||
Settings settings;
|
||||
settings._maxConfigs = 1;
|
||||
settings.maxConfigs = 1;
|
||||
settings.userDefines = "X";
|
||||
Preprocessor preprocessor(settings, this);
|
||||
preprocessor.preprocess(istr, actual, "file.c"); // <- don't crash
|
||||
|
@ -831,7 +831,7 @@ private:
|
|||
errout.str("");
|
||||
Settings settings;
|
||||
settings.userDefines = "FOO";
|
||||
settings._force = true; // No message if --force is given
|
||||
settings.force = true; // No message if --force is given
|
||||
Preprocessor preprocessor(settings, this);
|
||||
const std::string code("#error hello world!\n");
|
||||
preprocessor.getcode(code, "X", "test.c");
|
||||
|
@ -2922,7 +2922,7 @@ private:
|
|||
void inline_suppression_for_missing_include() {
|
||||
Preprocessor::missingIncludeFlag = false;
|
||||
Settings settings;
|
||||
settings._inlineSuppressions = true;
|
||||
settings.inlineSuppressions = true;
|
||||
settings.addEnabled("all");
|
||||
Preprocessor preprocessor(settings, this);
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ private:
|
|||
|
||||
CppCheck cppCheck(*this, true);
|
||||
Settings& settings = cppCheck.settings();
|
||||
settings._inlineSuppressions = true;
|
||||
settings.inlineSuppressions = true;
|
||||
settings.addEnabled("information");
|
||||
settings.jointSuppressionReport = true;
|
||||
if (!suppression.empty()) {
|
||||
|
@ -169,8 +169,8 @@ private:
|
|||
files["test.cpp"] = 1;
|
||||
|
||||
Settings settings;
|
||||
settings._jobs = 1;
|
||||
settings._inlineSuppressions = true;
|
||||
settings.jobs = 1;
|
||||
settings.inlineSuppressions = true;
|
||||
settings.addEnabled("information");
|
||||
if (!suppression.empty()) {
|
||||
ASSERT_EQUALS("", settings.nomsg.addSuppressionLine(suppression));
|
||||
|
@ -372,9 +372,9 @@ private:
|
|||
CppCheck cppCheck(*this, true);
|
||||
Settings& settings = cppCheck.settings();
|
||||
settings.addEnabled("style");
|
||||
settings._inlineSuppressions = true;
|
||||
settings._relativePaths = true;
|
||||
settings._basePaths.push_back("/somewhere");
|
||||
settings.inlineSuppressions = true;
|
||||
settings.relativePaths = true;
|
||||
settings.basePaths.push_back("/somewhere");
|
||||
const char code[] =
|
||||
"struct Point\n"
|
||||
"{\n"
|
||||
|
|
|
@ -53,7 +53,7 @@ private:
|
|||
filemap[oss.str()] = 1;
|
||||
}
|
||||
|
||||
settings._jobs = jobs;
|
||||
settings.jobs = jobs;
|
||||
ThreadExecutor executor(filemap, settings, *this);
|
||||
for (std::map<std::string, std::size_t>::const_iterator i = filemap.begin(); i != filemap.end(); ++i)
|
||||
executor.addFileContent(i->first, data);
|
||||
|
|
|
@ -8302,7 +8302,7 @@ private:
|
|||
std::list<std::string> configurations;
|
||||
std::string filedata = "";
|
||||
std::istringstream fin(raw_code);
|
||||
preprocessor.preprocess(fin, filedata, configurations, emptyString, settings0._includePaths);
|
||||
preprocessor.preprocess(fin, filedata, configurations, emptyString, settings0.includePaths);
|
||||
const std::string code = preprocessor.getcode(filedata, emptyString, emptyString);
|
||||
|
||||
tokenizeAndStringify(code.c_str()); // just survive...
|
||||
|
|
Loading…
Reference in New Issue