int CppCheckExecutor::check(int argc, const char* const argv[]) { CppCheck cppCheck(*this, true); if (!parseFromArgs(&cppCheck, argc, argv)) { return EXIT_FAILURE; } if (cppCheck.settings().reportProgress) time1 = std::time(0); _settings = cppCheck.settings(); if (_settings._xml) { reportErr(ErrorLogger::ErrorMessage::getXMLHeader(_settings._xml_version)); } unsigned int returnValue = 0; if (_settings._jobs == 1) { // Single process returnValue = cppCheck.check(); } else if (!ThreadExecutor::isEnabled()) { std::cout << "No thread support yet implemented for this platform." << std::endl; } else { // Multiple processes const std::vector<std::string> &filenames = cppCheck.filenames(); Settings &settings = cppCheck.settings(); ThreadExecutor executor(filenames, settings, *this); returnValue = executor.check(); } reportUnmatchedSuppressions(cppCheck.settings().nomsg.getUnmatchedGlobalSuppressions()); if (_settings._xml) { reportErr(ErrorLogger::ErrorMessage::getXMLFooter(_settings._xml_version)); } if (returnValue) return _settings._exitCode; else return 0; }
int CppCheckExecutor::check(int argc, const char* const argv[]) { Preprocessor::missingIncludeFlag = false; Preprocessor::missingSystemIncludeFlag = false; CppCheck cppCheck(*this, true); const Settings& settings = cppCheck.settings(); _settings = &settings; if (!parseFromArgs(&cppCheck, argc, argv)) { return EXIT_FAILURE; } if (settings.terminated()) { return EXIT_SUCCESS; } if (cppCheck.settings().exceptionHandling) { return check_wrapper(cppCheck, argc, argv); } else { return check_internal(cppCheck, argc, argv); } }
int CppCheckExecutor::check(int argc, const char* const argv[]) { Preprocessor::missingIncludeFlag = false; CppCheck cppCheck(*this, true); Settings& settings = cppCheck.settings(); _settings = &settings; if (!parseFromArgs(&cppCheck, argc, argv)) { return EXIT_FAILURE; } bool std = settings.library.load(argv[0], "std.cfg"); bool posix = true; if (settings.standards.posix) posix = settings.library.load(argv[0], "posix.cfg"); if (!std || !posix) { const std::list<ErrorLogger::ErrorMessage::FileLocation> callstack; const std::string msg("Failed to load " + std::string(!std ? "std.cfg" : "posix.cfg") + ". Your Cppcheck installation is broken, please re-install."); #ifdef CFGDIR const std::string details("The Cppcheck binary was compiled with CFGDIR set to \"" + std::string(CFGDIR) + "\" and will therefore search for " "std.cfg in that path."); #else const std::string cfgfolder(Path::fromNativeSeparators(Path::getPathFromFilename(argv[0])) + "cfg"); const std::string details("The Cppcheck binary was compiled without CFGDIR set. Either the " "std.cfg should be available in " + cfgfolder + " or the CFGDIR " "should be configured."); #endif ErrorLogger::ErrorMessage errmsg(callstack, Severity::information, msg+" "+details, "failedToLoadCfg", false); reportErr(errmsg); return EXIT_FAILURE; } if (settings.reportProgress) time1 = std::time(0); if (settings._xml) { reportErr(ErrorLogger::ErrorMessage::getXMLHeader(settings._xml_version)); } unsigned int returnValue = 0; if (settings._jobs == 1) { // Single process std::size_t totalfilesize = 0; for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) { totalfilesize += i->second; } std::size_t processedsize = 0; unsigned int c = 0; for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) { if (!_settings->library.markupFile(i->first) || !_settings->library.processMarkupAfterCode(i->first)) { returnValue += cppCheck.check(i->first); processedsize += i->second; if (!settings._errorsOnly) reportStatus(c + 1, _files.size(), processedsize, totalfilesize); c++; } } // second loop to parse all markup files which may not work until all // c/cpp files have been parsed and checked for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) { if (_settings->library.markupFile(i->first) && _settings->library.processMarkupAfterCode(i->first)) { returnValue += cppCheck.check(i->first); processedsize += i->second; if (!settings._errorsOnly) reportStatus(c + 1, _files.size(), processedsize, totalfilesize); c++; } } cppCheck.checkFunctionUsage(); } else if (!ThreadExecutor::isEnabled()) { std::cout << "No thread support yet implemented for this platform." << std::endl; } else { // Multiple processes ThreadExecutor executor(_files, settings, *this); returnValue = executor.check(); } if (settings.isEnabled("information") || settings.checkConfiguration) reportUnmatchedSuppressions(settings.nomsg.getUnmatchedGlobalSuppressions()); if (!settings.checkConfiguration) { cppCheck.tooManyConfigsError("",0U); if (settings.isEnabled("missingInclude") && Preprocessor::missingIncludeFlag) { const std::list<ErrorLogger::ErrorMessage::FileLocation> callStack; ErrorLogger::ErrorMessage msg(callStack, Severity::information, "Cppcheck cannot find all the include files (use --check-config for details)\n" "Cppcheck cannot find all the include files. Cppcheck can check the code without the " "include files found. But the results will probably be more accurate if all the include " "files are found. Please check your project's include directories and add all of them " "as include directories for Cppcheck. To see what files Cppcheck cannot find use " "--check-config.", "missingInclude", false); reportInfo(msg); } } if (settings._xml) { reportErr(ErrorLogger::ErrorMessage::getXMLFooter(settings._xml_version)); } _settings = 0; if (returnValue) return settings._exitCode; else return 0; }
int CppCheckExecutor::check(int argc, const char* const argv[]) { Preprocessor::missingIncludeFlag = false; CppCheck cppCheck(*this, true); Settings& settings = cppCheck.settings(); _settings = &settings; if (!parseFromArgs(&cppCheck, argc, argv)) { return EXIT_FAILURE; } if (settings.reportProgress) time1 = std::time(0); if (settings._xml) { reportErr(ErrorLogger::ErrorMessage::getXMLHeader(settings._xml_version)); } unsigned int returnValue = 0; if (settings._jobs == 1) { // Single process std::size_t totalfilesize = 0; for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) { totalfilesize += i->second; } std::size_t processedsize = 0; unsigned int c = 0; for (std::map<std::string, std::size_t>::const_iterator i = _files.begin(); i != _files.end(); ++i) { returnValue += cppCheck.check(i->first); processedsize += i->second; if (!settings._errorsOnly) reportStatus(c + 1, _files.size(), processedsize, totalfilesize); c++; } cppCheck.checkFunctionUsage(); } else if (!ThreadExecutor::isEnabled()) { std::cout << "No thread support yet implemented for this platform." << std::endl; } else { // Multiple processes ThreadExecutor executor(_files, settings, *this); returnValue = executor.check(); } if (!settings.checkConfiguration) { if (!settings._errorsOnly) reportUnmatchedSuppressions(settings.nomsg.getUnmatchedGlobalSuppressions()); cppCheck.tooManyConfigsError("",0U); if (settings.isEnabled("missingInclude") && Preprocessor::missingIncludeFlag) { const std::list<ErrorLogger::ErrorMessage::FileLocation> callStack; ErrorLogger::ErrorMessage msg(callStack, Severity::information, "Cppcheck cannot find all the include files (use --check-config for details)\n" "Cppcheck cannot find all the include files. Cppcheck can check the code without the " "include files found. But the results will probably be more accurate if all the include " "files are found. Please check your project's include directories and add all of them " "as include directories for Cppcheck. To see what files Cppcheck cannot find use " "--check-config.", "missingInclude", false); reportInfo(msg); } } if (settings._xml) { reportErr(ErrorLogger::ErrorMessage::getXMLFooter(settings._xml_version)); } _settings = 0; if (returnValue) return settings._exitCode; else return 0; }