|
Cppcheck
|
The main purpose is to tokenize the source code. More...
#include <tokenize.h>
Public Member Functions | |
| Tokenizer () | |
| Tokenizer (const Settings *settings, ErrorLogger *errorLogger) | |
| ~Tokenizer () | |
| void | setTimerResults (TimerResults *tr) |
| const std::string & | getSourceFilePath () const |
| Returns the source file path. | |
| bool | isC () const |
| Is the code C. | |
| bool | isCPP () const |
| Is the code CPP. | |
| bool | tokenize (std::istream &code, const char FileName[], const std::string &configuration="") |
| Tokenize code. | |
| bool | tokenizeCondition (const std::string &code) |
| tokenize condition and run simple simplifications on it | |
| void | setVarId () |
| Set variable id. | |
| bool | simplifyTokenList () |
| Simplify tokenlist. | |
| void | simplifyMulAndParens () |
| Simplify '* & ( var% ) =' or any combination of '* &' and '()' parentheses around 'var' to 'var% ='. | |
| unsigned int | sizeOfType (const Token *type) const |
| Calculates sizeof value for given type. | |
| bool | isFunctionParameterPassedByValue (const Token *fpar) const |
| Try to determine if function parameter is passed by value by looking at the function declaration. | |
| void | simplifyAssignmentInFunctionCall () |
| Simplify assignment in function call "f(x=g());" => "x=g();f(x);". | |
| void | simplifyAssignmentBlock () |
| Simplify assignment where rhs is a block : "x=({123;});" => "{x=123;}". | |
| bool | simplifyCalculations () |
| Simplify constant calculations such as "1+2" => "3". | |
| void | arraySize () |
| Insert array size where it isn't given. | |
| bool | simplifyLabelsCaseDefault () |
| Simplify labels and 'case|default' syntaxes. | |
| void | removeMacrosInGlobalScope () |
| Remove macros in global scope. | |
| void | removeMacroInVarDecl () |
| Remove unknown macro in variable declarations: PROGMEM char x;. | |
| void | removeRedundantAssignment () |
| Remove redundant assignment. | |
| void | simplifyRealloc () |
| Simplifies some realloc usage like 'x = realloc (0, n);' => 'x = malloc(n);' 'x = realloc (y, 0);' => 'x = 0; free(y);'. | |
| bool | simplifySizeof () |
| Replace sizeof() to appropriate size. | |
| void | simplifyVarDecl (bool only_k_r_fpar) |
| Simplify variable declarations (split up) | |
| void | simplifyInitVar () |
| Simplify variable initialization '; int *p(0);' => '; int *p = 0;'. | |
| Token * | initVar (Token *tok) |
| void | simplifyPlatformTypes () |
| Convert platform dependent types to standard types. | |
| void | simplifyStdType () |
| Collapse compound standard types into a single token. | |
| bool | simplifyConstTernaryOp () |
| Simplify easy constant '?:' operation Example: 0 ? (2/0) : 0 => 0. | |
| void | simplifyCompoundAssignment () |
| Simplify compound assignments Example: ";a+=b;" => ";a=a+b;". | |
| void | simplifyIfAssign () |
| simplify if-assignments Example: "if(a=b);" => "a=b;if(a);" | |
| void | simplifyVariableMultipleAssign () |
| Simplify multiple assignments. | |
| void | simplifyIfNot () |
| simplify if-not Example: "if(0==x);" => "if(!x);" | |
| void | simplifyIfNotNull () |
| simplify if-not NULL Example: "if(0!=x);" => "if(x);" Special case: 'x = (0 != x);' is removed. | |
| void | simplifyIfSameInnerCondition () |
| simplify if (a) { if (a) | |
| bool | simplifyLogicalOperators () |
| Simplify the "not" and "and" keywords to "!" and "&&" accordingly. | |
| void | simplifyComma () |
| Simplify comma into a semicolon when possible: | |
| bool | simplifyAddBraces () |
| Add braces to an if-block, for-block, etc. | |
| Token * | simplifyAddBracesToCommand (Token *tok) |
| Add braces to an if-block, for-block, etc. | |
| Token * | simplifyAddBracesPair (Token *tok, bool commandWithCondition) |
| Add pair of braces to an single if-block, else-block, for-block, etc. | |
| void | simplifyTypedef () |
| typedef A mytype; mytype c; | |
| void | simplifyCasts () |
| Simplify casts. | |
| void | simplifyUndefinedSizeArray () |
| Change (multiple) arrays to (multiple) pointers. | |
| bool | simplifyKnownVariables () |
| A simplify function that replaces a variable with its value in cases when the value is known. | |
| bool | simplifyKnownVariablesSimplify (Token **tok2, Token *tok3, unsigned int varid, const std::string &structname, std::string &value, unsigned int valueVarId, bool valueIsPointer, const Token *const valueToken, int indentlevel) const |
| utility function for simplifyKnownVariables. | |
| void | simplifyGoto () |
| Replace a "goto" with the statements. | |
| void | simplifyEmptyNamespaces () |
| Simplify useless C++ empty namespaces, like: 'namespace var% { }'. | |
| void | simplifyFlowControl () |
| Simplify redundant code placed after control flow statements : 'return', 'throw', 'goto', 'break' and 'continue'. | |
| void | simplifyNestedStrcat () |
| Expand nested strcat() calls. | |
| void | elseif () |
| Simplify "if else". | |
| void | simplifyConditionOperator () |
| Simplify the operator "?:". | |
| bool | simplifyConditions () |
| Simplify conditions. | |
| bool | removeRedundantConditions () |
| Remove redundant code, e.g. | |
| void | removeRedundantFor () |
| Remove redundant for: "for (x=0;x<1;x++) { }" => "{ x = 1; }". | |
| void | removeRedundantSemicolons () |
| Reduces "; ;" to ";", except in "( ; ; )". | |
| bool | simplifyFunctionReturn () |
| Simplify function calls - constant return value. | |
| void | simplifyStructInit () |
| Struct initialization. | |
| void | simplifyStructDecl () |
| Struct simplification "struct S { } s;" => "struct S { }; S s;". | |
| bool | simplifyRedundantParentheses () |
| Remove redundant parentheses: | |
| void | simplifyCharAt () |
| void | simplifyReference () |
| Simplify references. | |
| bool | simplifyFunctionParameters () |
| Simplify functions like "void f(x) int x; {" into "void f(int x) {". | |
| void | simplifyTemplates () |
| Simplify templates. | |
| void | simplifyDoublePlusAndDoubleMinus () |
| void | simplifyRedundantConsecutiveBraces () |
| void | simplifyArrayAccessSyntax () |
| void | simplifyParameterVoid () |
| void | fillTypeSizes () |
| void | combineOperators () |
| void | combineStrings () |
| void | concatenateDoubleSharp () |
| void | simplifyFileAndLineMacro () |
| void | simplifyNull () |
| void | concatenateNegativeNumberAndAnyPositive () |
| void | simplifyExternC () |
| void | simplifyRoundCurlyParentheses () |
| void | simplifyDebugNew () |
| void | simplifySQL () |
| bool | hasEnumsWithTypedef () |
| void | simplifyDefaultAndDeleteInsideClass () |
| bool | hasComplicatedSyntaxErrorsInTemplates () |
| void | simplifyMathFunctions () |
| Simplify e.g. | |
| void | simplifyMathExpressions () |
| Simplify e.g. | |
| void | simplifyComparisonOrder () |
| Use "<" comparison instead of ">" Use "<=" comparison instead of ">=". | |
| void | simplifyConst () |
| Change "int const x;" into "const int x;". | |
| void | simplifyWhile0 () |
| simplify "while (0)" | |
| void | simplifyErrNoInWhile () |
| Simplify while(func() && errno==EINTR) | |
| void | simplifyFuncInWhile () |
| Simplify while(func(f)) | |
| void | simplifyEnum () |
| Replace enum with constant value. | |
| void | simplifyStd () |
| Remove "std::" before some function names. | |
| void | simplifyPointerToStandardType () |
| Simplify pointer to standard type (C only) | |
| void | simplifyFunctionPointers () |
| Simplify function pointers. | |
| void | removeExceptionSpecifications () |
| Remove exception specifications. | |
| void | cppcheckError (const Token *tok) const |
| Send error message to error logger about internal bug. | |
| bool | createLinks () |
| Setup links for tokens so that one can call Token::link(). | |
| void | createLinks2 () |
| Setup links between < and >. | |
| void | syntaxError (const Token *tok) const |
| Syntax error. | |
| void | syntaxError (const Token *tok, char c) const |
| Syntax error. | |
| void | unhandled_macro_class_x_y (const Token *tok) |
| Report that there is an unhandled "class x y {" code. | |
| bool | validate () const |
| assert that tokens are ok - used during debugging for example to catch problems in simplifyTokenList. | |
| void | simplifyDeclspec () |
| Remove __declspec() | |
| void | simplifyCallingConvention () |
| Remove calling convention. | |
| void | simplifyAttribute () |
| Remove __attribute__ ((?)) | |
| void | simplifyKeyword () |
| Remove keywords "volatile", "inline", "register", and "restrict". | |
| void | simplifyAsm () |
| Remove __asm. | |
| void | simplifyBitfields () |
| Simplify bitfields - the field width is removed as we don't use it. | |
| void | simplifyBuiltinExpect () |
| Remove __builtin_expect(...), likely(...), and unlikely(...) | |
| void | removeUnnecessaryQualification () |
| Remove unnecessary member qualification. | |
| void | unnecessaryQualificationError (const Token *tok, const std::string &qualification) const |
| unnecessary member qualification error | |
| void | simplifyNamespaceStd () |
| Add std:: in front of std classes, when using namespace std; was given. | |
| void | simplifyMicrosoftMFC () |
| Remove Microsoft MFC 'DECLARE_MESSAGE_MAP()'. | |
| void | simplifyMicrosoftMemoryFunctions () |
| Convert Microsoft memory functions CopyMemory(dst, src, len) -> memcpy(dst, src, len) FillMemory(dst, len, val) -> memset(dst, val, len) MoveMemory(dst, src, len) -> memmove(dst, src, len) ZeroMemory(dst, len) -> memset(dst, 0, len) | |
| void | simplifyMicrosoftStringFunctions () |
| Convert Microsoft string functions _tcscpy -> strcpy. | |
| void | simplifyBorland () |
| Remove Borland code. | |
| void | simplifyQtSignalsSlots () |
| Remove Qt signals and slots. | |
| void | simplifyOperatorName () |
| Collapse operator name tokens into single token operator = => operator=. | |
| bool | duplicateDefinition (Token **tokPtr, const Token *name) const |
| check for duplicate enum definition | |
| void | reportError (const Token *tok, const Severity::SeverityType severity, const std::string &id, const std::string &msg, bool inconclusive=false) const |
| report error message | |
| void | reportError (const std::list< const Token * > &callstack, Severity::SeverityType severity, const std::string &id, const std::string &msg, bool inconclusive=false) const |
| void | duplicateEnumError (const Token *tok1, const Token *tok2, const std::string &type) const |
| duplicate enum definition error | |
| bool | duplicateTypedef (Token **tokPtr, const Token *name, const Token *typeDef, bool undefinedStruct) const |
| void | duplicateTypedefError (const Token *tok1, const Token *tok2, const std::string &type) const |
| void | duplicateDeclarationError (const Token *tok1, const Token *tok2, const std::string &type) const |
| Report error - duplicate declarations. | |
| void | unsupportedTypedef (const Token *tok) const |
| bool | codeWithTemplates () const |
| Was there templates in the code? | |
| void | setSettings (const Settings *settings) |
| const SymbolDatabase * | getSymbolDatabase () const |
| void | createSymbolDatabase () |
| void | deleteSymbolDatabase () |
| Token * | deleteInvalidTypedef (Token *typeDef) |
| unsigned int | varIdCount () const |
| Get variable count. | |
| void | simplifyReturnStrncat () |
| Simplify e.g. | |
| void | printUnknownTypes () |
| Output list of unknown types. | |
| const Token * | tokens () const |
Static Public Member Functions | |
| static bool | IsScopeNoReturn (const Token *endScopeToken, bool *unknown=0) |
| Check if inner scope ends with a call to a noreturn function. | |
| static void | eraseDeadCode (Token *begin, const Token *end) |
| Deletes dead code between 'begin' and 'end'. | |
| static void | getErrorMessages (ErrorLogger *errorLogger, const Settings *settings) |
| get error messages that the tokenizer generate | |
| static bool | simplifyKnownVariablesGetData (unsigned int varid, Token **_tok2, Token **_tok3, std::string &value, unsigned int &valueVarId, bool &valueIsPointer, bool floatvar) |
| Utility function for simplifyKnownVariables. | |
| static std::string | simplifyString (const std::string &source) |
| Modify strings in the token list by replacing hex and oct values. | |
| static Token * | copyTokens (Token *dest, const Token *first, const Token *last, bool one_line=true) |
| Copy tokens. | |
Public Attributes | |
| TokenList | list |
| Token list: stores all tokens. | |
Private Member Functions | |
| Tokenizer (const Tokenizer &) | |
| Disable copy constructor, no implementation. | |
| Tokenizer & | operator= (const Tokenizer &) |
| Disable assignment operator, no implementation. | |
Private Attributes | |
| const Settings * | _settings |
| settings | |
| ErrorLogger *const | _errorLogger |
| errorlogger | |
| SymbolDatabase * | _symbolDatabase |
| Symbol database that all checks etc can use. | |
| std::string | _configuration |
| E.g. | |
| std::map< std::string, unsigned int > | _typeSize |
| sizeof information for known types | |
| unsigned int | _varId |
| variable count | |
| bool | _codeWithTemplates |
| was there any templates? templates that are "unused" are removed from the token list | |
| TimerResults * | m_timerResults |
| TimerResults. | |
The main purpose is to tokenize the source code.
It also has functions that simplify the token list
Definition at line 41 of file tokenize.h.
Definition at line 38 of file tokenize.cpp.
| Tokenizer::Tokenizer | ( | const Settings * | settings, |
| ErrorLogger * | errorLogger | ||
| ) |
Definition at line 49 of file tokenize.cpp.
References _settings.
Definition at line 62 of file tokenize.cpp.
References _symbolDatabase.
| Tokenizer::Tokenizer | ( | const Tokenizer & | ) | [private] |
Disable copy constructor, no implementation.
| void Tokenizer::arraySize | ( | ) |
Insert array size where it isn't given.
Specify array size if it hasn't been given.
Definition at line 2372 of file tokenize.cpp.
References Token::deleteNext(), TokenList::front(), Token::link(), Token::linkAt(), list, MathLib::longToString(), Token::Match(), Token::next(), and Token::tokAt().
Referenced by tokenize().
| bool Tokenizer::codeWithTemplates | ( | ) | const [inline] |
Was there templates in the code?
Definition at line 686 of file tokenize.h.
Referenced by CheckOther::checkSignOfUnsignedVariable().
| void Tokenizer::combineOperators | ( | ) |
Definition at line 2090 of file tokenize.cpp.
References TokenList::front(), list, and Token::next().
Referenced by tokenize(), and tokenizeCondition().
| void Tokenizer::combineStrings | ( | ) |
Definition at line 2136 of file tokenize.cpp.
References Token::eString, TokenList::front(), list, Token::next(), and simplifyString().
Referenced by tokenize(), and tokenizeCondition().
| void Tokenizer::concatenateDoubleSharp | ( | ) |
Definition at line 2168 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), and Token::next().
Referenced by tokenize(), and tokenizeCondition().
Definition at line 2210 of file tokenize.cpp.
References Token::eIncDecOp, TokenList::front(), list, Token::Match(), and Token::next().
Referenced by Preprocessor::simplifyCondition(), tokenize(), and tokenizeCondition().
| Token * Tokenizer::copyTokens | ( | Token * | dest, |
| const Token * | first, | ||
| const Token * | last, | ||
| bool | one_line = true |
||
| ) | [static] |
Copy tokens.
| dest | destination token where copied tokens will be inserted after |
| first | first token to copy |
| last | last token to copy |
| one_line | true=>copy all tokens to the same line as dest. false=>copy all tokens to dest while keeping the 'line breaks' |
Definition at line 95 of file tokenize.cpp.
References Token::fileIndex(), Token::insertToken(), Token::isLong(), Token::isPointerCompare(), Token::isSigned(), Token::isUnsigned(), Token::isUnused(), Token::linenr(), Token::link(), Token::next(), Token::setExpandedMacro(), Token::str(), Token::type(), and Token::varId().
Referenced by EnumValue::simplify(), simplifyEnum(), simplifyReturnStrncat(), and simplifyTypedef().
| void Tokenizer::cppcheckError | ( | const Token * | tok | ) | const |
Send error message to error logger about internal bug.
| tok | the token that this bug concerns. |
Definition at line 7870 of file tokenize.cpp.
References Severity::error, and reportError().
Referenced by getErrorMessages(), tokenize(), tokenizeCondition(), and validate().
| bool Tokenizer::createLinks | ( | ) |
Setup links for tokens so that one can call Token::link().
Definition at line 2980 of file tokenize.cpp.
References TokenList::front(), linkBrackets(), list, Token::next(), and syntaxError().
Referenced by tokenize(), and tokenizeCondition().
| void Tokenizer::createLinks2 | ( | ) |
Setup links between < and >.
Definition at line 3025 of file tokenize.cpp.
References Token::createMutualLinks(), TokenList::front(), isC(), list, Token::Match(), Token::next(), and Token::str().
Referenced by tokenize().
| void Tokenizer::createSymbolDatabase | ( | ) |
Definition at line 9119 of file tokenize.cpp.
References _errorLogger, _settings, _symbolDatabase, TokenList::back(), Scope::classEnd, Scope::classStart, Scope::eGlobal, SymbolDatabase::findFunction(), TokenList::front(), SymbolDatabase::functionScopes, SymbolDatabase::getVariableFromVarId(), list, Token::Match(), Token::next(), Token::scope(), and SymbolDatabase::scopeList.
Referenced by simplifyTokenList(), and tokenize().
| Token * Tokenizer::deleteInvalidTypedef | ( | Token * | typeDef | ) |
Definition at line 337 of file tokenize.cpp.
References Token::deleteNext(), Token::deleteThis(), Token::eraseTokens(), TokenList::front(), Token::linkAt(), list, Token::next(), Token::previous(), and Token::str().
Referenced by simplifyTypedef().
| void Tokenizer::deleteSymbolDatabase | ( | ) |
Definition at line 9178 of file tokenize.cpp.
References _symbolDatabase, TokenList::back(), TokenList::front(), list, and Token::next().
Referenced by simplifyTokenList().
| void Tokenizer::duplicateDeclarationError | ( | const Token * | tok1, |
| const Token * | tok2, | ||
| const std::string & | type | ||
| ) | const |
Report error - duplicate declarations.
Definition at line 151 of file tokenize.cpp.
References _settings, Settings::isEnabled(), reportError(), Token::str(), and Severity::style.
Referenced by duplicateTypedef(), and getErrorMessages().
| bool Tokenizer::duplicateDefinition | ( | Token ** | tokPtr, |
| const Token * | name | ||
| ) | const |
check for duplicate enum definition
Definition at line 6992 of file tokenize.cpp.
References duplicateEnumError(), Token::isName(), Token::link(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), and Token::tokAt().
Referenced by simplifyEnum().
| void Tokenizer::duplicateEnumError | ( | const Token * | tok1, |
| const Token * | tok2, | ||
| const std::string & | type | ||
| ) | const |
duplicate enum definition error
Definition at line 6975 of file tokenize.cpp.
References _settings, Settings::isEnabled(), reportError(), Token::str(), and Severity::style.
Referenced by duplicateDefinition(), and getErrorMessages().
| bool Tokenizer::duplicateTypedef | ( | Token ** | tokPtr, |
| const Token * | name, | ||
| const Token * | typeDef, | ||
| bool | undefinedStruct | ||
| ) | const |
Definition at line 166 of file tokenize.cpp.
References duplicateDeclarationError(), duplicateTypedefError(), Token::link(), Token::linkAt(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), Token::strAt(), and Token::tokAt().
Referenced by simplifyTypedef().
| void Tokenizer::duplicateTypedefError | ( | const Token * | tok1, |
| const Token * | tok2, | ||
| const std::string & | type | ||
| ) | const |
Definition at line 137 of file tokenize.cpp.
References _settings, Settings::inconclusive, Settings::isEnabled(), reportError(), Token::str(), and Severity::style.
Referenced by duplicateTypedef(), and getErrorMessages().
| void Tokenizer::elseif | ( | ) |
Simplify "if else".
Definition at line 6537 of file tokenize.cpp.
References Token::createMutualLinks(), TokenList::front(), list, Token::Match(), Token::next(), and Token::simpleMatch().
Referenced by simplifyTokenList().
| void Tokenizer::eraseDeadCode | ( | Token * | begin, |
| const Token * | end | ||
| ) | [static] |
Deletes dead code between 'begin' and 'end'.
In general not everything can be erased, such as:
| begin | Tokens after this have a possibility to be erased. |
| end | Tokens before this have a possibility to be erased. |
Definition at line 7661 of file tokenize.cpp.
References Token::deleteNext(), Token::eraseTokens(), Token::findsimplematch(), Token::link(), Token::linkAt(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), and Token::tokAt().
Referenced by removeRedundantConditions(), simplifyFlowControl(), and simplifyWhile0().
| void Tokenizer::fillTypeSizes | ( | ) |
Definition at line 2075 of file tokenize.cpp.
References _settings, _typeSize, Settings::sizeof_bool, Settings::sizeof_double, Settings::sizeof_float, Settings::sizeof_int, Settings::sizeof_long, Settings::sizeof_pointer, Settings::sizeof_short, Settings::sizeof_size_t, and Settings::sizeof_wchar_t.
Referenced by tokenize(), and tokenizeCondition().
| void Tokenizer::getErrorMessages | ( | ErrorLogger * | errorLogger, |
| const Settings * | settings | ||
| ) | [static] |
get error messages that the tokenizer generate
Definition at line 8246 of file tokenize.cpp.
References cppcheckError(), duplicateDeclarationError(), duplicateEnumError(), duplicateTypedefError(), syntaxError(), and unnecessaryQualificationError().
| const std::string & Tokenizer::getSourceFilePath | ( | ) | const |
Returns the source file path.
e.g. "file.cpp"
Definition at line 9477 of file tokenize.cpp.
References TokenList::getFiles(), and list.
Referenced by CppCheck::checkFile(), CheckBufferOverrun::checkGlobalAndLocalVariable(), isC(), isCPP(), and CheckUnusedFunctions::parseTokens().
| const SymbolDatabase* Tokenizer::getSymbolDatabase | ( | ) | const [inline] |
Definition at line 695 of file tokenize.h.
Referenced by CheckBufferOverrun::arrayIndexInForLoop(), CheckBufferOverrun::arrayIndexThenCheck(), CheckAutoVariables::autoVariables(), CheckUninitVar::check(), CheckLeakAutoVar::check(), CheckMemoryLeakInClass::check(), CheckMemoryLeakStructMember::check(), CheckMemoryLeakNoVar::check(), CheckOther::checkAssignBoolToPointer(), CheckOther::checkBitwiseOnBoolean(), CheckBoost::checkBoostForeachModification(), CheckBufferOverrun::checkBufferAllocatedWithStrlen(), CheckOther::checkCastIntToCharAndBack(), CheckExceptionSafety::checkCatchExceptionByValue(), CheckOther::checkCharVariable(), CheckOther::checkComparisonOfBoolExpressionWithInt(), CheckOther::checkComparisonOfBoolWithBool(), CheckOther::checkComparisonOfBoolWithInt(), CheckOther::checkComparisonOfFuncReturningBool(), CheckOther::checkConstantFunctionParameter(), CheckIO::checkCoutCerrMisusage(), CheckOther::checkDuplicateBranch(), CheckOther::checkDuplicateExpression(), CheckOther::checkDuplicateIf(), CheckIO::checkFileUsage(), CheckUnusedVar::checkFunctionVariableUsage(), CheckBufferOverrun::checkGlobalAndLocalVariable(), CheckOther::checkIncompleteArrayFill(), CheckOther::checkIncorrectLogicOperator(), CheckOther::checkIncorrectStringCompare(), CheckOther::checkIncrementBoolean(), CheckBufferOverrun::checkInsecureCmdLineArgs(), CheckOther::checkMathFunctions(), CheckMemoryLeakInFunction::CheckMemoryLeakInFunction(), CheckOther::checkMemsetZeroBytes(), CheckOther::checkMisusedScopedObject(), CheckOther::checkModuloAlwaysTrueFalse(), CheckOther::checkNegativeBitwiseShift(), CheckOther::checkPipeParameterSize(), CheckMemoryLeakInClass::checkPublicFunctions(), CheckOther::checkRedundantAssignment(), CheckOther::checkRedundantAssignmentInSwitch(), CheckOther::checkRedundantCopy(), CheckExceptionSafety::checkRethrowCopy(), CheckUninitVar::checkScope(), CheckBufferOverrun::checkScopeForBody(), CheckOther::checkSignOfUnsignedVariable(), CheckOther::checkSizeofForArrayParameter(), CheckOther::checkSizeofForNumericParameter(), CheckOther::checkSizeofForPointerSize(), CheckOther::checkSleepTimeInterval(), CheckBufferOverrun::checkStructVariable(), CheckOther::checkSuspiciousCaseInSwitch(), CheckOther::checkSuspiciousSemicolon(), CheckOther::checkSuspiciousStringCompare(), CheckOther::checkSwitchCaseFallThrough(), CheckOther::checkUnsignedDivision(), CheckOther::checkVarFuncNullUB(), CheckOther::checkVariableScope(), CheckIO::checkWrongPrintfScanfArguments(), CheckOther::clarifyCalculation(), CheckOther::clarifyCondition(), CheckOther::clarifyStatement(), CheckExceptionSafety::deallocThrow(), CheckExceptionSafety::destructors(), CheckStl::erase(), CheckUninitVar::executionPaths(), CheckBufferOverrun::executionPaths(), CheckNullPointer::executionPaths(), CheckMemoryLeak::functionReturnType(), CheckStl::if_find(), CheckOther::invalidPointerCast(), CheckIO::invalidScanf(), CheckMemoryLeak::isclass(), CheckStl::iterators(), CheckStl::mismatchingContainers(), CheckStl::missingComparison(), CheckAssignIf::multiCondition(), CheckNullPointer::nullConstantDereference(), CheckNullPointer::nullPointerByCheckAndDeRef(), CheckNullPointer::nullPointerByDeRefAndChec(), CheckNullPointer::nullPointerDefaultArgument(), CheckNullPointer::nullPointerLinkedList(), CheckNullPointer::nullPointerStructByDeRefAndChec(), CheckObsoleteFunctions::obsoleteFunctions(), CheckOther::oppositeInnerCondition(), Check64BitPortability::pointerassignment(), CheckPostfixOperator::postfixOperator(), CheckStl::pushback(), CheckLeakAutoVar::ret(), CheckAutoVariables::returnPointerToLocalArray(), CheckAutoVariables::returnReference(), CheckAutoVariables::returnTemporary(), CheckStl::size(), CheckStl::stlBoundaries(), CheckStl::stlOutOfBounds(), CheckStl::string_c_str(), CheckOther::strPlusChar(), CheckStl::uselessCalls(), and CheckBufferOverrun::writeOutsideBufferSize().
Definition at line 2048 of file tokenize.cpp.
References TokenList::front(), list, and syntaxError().
Referenced by tokenize().
| bool Tokenizer::hasEnumsWithTypedef | ( | ) |
Definition at line 2059 of file tokenize.cpp.
References Token::findsimplematch(), TokenList::front(), list, Token::Match(), Token::next(), and syntaxError().
Referenced by tokenize().
| Token * Tokenizer::initVar | ( | Token * | tok | ) |
Definition at line 5813 of file tokenize.cpp.
References Token::deleteThis(), Token::insertToken(), Token::isNumber(), Token::isStandardType(), Token::link(), Token::Match(), Token::next(), Token::str(), Token::strAt(), Token::tokAt(), and Token::varId().
Referenced by simplifyInitVar().
| bool Tokenizer::isC | ( | ) | const |
Is the code C.
Used for bailouts
Definition at line 9486 of file tokenize.cpp.
References _settings, Settings::C, Settings::enforcedLang, getSourceFilePath(), and Settings::None.
Referenced by CheckOther::checkConstantFunctionParameter(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckOther::checkMisusedScopedObject(), CheckOther::checkRedundantCopy(), CheckUninitVar::checkScope(), CheckMemoryLeakStructMember::checkStructVariable(), CheckOther::checkSuspiciousStringCompare(), CheckOther::clarifyCondition(), createLinks2(), CheckUninitVar::executionPaths(), removeExceptionSpecifications(), removeUnnecessaryQualification(), CheckClass::runChecks(), CheckPostfixOperator::runSimplifiedChecks(), CheckExceptionSafety::runSimplifiedChecks(), CheckClass::runSimplifiedChecks(), setVarId(), simplifyEmptyNamespaces(), simplifyFlowControl(), simplifyOperatorName(), simplifyPointerToStandardType(), simplifyReference(), simplifyStd(), and simplifyTemplates().
| bool Tokenizer::isCPP | ( | ) | const |
Is the code CPP.
Used for bailouts
Definition at line 9491 of file tokenize.cpp.
References _settings, Settings::CPP, Settings::enforcedLang, getSourceFilePath(), and Settings::None.
Referenced by CheckOther::checkComparisonOfBoolWithBool(), CheckOther::checkComparisonOfFuncReturningBool(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckUninitVar::checkIfForWhileHead(), CheckUninitVar::checkLoopBody(), CheckUninitVar::checkScope(), CheckUninitVar::checkScopeForVariable(), SymbolDatabase::isCPP(), CheckUninitVar::isMemberVariableUsage(), isTypeWithoutSideEffects(), Scope::isVariableDeclaration(), CheckObsoleteFunctions::obsoleteFunctions(), CheckStl::runSimplifiedChecks(), CheckBoost::runSimplifiedChecks(), CheckMemoryLeakInClass::runSimplifiedChecks(), setVarId(), simplifyKnownVariablesSimplify(), simplifyNamespaceStd(), simplifyNull(), simplifyRedundantParentheses(), simplifyVarDecl(), SymbolDatabase::SymbolDatabase(), tokenize(), and CheckOther::warningOldStylePointerCast().
| bool Tokenizer::isFunctionParameterPassedByValue | ( | const Token * | fpar | ) | const |
Try to determine if function parameter is passed by value by looking at the function declaration.
| fpar | token for function parameter in the function call |
Definition at line 7588 of file tokenize.cpp.
References Token::isStandardType(), Token::Match(), Token::next(), Token::previous(), Token::str(), Token::tokAt(), and tokens().
Referenced by simplifyKnownVariablesSimplify().
| bool Tokenizer::IsScopeNoReturn | ( | const Token * | endScopeToken, |
| bool * | unknown = 0 |
||
| ) | [static] |
Check if inner scope ends with a call to a noreturn function.
| endScopeToken | The '}' token |
| unknown | set to true if it's unknown if the scope is noreturn |
Definition at line 7552 of file tokenize.cpp.
References Token::isName(), Token::linkAt(), Token::Match(), Token::previous(), Token::simpleMatch(), Token::str(), and Token::tokAt().
Referenced by CheckOther::checkDoubleFree(), CheckOther::checkRedundantAssignment(), CheckLeakAutoVar::checkScope(), CheckUninitVar::checkScopeForVariable(), and CheckNullPointer::nullPointerByCheckAndDeRef().
Disable assignment operator, no implementation.
| void Tokenizer::printUnknownTypes | ( | ) |
Output list of unknown types.
Definition at line 9370 of file tokenize.cpp.
References _errorLogger, _symbolDatabase, _varId, SymbolDatabase::getVariableFromVarId(), Token::isStandardType(), Token::Match(), Token::next(), ErrorLogger::reportOut(), Token::str(), Variable::type(), Variable::typeEndToken(), and Variable::typeStartToken().
Referenced by simplifyTokenList().
Remove exception specifications.
Definition at line 8029 of file tokenize.cpp.
References Token::eraseTokens(), TokenList::front(), isC(), list, Token::Match(), and Token::next().
Referenced by tokenize().
| void Tokenizer::removeMacroInVarDecl | ( | ) |
Remove unknown macro in variable declarations: PROGMEM char x;.
Definition at line 3578 of file tokenize.cpp.
References Token::eraseTokens(), TokenList::front(), Token::isStandardType(), Token::isUpperCaseName(), list, Token::Match(), Token::next(), and Token::str().
Referenced by tokenize().
| void Tokenizer::removeMacrosInGlobalScope | ( | ) |
Remove macros in global scope.
Definition at line 3523 of file tokenize.cpp.
References Token::eraseTokens(), TokenList::front(), list, Token::Match(), Token::next(), Token::str(), Token::strAt(), and Token::tokAt().
Referenced by tokenize().
| void Tokenizer::removeRedundantAssignment | ( | ) |
Remove redundant assignment.
Definition at line 3607 of file tokenize.cpp.
References TokenList::front(), Token::link(), list, Token::Match(), and Token::next().
Referenced by simplifyTokenList().
| bool Tokenizer::removeRedundantConditions | ( | ) |
Remove redundant code, e.g.
if( false ) { int a; } should be removed, because it is never executed.
Definition at line 3811 of file tokenize.cpp.
References Token::deleteNext(), Token::deleteThis(), eraseDeadCode(), TokenList::front(), Token::link(), Token::linkAt(), list, Token::Match(), Token::next(), Token::previous(), and Token::simpleMatch().
Referenced by simplifyTokenList().
| void Tokenizer::removeRedundantFor | ( | ) |
Remove redundant for: "for (x=0;x<1;x++) { }" => "{ x = 1; }".
Definition at line 3880 of file tokenize.cpp.
References TokenList::front(), Token::insertToken(), Token::link(), Token::linkAt(), list, MathLib::longToString(), Token::Match(), Token::next(), Token::str(), Token::tokAt(), MathLib::toLongNumber(), and Token::varId().
Referenced by simplifyTokenList().
| void Tokenizer::removeRedundantSemicolons | ( | ) |
Reduces "; ;" to ";", except in "( ; ; )".
Definition at line 3950 of file tokenize.cpp.
References TokenList::front(), list, Token::next(), and Token::simpleMatch().
Referenced by simplifyTokenList(), and tokenize().
Remove unnecessary member qualification.
Definition at line 9248 of file tokenize.cpp.
References _settings, Space::classEnd, Space::className, TokenList::front(), isC(), Settings::isEnabled(), Space::isNamespace, Token::link(), list, Token::Match(), Token::next(), Token::str(), Token::tokAt(), and unnecessaryQualificationError().
Referenced by tokenize().
| void Tokenizer::reportError | ( | const Token * | tok, |
| const Severity::SeverityType | severity, | ||
| const std::string & | id, | ||
| const std::string & | msg, | ||
| bool | inconclusive = false |
||
| ) | const |
report error message
Definition at line 9496 of file tokenize.cpp.
Referenced by cppcheckError(), duplicateDeclarationError(), duplicateEnumError(), duplicateTypedefError(), reportError(), simplifyKnownVariablesSimplify(), syntaxError(), unhandled_macro_class_x_y(), unnecessaryQualificationError(), and unsupportedTypedef().
| void Tokenizer::reportError | ( | const std::list< const Token * > & | callstack, |
| Severity::SeverityType | severity, | ||
| const std::string & | id, | ||
| const std::string & | msg, | ||
| bool | inconclusive = false |
||
| ) | const |
Definition at line 9502 of file tokenize.cpp.
References _errorLogger, list, ErrorLogger::reportErr(), and reportError().
| void Tokenizer::setSettings | ( | const Settings * | settings | ) | [inline] |
Definition at line 690 of file tokenize.h.
Referenced by PreprocessorMacro::PreprocessorMacro().
| void Tokenizer::setTimerResults | ( | TimerResults * | tr | ) | [inline] |
Definition at line 47 of file tokenize.h.
Referenced by CppCheck::checkFile().
| void Tokenizer::setVarId | ( | ) |
Set variable id.
Definition at line 2711 of file tokenize.cpp.
References _varId, Token::findsimplematch(), TokenList::front(), isC(), isCPP(), isInitList(), Token::isStandardType(), Token::link(), Token::linkAt(), list, Token::Match(), Token::next(), Token::previous(), setVarIdClassDeclaration(), setVarIdClassFunction(), setVarIdParseDeclaration(), setVarIdStructMembers(), Token::simpleMatch(), Token::str(), Token::tokAt(), and Token::varId().
Referenced by tokenize().
| bool Tokenizer::simplifyAddBraces | ( | ) |
Add braces to an if-block, for-block, etc.
Definition at line 3969 of file tokenize.cpp.
References TokenList::front(), list, Token::next(), and simplifyAddBracesToCommand().
Referenced by tokenize().
| Token * Tokenizer::simplifyAddBracesPair | ( | Token * | tok, |
| bool | commandWithCondition | ||
| ) |
Add pair of braces to an single if-block, else-block, for-block, etc.
for command starting at token
Definition at line 4029 of file tokenize.cpp.
References Token::createMutualLinks(), Token::eBracket, Token::eExtendedOp, Token::insertToken(), Token::link(), Token::Match(), Token::next(), Token::previous(), simplifyAddBracesToCommand(), Token::str(), syntaxError(), and Token::type().
Referenced by simplifyAddBracesToCommand().
| Token * Tokenizer::simplifyAddBracesToCommand | ( | Token * | tok | ) |
Add braces to an if-block, for-block, etc.
for command starting at token including else-block
Definition at line 3979 of file tokenize.cpp.
References Token::link(), Token::next(), Token::previous(), simplifyAddBracesPair(), Token::str(), and syntaxError().
Referenced by simplifyAddBraces(), and simplifyAddBracesPair().
| void Tokenizer::simplifyArrayAccessSyntax | ( | ) |
Definition at line 2289 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), and Token::next().
Referenced by tokenize().
| void Tokenizer::simplifyAsm | ( | ) |
Remove __asm.
Definition at line 8648 of file tokenize.cpp.
References Token::createMutualLinks(), Token::eraseTokens(), TokenList::front(), Token::isName(), Token::isNumber(), Token::linenr(), Token::link(), list, Token::Match(), Token::next(), Token::str(), and Token::stringifyList().
Referenced by tokenize().
| void Tokenizer::simplifyAssignmentBlock | ( | ) |
Simplify assignment where rhs is a block : "x=({123;});" => "{x=123;}".
Definition at line 8617 of file tokenize.cpp.
References Token::deleteNext(), TokenList::front(), Token::insertToken(), list, Token::Match(), Token::next(), Token::simpleMatch(), Token::str(), Token::tokAt(), and Token::varId().
Referenced by tokenize().
Simplify assignment in function call "f(x=g());" => "x=g();f(x);".
Definition at line 8578 of file tokenize.cpp.
References Token::createMutualLinks(), Token::eraseTokens(), TokenList::front(), Token::link(), list, Token::Match(), Token::next(), Token::simpleMatch(), and Token::tokAt().
Referenced by tokenize().
| void Tokenizer::simplifyAttribute | ( | ) |
Remove __attribute__ ((?))
Definition at line 8521 of file tokenize.cpp.
References Token::eraseTokens(), TokenList::front(), list, Token::Match(), Token::next(), and Token::simpleMatch().
Referenced by tokenize().
| void Tokenizer::simplifyBitfields | ( | ) |
Simplify bitfields - the field width is removed as we don't use it.
Definition at line 8707 of file tokenize.cpp.
References Token::deleteNext(), Token::eraseTokens(), TokenList::front(), Token::insertToken(), Token::isLong(), Token::isSigned(), Token::isUnsigned(), Token::link(), list, Token::Match(), Token::next(), Token::simpleMatch(), Token::str(), and Token::tokAt().
Referenced by tokenize().
| void Tokenizer::simplifyBorland | ( | ) |
Remove Borland code.
Definition at line 9021 of file tokenize.cpp.
References Token::eraseTokens(), TokenList::front(), Token::link(), list, Token::Match(), and Token::next().
Referenced by tokenize().
| void Tokenizer::simplifyBuiltinExpect | ( | ) |
Remove __builtin_expect(...), likely(...), and unlikely(...)
Definition at line 8759 of file tokenize.cpp.
References TokenList::front(), Token::link(), Token::linkAt(), list, Token::Match(), Token::next(), Token::simpleMatch(), and Token::tokAt().
Referenced by tokenize().
| bool Tokenizer::simplifyCalculations | ( | ) |
Simplify constant calculations such as "1+2" => "3".
Definition at line 6737 of file tokenize.cpp.
References TokenList::front(), and list.
Referenced by Preprocessor::simplifyCondition(), and simplifyTokenList().
| void Tokenizer::simplifyCallingConvention | ( | ) |
Remove calling convention.
Definition at line 8502 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), and Token::next().
Referenced by tokenize().
| void Tokenizer::simplifyCasts | ( | ) |
Simplify casts.
Definition at line 4559 of file tokenize.cpp.
References _typeSize, Token::deleteThis(), Token::eraseTokens(), Token::findClosingBracket(), TokenList::front(), Token::link(), list, Token::Match(), Token::next(), Token::simpleMatch(), Token::tokAt(), and MathLib::toLongNumber().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyCharAt | ( | ) |
Definition at line 6688 of file tokenize.cpp.
References TokenList::front(), Token::getCharAt(), Token::getStrLength(), list, Token::Match(), Token::next(), and MathLib::toLongNumber().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyComma | ( | ) |
Simplify comma into a semicolon when possible:
Definition at line 7907 of file tokenize.cpp.
References Token::deleteNext(), Token::findClosingBracket(), TokenList::front(), Token::link(), list, Token::Match(), Token::next(), Token::previous(), and Token::str().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyComparisonOrder | ( | ) |
Use "<" comparison instead of ">" Use "<=" comparison instead of ">=".
Definition at line 8199 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), Token::next(), Token::str(), Token::tokAt(), and Token::varId().
Referenced by simplifyTokenList(), and tokenize().
Simplify compound assignments Example: ";a+=b;" => ";a=a+b;".
Definition at line 4101 of file tokenize.cpp.
References Token::createMutualLinks(), Token::deleteNext(), Token::eIncDecOp, TokenList::front(), Token::link(), list, Token::Match(), Token::next(), Token::previous(), and Token::simpleMatch().
Referenced by tokenize().
| void Tokenizer::simplifyConditionOperator | ( | ) |
Simplify the operator "?:".
Definition at line 4211 of file tokenize.cpp.
References Token::createMutualLinks(), Token::deleteNext(), TokenList::front(), Token::insertToken(), Token::isName(), Token::isNumber(), list, Token::Match(), Token::next(), Token::previous(), Token::str(), and Token::tokAt().
Referenced by simplifyTokenList(), and tokenize().
| bool Tokenizer::simplifyConditions | ( | ) |
Simplify conditions.
Definition at line 4310 of file tokenize.cpp.
References Token::eraseTokens(), TokenList::front(), MathLib::isInt(), Token::link(), list, Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), MathLib::toDoubleNumber(), and MathLib::toLongNumber().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyConst | ( | ) |
Change "int const x;" into "const int x;".
Definition at line 8226 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), and Token::next().
Referenced by tokenize().
| bool Tokenizer::simplifyConstTernaryOp | ( | ) |
Simplify easy constant '?:' operation Example: 0 ? (2/0) : 0 => 0.
Definition at line 4458 of file tokenize.cpp.
References Token::eraseTokens(), TokenList::front(), list, Token::Match(), Token::next(), Token::previous(), skipTernaryOp(), Token::str(), TemplateSimplifier::templateParameters(), and Token::tokAt().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyDebugNew | ( | ) |
Definition at line 2280 of file tokenize.cpp.
References TokenList::front(), list, and Token::next().
Referenced by tokenize().
| void Tokenizer::simplifyDeclspec | ( | ) |
Remove __declspec()
Definition at line 8511 of file tokenize.cpp.
References Token::eraseTokens(), TokenList::front(), list, Token::next(), and Token::simpleMatch().
Referenced by tokenize().
Definition at line 2324 of file tokenize.cpp.
References TokenList::front(), list, and Token::next().
Referenced by tokenize(), and tokenizeCondition().
| void Tokenizer::simplifyEmptyNamespaces | ( | ) |
Simplify useless C++ empty namespaces, like: 'namespace var% { }'.
Definition at line 3704 of file tokenize.cpp.
References TokenList::front(), isC(), list, Token::Match(), and Token::next().
Referenced by simplifyTokenList(), and tokenize().
| void Tokenizer::simplifyEnum | ( | ) |
Replace enum with constant value.
Definition at line 7131 of file tokenize.cpp.
References copyTokens(), Token::deleteNext(), Token::deleteThis(), duplicateDefinition(), EnumValue::end, Token::eraseTokens(), Token::fileIndex(), TokenList::front(), Token::insertToken(), Token::isName(), Token::linenr(), Token::link(), list, MathLib::longToString(), Token::Match(), EnumValue::name, Token::next(), Token::previous(), EnumValue::simplify(), EnumValue::start, Token::str(), Token::strAt(), syntaxError(), Token::tokAt(), MathLib::toLongNumber(), and EnumValue::value.
Referenced by tokenize().
| void Tokenizer::simplifyErrNoInWhile | ( | ) |
Simplify while(func() && errno==EINTR)
Definition at line 8305 of file tokenize.cpp.
References Token::eraseTokens(), TokenList::front(), Token::link(), list, Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), and Token::tokAt().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyExternC | ( | ) |
Definition at line 2224 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), and Token::next().
Referenced by tokenize().
| void Tokenizer::simplifyFileAndLineMacro | ( | ) |
Definition at line 2178 of file tokenize.cpp.
References TokenList::file(), TokenList::front(), list, MathLib::longToString(), and Token::next().
Referenced by tokenize().
| void Tokenizer::simplifyFlowControl | ( | ) |
Simplify redundant code placed after control flow statements : 'return', 'throw', 'goto', 'break' and 'continue'.
Definition at line 3737 of file tokenize.cpp.
References eraseDeadCode(), TokenList::front(), isC(), Token::link(), Token::linkAt(), list, Token::Match(), Token::next(), and Token::simpleMatch().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyFuncInWhile | ( | ) |
Simplify while(func(f))
Definition at line 8336 of file tokenize.cpp.
References _varId, Token::createMutualLinks(), TokenList::front(), Token::insertToken(), Token::link(), list, MathLib::longToString(), Token::Match(), Token::move(), Token::next(), Token::previous(), Token::str(), Token::tokAt(), and Token::varId().
Referenced by simplifyTokenList().
Simplify functions like "void f(x) int x; {" into "void f(int x) {".
Definition at line 4648 of file tokenize.cpp.
References Token::deleteNext(), TokenList::front(), Token::isName(), Token::link(), list, Token::Match(), Token::next(), Token::previous(), Token::replace(), Token::simpleMatch(), Token::str(), syntaxError(), and Token::tokAt().
Referenced by tokenize().
| void Tokenizer::simplifyFunctionPointers | ( | ) |
Simplify function pointers.
Definition at line 4837 of file tokenize.cpp.
References Token::deleteNext(), Token::eraseTokens(), TokenList::front(), Token::link(), Token::linkAt(), list, Token::Match(), Token::next(), Token::simpleMatch(), and Token::str().
Referenced by tokenize().
| bool Tokenizer::simplifyFunctionReturn | ( | ) |
Simplify function calls - constant return value.
Definition at line 4903 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), Token::next(), Token::str(), Token::tokAt(), and tokens().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyGoto | ( | ) |
Replace a "goto" with the statements.
Definition at line 6745 of file tokenize.cpp.
References Token::createMutualLinks(), Token::deleteNext(), TokenList::front(), Token::insertToken(), Token::linenr(), Token::link(), list, Token::Match(), Token::next(), Token::previous(), Token::str(), syntaxError(), Token::tokAt(), and Token::varId().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyIfAssign | ( | ) |
simplify if-assignments Example: "if(a=b);" => "a=b;if(a);"
Definition at line 5455 of file tokenize.cpp.
References Token::createMutualLinks(), Token::fileIndex(), TokenList::front(), Token::insertToken(), Token::linenr(), Token::link(), list, Token::Match(), Token::next(), Token::previous(), Token::str(), and Token::varId().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyIfNot | ( | ) |
simplify if-not Example: "if(0==x);" => "if(!x);"
Definition at line 5584 of file tokenize.cpp.
References Token::createMutualLinks(), TokenList::front(), Token::link(), list, Token::Match(), and Token::next().
Referenced by simplifyTokenList(), and tokenize().
| void Tokenizer::simplifyIfNotNull | ( | ) |
simplify if-not NULL Example: "if(0!=x);" => "if(x);" Special case: 'x = (0 != x);' is removed.
Definition at line 5645 of file tokenize.cpp.
References Token::deleteNext(), Token::eraseTokens(), TokenList::front(), Token::isPointerCompare(), list, Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), and Token::tokAt().
Referenced by simplifyTokenList(), and tokenize().
simplify if (a) { if (a)
Definition at line 5701 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), Token::next(), Token::simpleMatch(), and Token::tokAt().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyInitVar | ( | ) |
Simplify variable initialization '; int *p(0);' => '; int *p = 0;'.
Definition at line 5779 of file tokenize.cpp.
References TokenList::front(), initVar(), Token::insertToken(), list, Token::Match(), Token::next(), and Token::str().
Referenced by simplifyTokenList(), and tokenize().
| void Tokenizer::simplifyKeyword | ( | ) |
Remove keywords "volatile", "inline", "register", and "restrict".
Definition at line 8547 of file tokenize.cpp.
References _settings, Standards::c, Standards::C99, Standards::cpp, Standards::CPP11, TokenList::front(), list, Token::Match(), Token::next(), and Settings::standards.
Referenced by tokenize(), and tokenizeCondition().
| bool Tokenizer::simplifyKnownVariables | ( | ) |
A simplify function that replaces a variable with its value in cases when the value is known.
e.g. "x=10; if(x)" => "x=10;if(10)"
Definition at line 5859 of file tokenize.cpp.
References _settings, Token::deleteNext(), Token::deleteThis(), TokenList::front(), Token::isName(), list, Token::Match(), Token::next(), Token::previous(), Token::replace(), simplifyKnownVariablesGetData(), simplifyKnownVariablesSimplify(), Token::str(), Token::strAt(), Settings::terminated(), Token::tokAt(), and Token::varId().
Referenced by simplifyTokenList().
| bool Tokenizer::simplifyKnownVariablesGetData | ( | unsigned int | varid, |
| Token ** | _tok2, | ||
| Token ** | _tok3, | ||
| std::string & | value, | ||
| unsigned int & | valueVarId, | ||
| bool & | valueIsPointer, | ||
| bool | floatvar | ||
| ) | [static] |
Utility function for simplifyKnownVariables.
Get data about an assigned variable.
Definition at line 6062 of file tokenize.cpp.
References Token::isBoolean(), Token::isNumber(), Token::link(), Token::linkAt(), MathLib::longToString(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::strAt(), Token::tokAt(), MathLib::toLongNumber(), and Token::varId().
Referenced by simplifyKnownVariables().
| bool Tokenizer::simplifyKnownVariablesSimplify | ( | Token ** | tok2, |
| Token * | tok3, | ||
| unsigned int | varid, | ||
| const std::string & | structname, | ||
| std::string & | value, | ||
| unsigned int | valueVarId, | ||
| bool | valueIsPointer, | ||
| const Token *const | valueToken, | ||
| int | indentlevel | ||
| ) | const |
utility function for simplifyKnownVariables.
Perform simplification of a given variable
Definition at line 6133 of file tokenize.cpp.
References _errorLogger, _settings, Severity::debug, Settings::debugwarnings, Token::deleteNext(), Token::deleteThis(), Token::eraseTokens(), Token::findsimplematch(), TokenList::getFiles(), incdec(), Token::insertToken(), isCPP(), Token::isExtendedOp(), isFunctionParameterPassedByValue(), MathLib::isInt(), Token::isName(), Token::link(), Token::linkAt(), list, Token::Match(), Token::next(), Token::previous(), Token::progressValue(), reportError(), ErrorLogger::reportProgress(), Token::simpleMatch(), Token::str(), Token::strAt(), Token::tokAt(), and Token::varId().
Referenced by simplifyKnownVariables().
| bool Tokenizer::simplifyLabelsCaseDefault | ( | ) |
Simplify labels and 'case|default' syntaxes.
simplify labels and case|default in the code: add a ";" if not already in.
Definition at line 2444 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), Token::next(), skipTernaryOp(), and syntaxError().
Referenced by tokenize().
| bool Tokenizer::simplifyLogicalOperators | ( | ) |
Simplify the "not" and "and" keywords to "!" and "&&" accordingly.
Examples:
Definition at line 5727 of file tokenize.cpp.
References TokenList::front(), Token::link(), list, Token::Match(), Token::next(), Token::previous(), and Token::str().
Referenced by tokenize(), and tokenizeCondition().
| void Tokenizer::simplifyMathExpressions | ( | ) |
Simplify e.g.
'sin(0)' into '0'
Definition at line 9433 of file tokenize.cpp.
References Token::eraseTokens(), TokenList::front(), Token::link(), Token::linkAt(), list, Token::Match(), Token::next(), Token::simpleMatch(), Token::stringifyList(), and Token::tokAt().
Referenced by tokenize(), and tokenizeCondition().
| void Tokenizer::simplifyMathFunctions | ( | ) |
Simplify e.g.
'atol("0")' into '0'
Definition at line 7877 of file tokenize.cpp.
References TokenList::front(), MathLib::isInt(), list, MathLib::longToString(), Token::Match(), Token::next(), Token::simpleMatch(), and MathLib::toLongNumber().
Referenced by tokenize(), and tokenizeCondition().
Convert Microsoft memory functions CopyMemory(dst, src, len) -> memcpy(dst, src, len) FillMemory(dst, len, val) -> memset(dst, val, len) MoveMemory(dst, src, len) -> memmove(dst, src, len) ZeroMemory(dst, len) -> memset(dst, 0, len)
Definition at line 8873 of file tokenize.cpp.
References _settings, TokenList::front(), Token::insertToken(), Token::link(), list, Token::Match(), Token::move(), Token::next(), Token::nextArgument(), Settings::platformType, Token::previous(), Token::simpleMatch(), Token::tokAt(), Settings::Win32A, Settings::Win32W, and Settings::Win64.
Referenced by tokenize().
| void Tokenizer::simplifyMicrosoftMFC | ( | ) |
Remove Microsoft MFC 'DECLARE_MESSAGE_MAP()'.
Definition at line 8856 of file tokenize.cpp.
References _settings, TokenList::front(), list, Token::Match(), Token::next(), Settings::platformType, Token::simpleMatch(), Settings::Win32A, Settings::Win32W, and Settings::Win64.
Referenced by tokenize().
Convert Microsoft string functions _tcscpy -> strcpy.
Definition at line 8925 of file tokenize.cpp.
References _settings, TokenList::front(), list, Token::Match(), Token::next(), Settings::platformType, Token::simpleMatch(), Settings::Win32A, Settings::Win32W, and Settings::Win64.
Referenced by tokenize().
| void Tokenizer::simplifyMulAndParens | ( | ) |
Simplify '* & ( var% ) =' or any combination of '* &' and '()' parentheses around 'var' to 'var% ='.
Definition at line 1494 of file tokenize.cpp.
References Token::deleteNext(), TokenList::front(), Token::isAssignmentOp(), list, Token::Match(), Token::next(), Token::previous(), Token::str(), and Token::tokAt().
Referenced by tokenize().
| void Tokenizer::simplifyNamespaceStd | ( | ) |
Add std:: in front of std classes, when using namespace std; was given.
Definition at line 8789 of file tokenize.cpp.
References _settings, Standards::cpp, Standards::CPP11, Token::eraseTokens(), Token::findsimplematch(), TokenList::front(), isCPP(), list, Token::Match(), Token::next(), Token::simpleMatch(), and Settings::standards.
Referenced by tokenize().
| void Tokenizer::simplifyNestedStrcat | ( | ) |
Expand nested strcat() calls.
Definition at line 6942 of file tokenize.cpp.
References TokenList::front(), Token::insertToken(), Token::link(), list, Token::Match(), Token::move(), Token::next(), Token::previous(), Token::simpleMatch(), Token::strAt(), Token::tokAt(), and Token::varId().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyNull | ( | ) |
Definition at line 2188 of file tokenize.cpp.
References _settings, Standards::cpp, Standards::CPP11, TokenList::front(), isCPP(), MathLib::isInt(), list, Token::Match(), Token::next(), Settings::standards, and MathLib::toLongNumber().
Referenced by tokenize(), and tokenizeCondition().
| void Tokenizer::simplifyOperatorName | ( | ) |
Collapse operator name tokens into single token operator = => operator=.
Definition at line 9191 of file tokenize.cpp.
References Token::eraseTokens(), TokenList::front(), isC(), Token::isName(), Token::link(), list, Token::Match(), Token::next(), Token::simpleMatch(), Token::str(), and Token::tokAt().
Referenced by tokenize().
| void Tokenizer::simplifyParameterVoid | ( | ) |
Definition at line 2301 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), and Token::next().
Referenced by tokenize().
| void Tokenizer::simplifyPlatformTypes | ( | ) |
Convert platform dependent types to standard types.
32 bits: size_t -> unsigned long 64 bits: size_t -> unsigned long long
Definition at line 5200 of file tokenize.cpp.
References _settings, TokenList::front(), list, Token::Match(), Token::next(), Settings::platformType, Settings::sizeof_long, Settings::sizeof_size_t, Settings::Win32A, Settings::Win32W, and Settings::Win64.
Referenced by tokenize(), and tokenizeCondition().
Simplify pointer to standard type (C only)
Definition at line 4820 of file tokenize.cpp.
References TokenList::front(), isC(), list, Token::Match(), and Token::next().
Referenced by tokenize().
| void Tokenizer::simplifyQtSignalsSlots | ( | ) |
Remove Qt signals and slots.
Definition at line 9070 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), Token::next(), and Token::simpleMatch().
Referenced by tokenize().
| void Tokenizer::simplifyRealloc | ( | ) |
Simplifies some realloc usage like 'x = realloc (0, n);' => 'x = malloc(n);' 'x = realloc (y, 0);' => 'x = 0; free(y);'.
Definition at line 3659 of file tokenize.cpp.
References Token::deleteNext(), TokenList::front(), Token::insertToken(), Token::link(), list, Token::Match(), Token::move(), Token::next(), Token::previous(), Token::simpleMatch(), and Token::tokAt().
Referenced by simplifyTokenList().
Definition at line 2309 of file tokenize.cpp.
References TokenList::front(), list, and Token::simpleMatch().
Referenced by simplifyTokenList(), and tokenize().
Remove redundant parentheses:
Definition at line 6563 of file tokenize.cpp.
References Token::deleteNext(), Token::deleteThis(), Token::findsimplematch(), TokenList::front(), Token::isArithmeticalOp(), isCPP(), Token::link(), list, Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), and Token::tokAt().
Referenced by Preprocessor::simplifyCondition(), simplifyTokenList(), tokenize(), and tokenizeCondition().
| void Tokenizer::simplifyReference | ( | ) |
Simplify references.
Definition at line 6703 of file tokenize.cpp.
References TokenList::front(), isC(), Token::link(), list, Token::Match(), Token::next(), and Token::tokAt().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyReturnStrncat | ( | ) |
Simplify e.g.
'return(strncat(temp,"a",1));' into strncat(temp,"a",1); return temp;
Definition at line 9323 of file tokenize.cpp.
References copyTokens(), Token::deleteThis(), TokenList::front(), Token::insertToken(), Token::link(), Token::linkAt(), list, Token::next(), Token::nextArgument(), Token::simpleMatch(), and Token::tokAt().
Referenced by simplifyTokenList().
Definition at line 2238 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), Token::next(), and Token::simpleMatch().
Referenced by tokenize().
| bool Tokenizer::simplifySizeof | ( | ) |
Replace sizeof() to appropriate size.
Definition at line 3076 of file tokenize.cpp.
References Token::createMutualLinks(), Token::eChar, Token::eIncDecOp, Token::eraseTokens(), Token::eString, Token::findmatch(), TokenList::front(), Token::getStrLength(), Token::insertToken(), list, MathLib::longToString(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), sizeOfType(), Token::str(), Token::tokAt(), and MathLib::toLongNumber().
Referenced by Preprocessor::simplifyCondition(), and simplifyTokenList().
| void Tokenizer::simplifySQL | ( | ) |
Definition at line 2254 of file tokenize.cpp.
References Token::eraseTokens(), TokenList::front(), list, Token::next(), Token::simpleMatch(), Token::str(), Token::stringifyList(), and Token::tokAt().
Referenced by tokenize().
| void Tokenizer::simplifyStd | ( | ) |
Remove "std::" before some function names.
Definition at line 7520 of file tokenize.cpp.
References TokenList::front(), isC(), list, Token::Match(), and Token::next().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyStdType | ( | ) |
Collapse compound standard types into a single token.
unsigned long long int => long _isUnsigned=true,_isLong=true
Definition at line 5399 of file tokenize.cpp.
References TokenList::front(), list, Token::Match(), and Token::next().
Referenced by tokenize(), and tokenizeCondition().
| std::string Tokenizer::simplifyString | ( | const std::string & | source | ) | [static] |
Modify strings in the token list by replacing hex and oct values.
E.g. "\x61" -> "a" and "\000" -> "\0"
| source | The string to be modified, e.g. "\x61" |
Definition at line 8112 of file tokenize.cpp.
References MathLib::isOctalDigit().
Referenced by combineStrings().
| void Tokenizer::simplifyStructDecl | ( | ) |
Struct simplification "struct S { } s;" => "struct S { }; S s;".
Definition at line 8373 of file tokenize.cpp.
References Token::deleteThis(), TokenList::front(), Token::insertToken(), Token::link(), list, MathLib::longToString(), Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), Token::tokAt(), and Token::varId().
Referenced by tokenize().
| void Tokenizer::simplifyStructInit | ( | ) |
Struct initialization.
Definition at line 8152 of file tokenize.cpp.
References Token::deleteThis(), TokenList::front(), Token::insertToken(), Token::link(), list, Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), Token::tokAt(), and Token::varId().
Referenced by tokenize().
| void Tokenizer::simplifyTemplates | ( | ) |
Simplify templates.
Definition at line 2503 of file tokenize.cpp.
References _codeWithTemplates, _errorLogger, _settings, Token::deleteNext(), TokenList::front(), Token::insertToken(), isC(), list, MathLib::longToString(), Token::Match(), Token::next(), sizeOfType(), and Token::tokAt().
Referenced by tokenize().
| bool Tokenizer::simplifyTokenList | ( | ) |
Simplify tokenlist.
Definition at line 3299 of file tokenize.cpp.
References _settings, _symbolDatabase, Settings::_verbose, Token::assignProgressValues(), Token::createMutualLinks(), createSymbolDatabase(), Settings::debug, Settings::debugwarnings, deleteSymbolDatabase(), Token::deleteThis(), elseif(), TokenList::front(), TokenList::getFiles(), Token::getStrLength(), Token::link(), list, Token::Match(), Token::next(), Token::printOut(), SymbolDatabase::printOut(), printUnknownTypes(), removeRedundantAssignment(), removeRedundantConditions(), removeRedundantFor(), removeRedundantSemicolons(), Token::simpleMatch(), simplifyCalculations(), simplifyCasts(), simplifyCharAt(), simplifyComma(), simplifyComparisonOrder(), simplifyConditionOperator(), simplifyConditions(), simplifyConstTernaryOp(), simplifyEmptyNamespaces(), simplifyErrNoInWhile(), simplifyFlowControl(), simplifyFuncInWhile(), simplifyFunctionReturn(), simplifyGoto(), simplifyIfAssign(), simplifyIfNot(), simplifyIfNotNull(), simplifyIfSameInnerCondition(), simplifyInitVar(), simplifyKnownVariables(), simplifyNestedStrcat(), simplifyRealloc(), simplifyRedundantConsecutiveBraces(), simplifyRedundantParentheses(), simplifyReference(), simplifyReturnStrncat(), simplifySizeof(), simplifyStd(), simplifyUndefinedSizeArray(), simplifyVarDecl(), simplifyWhile0(), Settings::terminated(), Token::tokAt(), and validate().
Referenced by CppCheck::analyseFile(), and CppCheck::checkFile().
| void Tokenizer::simplifyTypedef | ( | ) |
typedef A mytype; mytype c;
Becomes: typedef A mytype; A c;
Definition at line 501 of file tokenize.cpp.
References _errorLogger, Space::classEnd, Space::className, copyTokens(), Token::createMutualLinks(), deleteInvalidTypedef(), Token::deleteNext(), Token::deleteThis(), duplicateTypedef(), Token::eraseTokens(), Token::findClosingBracket(), Token::findmatch(), TokenList::front(), TokenList::getFiles(), Token::insertToken(), Space::isNamespace, Token::isStandardType(), Token::link(), Token::linkAt(), list, Token::Match(), Token::next(), Token::previous(), processFunc(), ErrorLogger::reportProgress(), Token::simpleMatch(), splitDefinitionFromTypedef(), Token::str(), Token::strAt(), syntaxError(), Token::tokAt(), and unsupportedTypedef().
Referenced by tokenize().
Change (multiple) arrays to (multiple) pointers.
Definition at line 4530 of file tokenize.cpp.
References Token::deleteNext(), TokenList::front(), list, Token::Match(), Token::next(), Token::previous(), Token::str(), and Token::tokAt().
Referenced by simplifyTokenList().
| void Tokenizer::simplifyVarDecl | ( | bool | only_k_r_fpar | ) |
Simplify variable declarations (split up)
| only_k_r_fpar | Only simplify K&R function parameters |
Definition at line 4945 of file tokenize.cpp.
References Token::findClosingBracket(), TokenList::front(), TokenList::insertTokens(), isCPP(), Token::isName(), Token::link(), list, Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), Token::strAt(), TemplateSimplifier::templateParameters(), Token::tokAt(), and Token::varId().
Referenced by simplifyTokenList(), and tokenize().
Simplify multiple assignments.
Example: "a = b = c = 0;" => "a = 0; b = 0; c = 0;"
Definition at line 5553 of file tokenize.cpp.
References TokenList::front(), Token::insertToken(), list, Token::Match(), Token::next(), Token::previous(), Token::str(), and Token::tokAt().
Referenced by tokenize().
| void Tokenizer::simplifyWhile0 | ( | ) |
simplify "while (0)"
Definition at line 8257 of file tokenize.cpp.
References Token::deleteThis(), eraseDeadCode(), Token::findmatch(), TokenList::front(), Token::link(), list, Token::Match(), Token::next(), Token::previous(), Token::simpleMatch(), and Token::str().
Referenced by simplifyTokenList().
| unsigned int Tokenizer::sizeOfType | ( | const Token * | type | ) | const |
Calculates sizeof value for given type.
| type | Token which will contain e.g. "int", "*", or string. |
Definition at line 72 of file tokenize.cpp.
References _settings, _typeSize, Token::eString, Token::getStrLength(), Token::isLong(), Settings::sizeof_long_double, Settings::sizeof_long_long, Token::str(), and Token::type().
Referenced by CheckBufferOverrun::ArrayInfo::ArrayInfo(), CheckMemoryLeakInFunction::check(), CheckBufferOverrun::checkFunctionParameter(), CheckBufferOverrun::checkGlobalAndLocalVariable(), CheckOther::checkIncompleteArrayFill(), CheckOther::isUnsigned(), simplifySizeof(), and simplifyTemplates().
| void Tokenizer::syntaxError | ( | const Token * | tok | ) | const |
Syntax error.
Definition at line 7846 of file tokenize.cpp.
References Severity::error, and reportError().
Referenced by createLinks(), getErrorMessages(), hasComplicatedSyntaxErrorsInTemplates(), hasEnumsWithTypedef(), linkBrackets(), simplifyAddBracesPair(), simplifyAddBracesToCommand(), simplifyEnum(), simplifyFunctionParameters(), simplifyGoto(), simplifyLabelsCaseDefault(), simplifyTypedef(), and tokenize().
| void Tokenizer::syntaxError | ( | const Token * | tok, |
| char | c | ||
| ) | const |
Syntax error.
Example: invalid number of ')'
Definition at line 7851 of file tokenize.cpp.
References _configuration, Severity::error, and reportError().
| bool Tokenizer::tokenize | ( | std::istream & | code, |
| const char | FileName[], | ||
| const std::string & | configuration = "" |
||
| ) |
Tokenize code.
| code | input stream for code, e.g. #file "p.h" class Foo { private: void Bar(); }; #endfile void Foo::Bar() { } |
| FileName | The filename |
| configuration | E.g. "A" for code where "#ifdef A" is true |
Definition at line 1555 of file tokenize.cpp.
References Settings::_basePaths, _configuration, _settings, Settings::_showtime, arraySize(), Token::assignProgressValues(), TemplateSimplifier::cleanupAfterSimplify(), combineOperators(), combineStrings(), concatenateDoubleSharp(), concatenateNegativeNumberAndAnyPositive(), cppcheckError(), createLinks(), createLinks2(), createSymbolDatabase(), TokenList::createTokens(), TokenList::deallocateTokens(), fillTypeSizes(), TokenList::front(), Path::getRelativePath(), hasComplicatedSyntaxErrorsInTemplates(), hasEnumsWithTypedef(), isCPP(), Settings::isEnabled(), list, m_timerResults, Token::Match(), Token::next(), removeExceptionSpecifications(), removeMacroInVarDecl(), removeMacrosInGlobalScope(), removeRedundantSemicolons(), removeUnnecessaryQualification(), setVarId(), Token::simpleMatch(), simplifyAddBraces(), simplifyArrayAccessSyntax(), simplifyAsm(), simplifyAssignmentBlock(), simplifyAssignmentInFunctionCall(), simplifyAttribute(), simplifyBitfields(), simplifyBorland(), simplifyBuiltinExpect(), simplifyCallingConvention(), simplifyComparisonOrder(), simplifyCompoundAssignment(), simplifyConditionOperator(), simplifyConst(), simplifyDebugNew(), simplifyDeclspec(), simplifyDoublePlusAndDoubleMinus(), simplifyEmptyNamespaces(), simplifyEnum(), simplifyExternC(), simplifyFileAndLineMacro(), simplifyFunctionParameters(), simplifyFunctionPointers(), simplifyIfNot(), simplifyIfNotNull(), simplifyInitVar(), simplifyKeyword(), simplifyLabelsCaseDefault(), simplifyLogicalOperators(), simplifyMathExpressions(), simplifyMathFunctions(), simplifyMicrosoftMemoryFunctions(), simplifyMicrosoftMFC(), simplifyMicrosoftStringFunctions(), simplifyMulAndParens(), simplifyNamespaceStd(), simplifyNull(), TemplateSimplifier::simplifyNumericCalculations(), simplifyOperatorName(), simplifyParameterVoid(), Path::simplifyPath(), simplifyPlatformTypes(), simplifyPointerToStandardType(), simplifyQtSignalsSlots(), simplifyRedundantConsecutiveBraces(), simplifyRedundantParentheses(), simplifyRoundCurlyParentheses(), simplifySQL(), simplifyStdType(), simplifyStructDecl(), simplifyStructInit(), simplifyTemplates(), simplifyTypedef(), simplifyVarDecl(), simplifyVariableMultipleAssign(), syntaxError(), unhandled_macro_class_x_y(), and validate().
Referenced by CppCheck::analyseFile(), CppCheck::checkFile(), and Preprocessor::getcode().
| bool Tokenizer::tokenizeCondition | ( | const std::string & | code | ) |
tokenize condition and run simple simplifications on it
| code | code |
Definition at line 1974 of file tokenize.cpp.
References _settings, combineOperators(), combineStrings(), concatenateDoubleSharp(), concatenateNegativeNumberAndAnyPositive(), cppcheckError(), createLinks(), TokenList::createTokens(), fillTypeSizes(), TokenList::front(), list, Token::next(), simplifyDoublePlusAndDoubleMinus(), simplifyKeyword(), simplifyLogicalOperators(), simplifyMathExpressions(), simplifyMathFunctions(), simplifyNull(), TemplateSimplifier::simplifyNumericCalculations(), simplifyPlatformTypes(), simplifyRedundantParentheses(), and simplifyStdType().
Referenced by Preprocessor::getcfgs(), and Preprocessor::simplifyCondition().
| const Token* Tokenizer::tokens | ( | ) | const [inline] |
Definition at line 728 of file tokenize.h.
Referenced by CppCheck::analyseFile(), CheckAssignIf::assignIf(), CheckMemoryLeakNoVar::check(), CheckOther::checkAlwaysTrueOrFalseStringCompare(), CheckOther::checkAssignmentInAssert(), CheckStl::checkAutoPointer(), CheckOther::checkCCTypeFunctions(), CheckOther::checkDoubleFree(), CppCheck::checkFile(), CheckBufferOverrun::checkGlobalAndLocalVariable(), CheckOther::checkIncompleteStatement(), CheckOther::checkInvalidFree(), CheckInternal::checkMissingPercentCharacter(), CheckInternal::checkRedundantNextPrevious(), CheckOther::checkSelfAssignment(), CheckUnusedVar::checkStructMemberUsage(), CheckOther::checkSuspiciousEqualityComparison(), CheckOther::checkSwitchCaseFallThrough(), CheckInternal::checkTokenMatchPatterns(), CheckInternal::checkTokenSimpleMatchPatterns(), CheckInternal::checkUnknownPattern(), CheckOther::checkUnreachableCode(), CheckOther::checkZeroDivision(), CheckAssignIf::comparison(), CheckStl::erase(), CheckUninitVar::executionPaths(), CheckMemoryLeak::getAllocationType(), Preprocessor::getcfgs(), Preprocessor::getcode(), CheckMemoryLeakInFunction::getcode(), Scope::getVariableList(), CheckOther::invalidFunctionUsage(), isFunctionParameterPassedByValue(), CheckBufferOverrun::negativeIndex(), CheckNonReentrantFunctions::nonReentrantFunctions(), CheckUnusedFunctions::parseTokens(), CheckStl::redundantCondition(), CheckOther::redundantGetAndSetUserId(), Preprocessor::simplifyCondition(), simplifyFunctionReturn(), CheckOther::sizeofCalculation(), CheckOther::sizeofsizeof(), CheckStl::string_c_str(), CheckOther::suspiciousSizeofCalculation(), SymbolDatabase::SymbolDatabase(), CheckClass::thisSubtraction(), PreprocessorMacro::tokens(), validate(), CheckClass::virtualDestructor(), and CheckOther::warningOldStylePointerCast().
| void Tokenizer::unhandled_macro_class_x_y | ( | const Token * | tok | ) |
Report that there is an unhandled "class x y {" code.
Definition at line 7858 of file tokenize.cpp.
References Severity::information, reportError(), Token::str(), and Token::strAt().
Referenced by tokenize().
| void Tokenizer::unnecessaryQualificationError | ( | const Token * | tok, |
| const std::string & | qualification | ||
| ) | const |
unnecessary member qualification error
Definition at line 9317 of file tokenize.cpp.
References Severity::portability, and reportError().
Referenced by getErrorMessages(), and removeUnnecessaryQualification().
| void Tokenizer::unsupportedTypedef | ( | const Token * | tok | ) | const |
Definition at line 306 of file tokenize.cpp.
References _settings, Severity::debug, Settings::debugwarnings, Token::next(), reportError(), and Token::str().
Referenced by simplifyTypedef().
| bool Tokenizer::validate | ( | ) | const |
assert that tokens are ok - used during debugging for example to catch problems in simplifyTokenList.
Definition at line 8053 of file tokenize.cpp.
References TokenList::back(), cppcheckError(), list, Token::Match(), Token::next(), and tokens().
Referenced by simplifyTokenList(), and tokenize().
| unsigned int Tokenizer::varIdCount | ( | ) | const [inline] |
Get variable count.
Definition at line 707 of file tokenize.h.
Referenced by CheckBufferOverrun::checkGlobalAndLocalVariable(), CheckBufferOverrun::executionPaths(), and SymbolDatabase::SymbolDatabase().
bool Tokenizer::_codeWithTemplates [private] |
was there any templates? templates that are "unused" are removed from the token list
Definition at line 772 of file tokenize.h.
Referenced by simplifyTemplates().
std::string Tokenizer::_configuration [private] |
E.g.
"A" for code where "#ifdef A" is true. This is used to print additional information in error situations.
Definition at line 760 of file tokenize.h.
Referenced by syntaxError(), and tokenize().
ErrorLogger* const Tokenizer::_errorLogger [private] |
errorlogger
Definition at line 753 of file tokenize.h.
Referenced by createSymbolDatabase(), printUnknownTypes(), reportError(), simplifyKnownVariablesSimplify(), simplifyTemplates(), and simplifyTypedef().
const Settings* Tokenizer::_settings [private] |
settings
Definition at line 750 of file tokenize.h.
Referenced by createSymbolDatabase(), duplicateDeclarationError(), duplicateEnumError(), duplicateTypedefError(), fillTypeSizes(), isC(), isCPP(), removeUnnecessaryQualification(), simplifyKeyword(), simplifyKnownVariables(), simplifyKnownVariablesSimplify(), simplifyMicrosoftMemoryFunctions(), simplifyMicrosoftMFC(), simplifyMicrosoftStringFunctions(), simplifyNamespaceStd(), simplifyNull(), simplifyPlatformTypes(), simplifyTemplates(), simplifyTokenList(), sizeOfType(), tokenize(), tokenizeCondition(), Tokenizer(), and unsupportedTypedef().
SymbolDatabase* Tokenizer::_symbolDatabase [private] |
Symbol database that all checks etc can use.
Definition at line 756 of file tokenize.h.
Referenced by createSymbolDatabase(), deleteSymbolDatabase(), printUnknownTypes(), simplifyTokenList(), and ~Tokenizer().
std::map<std::string, unsigned int> Tokenizer::_typeSize [private] |
sizeof information for known types
Definition at line 763 of file tokenize.h.
Referenced by fillTypeSizes(), simplifyCasts(), and sizeOfType().
unsigned int Tokenizer::_varId [private] |
variable count
Definition at line 766 of file tokenize.h.
Referenced by printUnknownTypes(), setVarId(), and simplifyFuncInWhile().
Token list: stores all tokens.
Definition at line 726 of file tokenize.h.
Referenced by arraySize(), CppCheck::checkFile(), combineOperators(), combineStrings(), concatenateDoubleSharp(), concatenateNegativeNumberAndAnyPositive(), createLinks(), createLinks2(), createSymbolDatabase(), SymbolDatabase::debugMessage(), deleteInvalidTypedef(), deleteSymbolDatabase(), elseif(), getSourceFilePath(), hasComplicatedSyntaxErrorsInTemplates(), hasEnumsWithTypedef(), PreprocessorMacro::PreprocessorMacro(), SymbolDatabase::printOut(), SymbolDatabase::printVariable(), removeExceptionSpecifications(), removeMacroInVarDecl(), removeMacrosInGlobalScope(), removeRedundantAssignment(), removeRedundantConditions(), removeRedundantFor(), removeRedundantSemicolons(), removeUnnecessaryQualification(), CheckMemoryLeak::reportErr(), reportError(), setVarId(), simplifyAddBraces(), simplifyArrayAccessSyntax(), simplifyAsm(), simplifyAssignmentBlock(), simplifyAssignmentInFunctionCall(), simplifyAttribute(), simplifyBitfields(), simplifyBorland(), simplifyBuiltinExpect(), simplifyCalculations(), simplifyCallingConvention(), simplifyCasts(), simplifyCharAt(), simplifyComma(), simplifyComparisonOrder(), simplifyCompoundAssignment(), simplifyConditionOperator(), simplifyConditions(), simplifyConst(), simplifyConstTernaryOp(), simplifyDebugNew(), simplifyDeclspec(), simplifyDoublePlusAndDoubleMinus(), simplifyEmptyNamespaces(), simplifyEnum(), simplifyErrNoInWhile(), simplifyExternC(), simplifyFileAndLineMacro(), simplifyFlowControl(), simplifyFuncInWhile(), simplifyFunctionParameters(), simplifyFunctionPointers(), simplifyFunctionReturn(), simplifyGoto(), simplifyIfAssign(), simplifyIfNot(), simplifyIfNotNull(), simplifyIfSameInnerCondition(), simplifyInitVar(), simplifyKeyword(), simplifyKnownVariables(), simplifyKnownVariablesSimplify(), simplifyLabelsCaseDefault(), simplifyLogicalOperators(), simplifyMathExpressions(), simplifyMathFunctions(), simplifyMicrosoftMemoryFunctions(), simplifyMicrosoftMFC(), simplifyMicrosoftStringFunctions(), simplifyMulAndParens(), simplifyNamespaceStd(), simplifyNestedStrcat(), simplifyNull(), simplifyOperatorName(), simplifyParameterVoid(), simplifyPlatformTypes(), simplifyPointerToStandardType(), simplifyQtSignalsSlots(), simplifyRealloc(), simplifyRedundantConsecutiveBraces(), simplifyRedundantParentheses(), simplifyReference(), simplifyReturnStrncat(), simplifyRoundCurlyParentheses(), simplifySizeof(), simplifySQL(), simplifyStd(), simplifyStdType(), simplifyStructDecl(), simplifyStructInit(), simplifyTemplates(), simplifyTokenList(), simplifyTypedef(), simplifyUndefinedSizeArray(), simplifyVarDecl(), simplifyVariableMultipleAssign(), simplifyWhile0(), tokenize(), tokenizeCondition(), and validate().
TimerResults* Tokenizer::m_timerResults [private] |
1.7.6.1