|
Cppcheck
|
This is just a container for general settings so that we don't need to pass individual values to functions or constructors now or in the future when we might have even more detailed settings. More...
#include <settings.h>
Classes | |
| class | Rule |
| Rule. More... | |
Public Types | |
| enum | Language { None, C, CPP } |
| enum | PlatformType { Unspecified, Win32A, Win32W, Win64, Unix32, Unix64 } |
Public Member Functions | |
| Settings () | |
| void | terminate () |
| Request termination of checking. | |
| bool | terminated () const |
| termination requested? | |
| bool | append (const std::string &filename) |
| assign append code (--append) | |
| const std::string & | append () const |
| get append code (--append) | |
| bool | isEnabled (const std::string &str) const |
| Returns true if given id is in the list of enabled extra checks (--enable) | |
| std::string | addEnabled (const std::string &str) |
| Enable extra checks by id. | |
| bool | platform (PlatformType type) |
| set the platform type for predefined platforms | |
| bool | platformFile (const std::string &filename) |
| set the platform type for user specified platforms | |
Public Attributes | |
| bool | debug |
| Is --debug given? | |
| bool | debugwarnings |
| Is --debug-warnings given? | |
| bool | debugFalsePositive |
| Is --debug-fp given? | |
| bool | inconclusive |
| Inconclusive checks. | |
| bool | experimental |
| When this flag is false (default) then experimental heuristics and checks are disabled. | |
| bool | _errorsOnly |
| Is --quiet given? | |
| bool | _inlineSuppressions |
| Is --inline-suppr given? | |
| bool | _verbose |
| Is --verbose given? | |
| bool | _force |
| Force checking the files with "too many" configurations (--force). | |
| bool | _relativePaths |
| Use relative paths in output. | |
| std::vector< std::string > | _basePaths |
| Paths used as base for conversion to relative paths. | |
| bool | _xml |
| write XML results (--xml) | |
| int | _xml_version |
| XML version (--xmlver=..) | |
| unsigned int | _jobs |
| How many processes/threads should do checking at the same time. | |
| int | _exitCode |
| If errors are found, this value is returned from main(). | |
| std::string | _outputFormat |
| The output format in which the errors are printed in text mode, e.g. | |
| unsigned int | _showtime |
| show timing information (--showtime=file|summary|top5) | |
| std::list< std::string > | _includePaths |
| List of include paths, e.g. | |
| unsigned int | _maxConfigs |
| Maximum number of configurations to check before bailing. | |
| Language | enforcedLang |
| Name of the language that is enforced. | |
| Suppressions | nomsg |
| suppress message (--suppressions) | |
| Suppressions | nofail |
| suppress exitcode | |
| std::string | userDefines |
| defines given by the user | |
| std::set< std::string > | userUndefs |
| undefines given by the user | |
| std::list< std::string > | userIncludes |
| forced includes given by the user | |
| bool | reportProgress |
| --report-progress | |
| std::list< Rule > | rules |
| Extra rules. | |
| bool | checkConfiguration |
| Is the 'configuration checking' wanted? | |
| Standards | standards |
| Struct contains standards settings. | |
| unsigned int | sizeof_bool |
| size of standard types | |
| unsigned int | sizeof_short |
| unsigned int | sizeof_int |
| unsigned int | sizeof_long |
| unsigned int | sizeof_long_long |
| unsigned int | sizeof_float |
| unsigned int | sizeof_double |
| unsigned int | sizeof_long_double |
| unsigned int | sizeof_wchar_t |
| unsigned int | sizeof_size_t |
| unsigned int | sizeof_pointer |
| PlatformType | platformType |
| platform type | |
Private Attributes | |
| std::string | _append |
| Code to append in the checks. | |
| std::set< std::string > | _enabled |
| enable extra checks by id | |
| bool | _terminate |
| terminate checking | |
This is just a container for general settings so that we don't need to pass individual values to functions or constructors now or in the future when we might have even more detailed settings.
Definition at line 39 of file settings.h.
| enum Settings::Language |
Definition at line 152 of file settings.h.
Definition at line 215 of file settings.h.
Definition at line 26 of file settings.cpp.
References platform(), Unspecified, Win32A, and Win64.
| std::string Settings::addEnabled | ( | const std::string & | str | ) |
Enable extra checks by id.
See isEnabled()
| str | single id or list of id values to be enabled or empty string to enable all. e.g. "style,possibleError" |
Definition at line 54 of file settings.cpp.
References _enabled.
Referenced by MainWindow::GetCppcheckSettings(), and CmdLineParser::ParseFromArgs().
| bool Settings::append | ( | const std::string & | filename | ) |
assign append code (--append)
Definition at line 119 of file settings.cpp.
References _append, and Preprocessor::preprocessWhitespaces().
Referenced by CmdLineParser::ParseFromArgs(), and CppCheck::processFile().
| const std::string & Settings::append | ( | ) | const |
| bool Settings::isEnabled | ( | const std::string & | str | ) | const |
Returns true if given id is in the list of enabled extra checks (--enable)
| str | id for the extra check, e.g. "style" |
Definition at line 113 of file settings.cpp.
References _enabled.
Referenced by CheckBufferOverrun::arrayIndexThenCheck(), CheckAssert::assertWithSideEffects(), CheckAssignIf::assignIf(), CheckAutoVariables::autoVariables(), CppCheckExecutor::check(), CheckOther::checkAlwaysTrueOrFalseStringCompare(), CheckStl::checkAutoPointer(), CheckBool::checkBitwiseOnBoolean(), CheckOther::checkCastIntToCharAndBack(), CheckExceptionSafety::checkCatchExceptionByValue(), CheckOther::checkCharVariable(), CheckBool::checkComparisonOfBoolExpressionWithInt(), CheckBool::checkComparisonOfBoolWithBool(), CheckBool::checkComparisonOfBoolWithInt(), CheckBool::checkComparisonOfFuncReturningBool(), CheckClass::checkConst(), CheckOther::checkConstantFunctionParameter(), CheckStl::checkDereferenceInvalidIterator(), CheckOther::checkDuplicateBranch(), CheckOther::checkDuplicateExpression(), CheckOther::checkDuplicateIf(), CppCheck::checkFile(), CheckBufferOverrun::checkFunctionParameter(), CppCheck::checkFunctionUsage(), CheckUnusedVar::checkFunctionVariableUsage(), CheckOther::checkIncompleteArrayFill(), CheckOther::checkIncompleteStatement(), CheckOther::checkIncorrectLogicOperator(), CheckOther::checkIncorrectStringCompare(), CheckBool::checkIncrementBoolean(), CheckOther::checkMemsetZeroBytes(), CheckOther::checkModuloAlwaysTrueFalse(), CheckMemoryLeakInClass::checkPublicFunctions(), CheckOther::checkRedundantAssignment(), CheckOther::checkRedundantAssignmentInSwitch(), CheckOther::checkRedundantCopy(), CheckExceptionSafety::checkRethrowCopy(), CheckBufferOverrun::checkScope(), CheckOther::checkSelfAssignment(), CheckOther::checkSignOfUnsignedVariable(), CheckSizeof::checkSizeofForNumericParameter(), CheckSizeof::checkSizeofForPointerSize(), CheckUnusedVar::checkStructMemberUsage(), CheckOther::checkSuspiciousCaseInSwitch(), CheckOther::checkSuspiciousEqualityComparison(), CheckOther::checkSuspiciousSemicolon(), CheckOther::checkSuspiciousStringCompare(), CheckOther::checkSwitchCaseFallThrough(), CheckOther::checkUnreachableCode(), CheckOther::checkUnsignedDivision(), CheckOther::checkVarFuncNullUB(), CheckOther::checkVariableScope(), CheckIO::checkWrongPrintfScanfArguments(), CheckOther::clarifyCalculation(), CheckOther::clarifyCondition(), CheckOther::clarifyStatement(), CheckAssignIf::comparison(), CheckLeakAutoVar::configurationInfo(), CheckClass::constructors(), CheckClass::copyconstructors(), CheckExceptionSafety::deallocThrow(), Tokenizer::duplicateDeclarationError(), Tokenizer::duplicateEnumError(), Tokenizer::duplicateTypedefError(), CheckStl::if_find(), CheckClass::initializationListUsage(), CheckClass::initializerListOrder(), CppCheck::internalError(), CheckOther::invalidPointerCast(), CheckIO::invalidScanf(), CheckIO::invalidScanfFormatWidthError(), CheckStl::missingComparison(), CheckAssignIf::multiCondition(), CheckClass::noMemset(), CheckNonReentrantFunctions::nonReentrantFunctions(), CheckNullPointer::nullPointer(), CheckObsoleteFunctions::obsoleteFunctions(), CheckClass::operatorEq(), CheckClass::operatorEqRetRefThis(), CheckClass::operatorEqToSelf(), CheckOther::oppositeInnerCondition(), CmdLineParser::ParseFromArgs(), Check64BitPortability::pointerassignment(), CheckPostfixOperator::postfixOperator(), CheckClass::privateFunctions(), CppCheck::processFile(), CheckOther::redundantGetAndSetUserId(), Preprocessor::removeComments(), Tokenizer::removeUnnecessaryQualification(), CheckInternal::runSimplifiedChecks(), Tokenizer::simplifyEnum(), CheckStl::size(), CheckBufferOverrun::sizeArgumentAsCharError(), CheckSizeof::sizeofCalculation(), CheckSizeof::sizeofsizeof(), CheckStl::string_c_str(), CheckBufferOverrun::strncatUsageError(), CheckSizeof::suspiciousSizeofCalculation(), CheckClass::thisSubtraction(), Tokenizer::tokenize(), CppCheck::tooManyConfigsError(), CheckStl::uselessCalls(), Preprocessor::validateCfg(), CheckOther::warningOldStylePointerCast(), and CheckIO::wrongPrintfScanfArgumentsError().
| bool Settings::platform | ( | PlatformType | type | ) |
set the platform type for predefined platforms
Definition at line 138 of file settings.cpp.
References platformType, sizeof_bool, sizeof_double, sizeof_float, sizeof_int, sizeof_long, sizeof_long_double, sizeof_long_long, sizeof_pointer, sizeof_short, sizeof_size_t, sizeof_wchar_t, Unix32, Unix64, Unspecified, Win32A, Win32W, and Win64.
Referenced by CmdLineParser::ParseFromArgs(), and Settings().
| bool Settings::platformFile | ( | const std::string & | filename | ) |
set the platform type for user specified platforms
Definition at line 218 of file settings.cpp.
| void Settings::terminate | ( | ) | [inline] |
Request termination of checking.
Definition at line 83 of file settings.h.
| bool Settings::terminated | ( | ) | const [inline] |
termination requested?
Definition at line 88 of file settings.h.
Referenced by CppCheck::checkFile(), Preprocessor::handleIncludes(), CppCheck::processFile(), Tokenizer::simplifyKnownVariables(), and Tokenizer::simplifyTokenList().
std::string Settings::_append [private] |
| std::vector<std::string> Settings::_basePaths |
Paths used as base for conversion to relative paths.
Definition at line 99 of file settings.h.
Referenced by TokenList::createTokens(), CmdLineParser::ParseFromArgs(), and Tokenizer::tokenize().
std::set<std::string> Settings::_enabled [private] |
enable extra checks by id
Definition at line 45 of file settings.h.
Referenced by addEnabled(), and isEnabled().
Is --quiet given?
Definition at line 74 of file settings.h.
Referenced by CppCheckExecutor::check(), CppCheck::checkFunctionUsage(), MainWindow::GetCppcheckSettings(), CmdLineParser::ParseFromArgs(), and CppCheck::processFile().
If errors are found, this value is returned from main().
Default value is 0.
Definition at line 113 of file settings.h.
Referenced by CppCheckExecutor::check(), and CmdLineParser::ParseFromArgs().
| bool Settings::_force |
Force checking the files with "too many" configurations (--force).
Definition at line 93 of file settings.h.
Referenced by MainWindow::GetCppcheckSettings(), CmdLineParser::ParseFromArgs(), and CppCheck::processFile().
| std::list<std::string> Settings::_includePaths |
List of include paths, e.g.
"my/includes/" which should be used for finding include files inside source files. (-I)
Definition at line 124 of file settings.h.
Referenced by MainWindow::AddIncludeDirs(), CppCheck::analyseFile(), CmdLineParser::ParseFromArgs(), CppCheckExecutor::parseFromArgs(), and CppCheck::processFile().
Is --inline-suppr given?
Definition at line 77 of file settings.h.
Referenced by MainWindow::GetCppcheckSettings(), CmdLineParser::ParseFromArgs(), and Preprocessor::removeComments().
| unsigned int Settings::_jobs |
How many processes/threads should do checking at the same time.
Default is 1. (-j N)
Definition at line 109 of file settings.h.
Referenced by CppCheckExecutor::check(), ThreadHandler::Check(), CppCheck::checkFile(), CppCheck::checkFunctionUsage(), CheckUninitVar::executionPaths(), MainWindow::GetCppcheckSettings(), and CmdLineParser::ParseFromArgs().
| unsigned int Settings::_maxConfigs |
Maximum number of configurations to check before bailing.
Default is 12. (--max-configs=N)
Definition at line 134 of file settings.h.
Referenced by CmdLineParser::ParseFromArgs(), Preprocessor::preprocess(), CppCheck::processFile(), and CppCheck::tooManyConfigsError().
| std::string Settings::_outputFormat |
The output format in which the errors are printed in text mode, e.g.
"{severity} {file}:{line} {message} {id}"
Definition at line 117 of file settings.h.
Referenced by CmdLineParser::ParseFromArgs(), and CppCheckExecutor::reportErr().
Use relative paths in output.
Definition at line 96 of file settings.h.
Referenced by CmdLineParser::ParseFromArgs().
| unsigned int Settings::_showtime |
show timing information (--showtime=file|summary|top5)
Definition at line 120 of file settings.h.
Referenced by CppCheck::checkFile(), CmdLineParser::ParseFromArgs(), CppCheck::processFile(), Tokenizer::tokenize(), and CppCheck::~CppCheck().
bool Settings::_terminate [private] |
terminate checking
Definition at line 48 of file settings.h.
| bool Settings::_verbose |
Is --verbose given?
Definition at line 80 of file settings.h.
Referenced by CppCheck::checkFunctionUsage(), CheckMemoryLeakInFunction::checkScope(), MainWindow::GetCppcheckSettings(), CmdLineParser::ParseFromArgs(), CppCheckExecutor::reportErr(), CppCheck::reportErr(), and Tokenizer::simplifyTokenList().
| bool Settings::_xml |
write XML results (--xml)
Definition at line 102 of file settings.h.
Referenced by CppCheckExecutor::check(), MainWindow::GetCppcheckSettings(), CmdLineParser::ParseFromArgs(), and CppCheckExecutor::reportErr().
XML version (--xmlver=..)
Definition at line 105 of file settings.h.
Referenced by CppCheckExecutor::check(), CmdLineParser::ParseFromArgs(), CppCheckExecutor::parseFromArgs(), and CppCheckExecutor::reportErr().
Is the 'configuration checking' wanted?
Definition at line 197 of file settings.h.
Referenced by CppCheck::analyseFile(), CppCheckExecutor::check(), CppCheck::checkFile(), Preprocessor::getErrorMessages(), Preprocessor::missingInclude(), CmdLineParser::ParseFromArgs(), and CppCheck::processFile().
| bool Settings::debug |
Is --debug given?
Definition at line 54 of file settings.h.
Referenced by CheckMemoryLeakInFunction::checkScope(), MainWindow::GetCppcheckSettings(), CmdLineParser::ParseFromArgs(), and Tokenizer::simplifyTokenList().
Is --debug-fp given?
Definition at line 60 of file settings.h.
Referenced by CmdLineParser::ParseFromArgs(), CppCheck::processFile(), and CppCheck::reportErr().
Is --debug-warnings given?
Definition at line 57 of file settings.h.
Referenced by CheckMemoryLeakInFunction::checkScope(), CheckUninitVar::checkScopeForVariable(), SymbolDatabase::debugMessage(), Preprocessor::getcfgs(), MainWindow::GetCppcheckSettings(), CmdLineParser::ParseFromArgs(), CppCheck::processFile(), Tokenizer::simplifyKnownVariablesSimplify(), TemplateSimplifier::simplifyTemplateInstantiations(), Tokenizer::simplifyTokenList(), SymbolDatabase::SymbolDatabase(), and Tokenizer::unsupportedTypedef().
Name of the language that is enforced.
Empty per default.
Definition at line 157 of file settings.h.
Referenced by Preprocessor::getcode(), Tokenizer::isC(), Tokenizer::isCPP(), and CmdLineParser::ParseFromArgs().
When this flag is false (default) then experimental heuristics and checks are disabled.
It should not be possible to enable this from any client.
Definition at line 71 of file settings.h.
Referenced by CheckMemoryLeakInFunction::call_func(), CheckBool::checkComparisonOfBoolWithBool(), CheckOther::checkSwitchCaseFallThrough(), CheckLeakAutoVar::configurationInfo(), CheckOther::oppositeInnerCondition(), Preprocessor::removeComments(), and CheckMemoryLeakInFunction::simplifycode().
Inconclusive checks.
Definition at line 63 of file settings.h.
Referenced by CheckAutoVariables::autoVariables(), CheckBool::checkBitwiseOnBoolean(), CheckClass::checkConst(), CheckOther::checkIncompleteArrayFill(), CheckOther::checkInvalidFree(), CheckBufferOverrun::checkReadlinkBufferUsage(), CheckBufferOverrun::checkScope(), CheckOther::checkSignOfUnsignedVariable(), CheckSizeof::checkSizeofForPointerSize(), CheckOther::checkSuspiciousCaseInSwitch(), CheckOther::checkSuspiciousEqualityComparison(), CheckOther::checkSuspiciousSemicolon(), CheckOther::checkUnreachableCode(), CheckOther::checkUnsignedDivision(), CheckClass::constructors(), CheckExceptionSafety::deallocThrow(), Tokenizer::duplicateTypedefError(), MainWindow::GetCppcheckSettings(), CheckClass::initializerListOrder(), CheckOther::invalidPointerCast(), CheckIO::invalidScanfFormatWidthError(), CheckNullPointer::nullPointerByCheckAndDeRef(), CheckNullPointer::nullPointerByDeRefAndChec(), CheckNullPointer::nullPointerStructByDeRefAndChec(), CheckOther::oppositeInnerCondition(), CmdLineParser::ParseFromArgs(), CheckSizeof::sizeofCalculation(), CheckStl::string_c_str(), and CheckSizeof::suspiciousSizeofCalculation().
suppress exitcode
Definition at line 163 of file settings.h.
Referenced by CmdLineParser::ParseFromArgs(), and CppCheck::reportErr().
suppress message (--suppressions)
Definition at line 160 of file settings.h.
Referenced by CppCheckExecutor::check(), Preprocessor::missingInclude(), CmdLineParser::ParseFromArgs(), CppCheck::processFile(), Preprocessor::removeComments(), CppCheck::reportErr(), and CppCheck::reportInfo().
platform type
Definition at line 225 of file settings.h.
Referenced by MainWindow::GetCppcheckSettings(), CheckIO::invalidScanf(), platform(), Tokenizer::simplifyMicrosoftMemoryFunctions(), Tokenizer::simplifyMicrosoftMFC(), Tokenizer::simplifyMicrosoftStringFunctions(), and Tokenizer::simplifyPlatformTypes().
--report-progress
Definition at line 175 of file settings.h.
Referenced by CppCheckExecutor::check(), and CmdLineParser::ParseFromArgs().
| std::list<Rule> Settings::rules |
Extra rules.
Definition at line 194 of file settings.h.
Referenced by CppCheck::checkFile(), and CmdLineParser::ParseFromArgs().
| unsigned int Settings::sizeof_bool |
size of standard types
Definition at line 203 of file settings.h.
Referenced by Tokenizer::fillTypeSizes(), and platform().
| unsigned int Settings::sizeof_double |
Definition at line 209 of file settings.h.
Referenced by Tokenizer::fillTypeSizes(), and platform().
| unsigned int Settings::sizeof_float |
Definition at line 208 of file settings.h.
Referenced by Tokenizer::fillTypeSizes(), and platform().
| unsigned int Settings::sizeof_int |
Definition at line 205 of file settings.h.
Referenced by Tokenizer::fillTypeSizes(), CheckOther::isUnsigned(), and platform().
| unsigned int Settings::sizeof_long |
Definition at line 206 of file settings.h.
Referenced by Tokenizer::fillTypeSizes(), platform(), and Tokenizer::simplifyPlatformTypes().
| unsigned int Settings::sizeof_long_double |
Definition at line 210 of file settings.h.
Referenced by platform(), and Tokenizer::sizeOfType().
| unsigned int Settings::sizeof_long_long |
Definition at line 207 of file settings.h.
Referenced by platform(), and Tokenizer::sizeOfType().
| unsigned int Settings::sizeof_pointer |
Definition at line 213 of file settings.h.
Referenced by Tokenizer::fillTypeSizes(), and platform().
| unsigned int Settings::sizeof_short |
Definition at line 204 of file settings.h.
Referenced by Tokenizer::fillTypeSizes(), and platform().
| unsigned int Settings::sizeof_size_t |
Definition at line 212 of file settings.h.
Referenced by Tokenizer::fillTypeSizes(), platform(), and Tokenizer::simplifyPlatformTypes().
| unsigned int Settings::sizeof_wchar_t |
Definition at line 211 of file settings.h.
Referenced by Tokenizer::fillTypeSizes(), and platform().
Struct contains standards settings.
Definition at line 200 of file settings.h.
Referenced by CheckOther::checkPipeParameterSize(), CheckBufferOverrun::checkScope(), CheckOther::checkSleepTimeInterval(), CheckLeakAutoVar::deallocUseError(), CheckMemoryLeakInFunction::getcode(), MainWindow::GetCppcheckSettings(), CheckLeakAutoVar::leakError(), CheckLeakAutoVar::mismatchError(), CheckNonReentrantFunctions::nonReentrantFunctions(), CheckObsoleteFunctions::obsoleteFunctions(), CmdLineParser::ParseFromArgs(), CheckOther::redundantGetAndSetUserId(), Tokenizer::simplifyKeyword(), Tokenizer::simplifyNamespaceStd(), Tokenizer::simplifyNull(), and CheckBufferOverrun::writeOutsideBufferSize().
| std::string Settings::userDefines |
defines given by the user
Definition at line 166 of file settings.h.
Referenced by Preprocessor::getcode(), MainWindow::GetCppcheckSettings(), CmdLineParser::ParseFromArgs(), Preprocessor::preprocess(), CppCheck::processFile(), and Preprocessor::removeComments().
| std::list<std::string> Settings::userIncludes |
forced includes given by the user
Definition at line 172 of file settings.h.
Referenced by CmdLineParser::ParseFromArgs(), and Preprocessor::preprocess().
| std::set<std::string> Settings::userUndefs |
undefines given by the user
Definition at line 169 of file settings.h.
Referenced by Preprocessor::getcode(), Preprocessor::handleIncludes(), Preprocessor::handleUndef(), CmdLineParser::ParseFromArgs(), and Preprocessor::preprocess().
1.7.6.1