Cppcheck
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes
Settings Class Reference

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>

List of all members.

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< Rulerules
 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

Detailed Description

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.


Member Enumeration Documentation

Enumerator:
None 
C 
CPP 

Definition at line 152 of file settings.h.

Enumerator:
Unspecified 
Win32A 
Win32W 
Win64 
Unix32 
Unix64 

Definition at line 215 of file settings.h.


Constructor & Destructor Documentation

Definition at line 26 of file settings.cpp.

References platform(), Unspecified, Win32A, and Win64.


Member Function Documentation

std::string Settings::addEnabled ( const std::string &  str)

Enable extra checks by id.

See isEnabled()

Parameters:
strsingle id or list of id values to be enabled or empty string to enable all. e.g. "style,possibleError"
Returns:
error message. empty upon success

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

get append code (--append)

Definition at line 133 of file settings.cpp.

References _append.

bool Settings::isEnabled ( const std::string &  str) const

Returns true if given id is in the list of enabled extra checks (--enable)

Parameters:
strid for the extra check, e.g. "style"
Returns:
true if the check is enabled.

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::platformFile ( const std::string &  filename)

set the platform type for user specified platforms

Todo:
TBD

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]

Member Data Documentation

std::string Settings::_append [private]

Code to append in the checks.

Definition at line 42 of file settings.h.

Referenced by append().

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().

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().

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().

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.

Is --debug-fp given?

Definition at line 60 of file settings.h.

Referenced by CmdLineParser::ParseFromArgs(), CppCheck::processFile(), and CppCheck::reportErr().

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().

suppress exitcode

Definition at line 163 of file settings.h.

Referenced by CmdLineParser::ParseFromArgs(), and CppCheck::reportErr().

--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().

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 210 of file settings.h.

Referenced by platform(), and Tokenizer::sizeOfType().

Definition at line 207 of file settings.h.

Referenced by platform(), and Tokenizer::sizeOfType().

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().

Definition at line 211 of file settings.h.

Referenced by Tokenizer::fillTypeSizes(), and platform().

std::string Settings::userDefines
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

The documentation for this class was generated from the following files: