Cppcheck
|
The command line parser. More...
#include <cmdlineparser.h>
Public Types | |
enum class | Result { Success , Exit , Fail } |
Public Member Functions | |
CmdLineParser (CmdLineLogger &logger, Settings &settings, Suppressions &suppressions) | |
The constructor. More... | |
bool | fillSettingsFromArgs (int argc, const char *const argv[]) |
Parse command line args and fill settings and file lists from there. More... | |
Result | parseFromArgs (int argc, const char *const argv[]) |
Parse given command line. More... | |
const std::vector< std::string > & | getPathNames () const |
Return the path names user gave to command line. More... | |
const std::list< FileWithDetails > & | getFiles () const |
Return the files user gave to command line. More... | |
const std::list< FileSettings > & | getFileSettings () const |
Return the file settings read from command line. More... | |
const std::vector< std::string > & | getIgnoredPaths () const |
Return a list of paths user wants to ignore. More... | |
std::string | getVersion () const |
Get Cppcheck version. More... | |
Protected Member Functions | |
void | printHelp () const |
Print help text to the console. More... | |
Private Member Functions | |
bool | isCppcheckPremium () const |
template<typename T > | |
bool | parseNumberArg (const char *const arg, std::size_t offset, T &num, bool mustBePositive=false) |
bool | tryLoadLibrary (Library &destination, const std::string &basepath, const char *filename) |
Tries to load a library and prints warning/error messages. More... | |
bool | loadLibraries (Settings &settings) |
Load libraries. More... | |
bool | loadAddons (Settings &settings) |
Load addons. More... | |
bool | loadCppcheckCfg () |
Private Attributes | |
CmdLineLogger & | mLogger |
std::vector< std::string > | mPathNames |
std::list< FileWithDetails > | mFiles |
std::list< FileSettings > | mFileSettings |
std::vector< std::string > | mIgnoredPaths |
Settings & | mSettings |
Suppressions & | mSuppressions |
std::string | mVSConfig |
The command line parser.
The command line parser parses options and parameters user gives to cppcheck command line.
The parser takes a pointer to Settings instance which it will update based on options user has given. Couple of options are handled as class internal options.
Definition at line 48 of file cmdlineparser.h.
|
strong |
Enumerator | |
---|---|
Success | |
Exit | |
Fail |
Definition at line 59 of file cmdlineparser.h.
CmdLineParser::CmdLineParser | ( | CmdLineLogger & | logger, |
Settings & | settings, | ||
Suppressions & | suppressions | ||
) |
The constructor.
logger | The logger instance to log messages through |
settings | Settings instance that will be modified according to options user has given. |
suppressions | Suppressions instance that keeps the suppressions |
Definition at line 138 of file cmdlineparser.cpp.
bool CmdLineParser::fillSettingsFromArgs | ( | int | argc, |
const char *const | argv[] | ||
) |
Parse command line args and fill settings and file lists from there.
Definition at line 144 of file cmdlineparser.cpp.
References Exit, Fail, Settings::fileFilters, getFileSettings(), getIgnoredPaths(), getPathNames(), Settings::includePaths, information, Path::isDirectory(), SimpleEnableGroup< T >::isEnabled(), Settings::library, loadAddons(), loadLibraries(), Library::markupExtensions(), mFiles, mFileSettings, mLogger, mSettings, parseFromArgs(), CmdLineLogger::printError(), CmdLineLogger::printMessage(), FileLister::recursiveAddFiles(), Settings::severity, Success, Settings::terminate(), and Path::toNativeSeparators().
Referenced by CppCheckExecutor::check().
|
inline |
Return the files user gave to command line.
Definition at line 87 of file cmdlineparser.h.
References mFiles.
Referenced by CppCheckExecutor::check().
|
inline |
Return the file settings read from command line.
Definition at line 94 of file cmdlineparser.h.
References mFileSettings.
Referenced by CppCheckExecutor::check(), and fillSettingsFromArgs().
|
inline |
Return a list of paths user wants to ignore.
Definition at line 101 of file cmdlineparser.h.
References mIgnoredPaths.
Referenced by fillSettingsFromArgs().
|
inline |
Return the path names user gave to command line.
Definition at line 80 of file cmdlineparser.h.
References mPathNames.
Referenced by fillSettingsFromArgs().
std::string CmdLineParser::getVersion | ( | ) | const |
Get Cppcheck version.
Definition at line 1789 of file cmdlineparser.cpp.
References Settings::cppcheckCfgProductName, CppCheck::extraVersion(), mSettings, and CppCheck::version().
Referenced by parseFromArgs().
|
private |
Definition at line 1798 of file cmdlineparser.cpp.
References Settings::cppcheckCfgProductName, Settings::loadCppcheckCfg(), mSettings, startsWith(), and Settings::supprs.
Referenced by parseFromArgs(), and printHelp().
|
private |
Load addons.
settings | Settings |
Definition at line 1878 of file cmdlineparser.cpp.
References Settings::addonInfos, Settings::addons, Settings::exename, AddonInfo::getAddonInfo(), mLogger, and CmdLineLogger::printRaw().
Referenced by fillSettingsFromArgs().
|
private |
Definition at line 1894 of file cmdlineparser.cpp.
References Settings::loadCppcheckCfg(), mLogger, mSettings, mSuppressions, and CmdLineLogger::printError().
Referenced by parseFromArgs().
|
private |
Load libraries.
settings | Settings |
Definition at line 1851 of file cmdlineparser.cpp.
References Settings::exename, Path::fromNativeSeparators(), Path::getPathFromFilename(), Settings::libraries, Settings::library, mLogger, CmdLineLogger::printRaw(), and tryLoadLibrary().
Referenced by fillSettingsFromArgs().
CmdLineParser::Result CmdLineParser::parseFromArgs | ( | int | argc, |
const char *const | argv[] | ||
) |
Parse given command line.
Definition at line 310 of file cmdlineparser.cpp.
References Settings::addEnabled(), addFilesToList(), addIncludePathsToList(), Settings::addonPython, Settings::addons, addPathsToSet(), SuppressionList::addSuppressionLine(), ImportProject::analyzeAllVsConfigs, Settings::basePaths, Settings::buildDir, Standards::c, Settings::certainty, Settings::checkAllConfigurations, Settings::checkConfiguration, Settings::checkersReportFilename, Settings::checkLibrary, Settings::checks, Settings::checksMaxTime, Settings::clang, Settings::clangExecutable, Settings::configExcludePaths, Standards::cpp, ImportProject::CPPCHECK_GUI, Settings::cppcheckCfgProductName, Settings::daca, Settings::debugnormal, Settings::debugSimplified, Settings::debugtemplate, Settings::debugwarnings, Settings::defaultExecutor(), Platform::defaultSign, Settings::dump, empty_if_null(), SimpleEnableGroup< T >::enable(), endsWith(), Settings::enforcedLang, ImportProject::excludedPaths, Settings::executor, Settings::exename, Settings::exhaustive, Exit, Settings::exitCode, Fail, ImportProject::FAILURE, Settings::fileFilters, ImportProject::fileSettings, Settings::force, Path::fromNativeSeparators(), Standards::getC(), Standards::getCPP(), Path::getCurrentExecutablePath(), CppCheck::getErrorMessages(), getVersion(), ErrorMessage::getXMLFooter(), ErrorMessage::getXMLHeader(), ImportProject::guiProject, ImportProject::ignoreOtherConfigs(), ImportProject::ignorePaths(), ImportProject::import(), Settings::includePaths, inconclusive, Settings::inlineSuppressions, Check::instances(), isCppcheckPremium(), Path::isDirectory(), SimpleEnableGroup< T >::isEnabled(), Settings::jobs, ImportProject::libraries, Settings::libraries, Settings::loadAverage, loadCppcheckCfg(), Settings::maxConfigs, Settings::maxCtuDepth, mFileSettings, mIgnoredPaths, ImportProject::MISSING, mLogger, mPathNames, mSettings, mSuppressions, mVSConfig, Suppressions::nofail, Suppressions::nomsg, none, ImportProject::NONE, Settings::normal, Settings::outputFile, SuppressionList::parseFile(), parseNumberArg(), SuppressionList::parseXmlFile(), ImportProject::pathNames, Settings::performanceValueFlowMaxIfCount, Settings::performanceValueFlowMaxTime, ImportProject::platform, Settings::platform, Settings::plistOutput, Settings::premiumArgs, Settings::preprocessOnly, CmdLineLogger::printError(), printHelp(), CmdLineLogger::printMessage(), CmdLineLogger::printRaw(), ImportProject::projectFile, ImportProject::projectType, Settings::quiet, Settings::relativePaths, Settings::removeEnabled(), Path::removeQuotationMarks(), Settings::reportProgress, Settings::safety, ImportProject::selectOneVsConfig(), Platform::set(), Settings::setCheckLevel(), CppCheckExecutor::setExceptionOutput(), severityFromString(), Settings::showtime, SHOWTIME_FILE, SHOWTIME_FILE_TOTAL, SHOWTIME_NONE, SHOWTIME_SUMMARY, SHOWTIME_TOP5_FILE, SHOWTIME_TOP5_SUMMARY, Path::simplifyPath(), Settings::standards, startsWith(), strToInt(), substituteTemplateFormatStatic(), substituteTemplateLocationStatic(), Success, Settings::templateFormat, Settings::templateLocation, Settings::templateMaxTime, Path::toNativeSeparators(), Platform::type, Settings::typedefMaxTime, ImportProject::UNKNOWN, unusedFunction, Settings::userDefines, Settings::userIncludes, Settings::userUndefs, Settings::useSingleJob(), Settings::valueFlowMaxIterations, Settings::verbose, ImportProject::VS_SLN, ImportProject::VS_VCXPROJ, Settings::xml, and Settings::xml_version.
Referenced by fillSettingsFromArgs().
|
inlineprivate |
Definition at line 121 of file cmdlineparser.h.
References mLogger, CmdLineLogger::printError(), and strToInt().
Referenced by parseFromArgs().
|
protected |
Print help text to the console.
Definition at line 1433 of file cmdlineparser.cpp.
References isCppcheckPremium(), mLogger, and CmdLineLogger::printRaw().
Referenced by parseFromArgs().
|
private |
Tries to load a library and prints warning/error messages.
Definition at line 1804 of file cmdlineparser.cpp.
References Library::BAD_ATTRIBUTE_VALUE, Library::BAD_XML, Library::DUPLICATE_DEFINE, Library::DUPLICATE_PLATFORM_TYPE, Library::Error::errorcode, Library::FILE_NOT_FOUND, Library::load(), Library::MISSING_ATTRIBUTE, mLogger, Library::OK, Library::PLATFORM_TYPE_REDEFINED, CmdLineLogger::printMessage(), Library::Error::reason, Library::UNKNOWN_ELEMENT, and Library::UNSUPPORTED_FORMAT.
Referenced by loadLibraries().
|
private |
Definition at line 162 of file cmdlineparser.h.
Referenced by fillSettingsFromArgs(), and getFiles().
|
private |
Definition at line 163 of file cmdlineparser.h.
Referenced by fillSettingsFromArgs(), getFileSettings(), and parseFromArgs().
|
private |
Definition at line 164 of file cmdlineparser.h.
Referenced by getIgnoredPaths(), and parseFromArgs().
|
private |
Definition at line 159 of file cmdlineparser.h.
Referenced by fillSettingsFromArgs(), loadAddons(), loadCppcheckCfg(), loadLibraries(), parseFromArgs(), parseNumberArg(), printHelp(), and tryLoadLibrary().
|
private |
Definition at line 161 of file cmdlineparser.h.
Referenced by getPathNames(), and parseFromArgs().
|
private |
Definition at line 165 of file cmdlineparser.h.
Referenced by fillSettingsFromArgs(), getVersion(), isCppcheckPremium(), loadCppcheckCfg(), and parseFromArgs().
|
private |
Definition at line 166 of file cmdlineparser.h.
Referenced by loadCppcheckCfg(), and parseFromArgs().
|
private |
Definition at line 167 of file cmdlineparser.h.
Referenced by parseFromArgs().