|
Cppcheck
|
#include <symboldatabase.h>
Classes | |
| struct | UsingInfo |
Public Types | |
| enum | ScopeType { eGlobal, eClass, eStruct, eUnion, eNamespace, eFunction, eIf, eElse, eElseIf, eFor, eWhile, eDo, eSwitch, eUnconditional, eTry, eCatch } |
Public Member Functions | |
| Scope (const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_) | |
| Scope (const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_) | |
| bool | isClassOrStruct () const |
| bool | isExecutable () const |
| bool | isLocal () const |
| const Function * | findFunction (const Token *tok) const |
| find a function | |
| Scope * | findInNestedList (const std::string &name) |
| find if name is in nested list | |
| const Scope * | findRecordInNestedList (const std::string &name) const |
| Scope * | findRecordInNestedList (const std::string &name) |
| const Type * | findType (const std::string &name) const |
| Type * | findType (const std::string &name) |
| Scope * | findInNestedListRecursive (const std::string &name) |
| find if name is in nested list | |
| void | addVariable (const Token *token_, const Token *start_, const Token *end_, AccessControl access_, const Type *type_, const Scope *scope_) |
| void | getVariableList () |
| initialize varlist | |
| const Function * | getDestructor () const |
| unsigned int | getNestedNonFunctions () const |
| get the number of nested scopes that are not functions | |
| bool | hasDefaultConstructor () const |
| AccessControl | defaultAccess () const |
| const Token * | checkVariable (const Token *tok, AccessControl varaccess) |
| check if statement is variable declaration and add it if it is | |
| const Variable * | getVariable (const std::string &varname) const |
| get variable from name | |
Public Attributes | |
| const SymbolDatabase * | check |
| std::string | className |
| const Token * | classDef |
| const Token * | classStart |
| const Token * | classEnd |
| std::list< Function > | functionList |
| std::list< Variable > | varlist |
| const Scope * | nestedIn |
| std::list< Scope * > | nestedList |
| unsigned int | numConstructors |
| unsigned int | numCopyConstructors |
| std::list< UsingInfo > | usingList |
| ScopeType | type |
| Type * | definedType |
| std::list< Type * > | definedTypes |
| const Scope * | functionOf |
| Function * | function |
Private Member Functions | |
| bool | isVariableDeclaration (const Token *tok, const Token *&vartok, const Token *&typetok) const |
| helper function for getVariableList() | |
Friends | |
| class | TestSymbolDatabase |
Definition at line 499 of file symboldatabase.h.
| enum Scope::ScopeType |
| eGlobal | |
| eClass | |
| eStruct | |
| eUnion | |
| eNamespace | |
| eFunction | |
| eIf | |
| eElse | |
| eElseIf | |
| eFor | |
| eWhile | |
| eDo | |
| eSwitch | |
| eUnconditional | |
| eTry | |
| eCatch |
Definition at line 509 of file symboldatabase.h.
| Scope::Scope | ( | const SymbolDatabase * | check_, |
| const Token * | classDef_, | ||
| const Scope * | nestedIn_ | ||
| ) |
Definition at line 1997 of file symboldatabase.cpp.
References classDef, className, eClass, eFunction, eGlobal, eNamespace, eStruct, eUnion, Token::Match(), Token::next(), Token::str(), Token::tokAt(), and type.
| Scope::Scope | ( | const SymbolDatabase * | check_, |
| const Token * | classDef_, | ||
| const Scope * | nestedIn_, | ||
| ScopeType | type_, | ||
| const Token * | start_ | ||
| ) |
Definition at line 1982 of file symboldatabase.cpp.
| void Scope::addVariable | ( | const Token * | token_, |
| const Token * | start_, | ||
| const Token * | end_, | ||
| AccessControl | access_, | ||
| const Type * | type_, | ||
| const Scope * | scope_ | ||
| ) | [inline] |
Definition at line 578 of file symboldatabase.h.
Referenced by checkVariable(), and SymbolDatabase::SymbolDatabase().
| const Token * Scope::checkVariable | ( | const Token * | tok, |
| AccessControl | varaccess | ||
| ) |
check if statement is variable declaration and add it if it is
| tok | pointer to start of statement |
| varaccess | access control of statement |
Definition at line 2187 of file symboldatabase.cpp.
References addVariable(), check, SymbolDatabase::debugMessage(), Token::findmatch(), SymbolDatabase::findVariableType(), Token::isBoolean(), isVariableDeclaration(), Token::link(), Token::linkAt(), Token::Match(), nestedIn, Token::next(), Token::previous(), Token::simpleMatch(), Token::str(), Token::tokAt(), usingList, and Token::varId().
Referenced by getVariableList(), and SymbolDatabase::SymbolDatabase().
| AccessControl Scope::defaultAccess | ( | ) | const |
Definition at line 2049 of file symboldatabase.cpp.
References eClass, eGlobal, eNamespace, eStruct, eUnion, Global, Local, Namespace, Private, Public, and type.
Referenced by getVariableList().
| const Function * Scope::findFunction | ( | const Token * | tok | ) | const |
find a function
| tok | token of function call |
It does not take into account function constantness. It does not take into account argument types. This can be difficult because of promotion and conversion operators and casts and because the argument can also be a function call.
Definition at line 2385 of file symboldatabase.cpp.
References Function::argCount(), functionList, Function::minArgCount(), Token::nextArgument(), Token::str(), Token::strAt(), and Token::tokAt().
Referenced by SymbolDatabase::findFunction(), and CheckClass::initializeVarList().
| Scope * Scope::findInNestedList | ( | const std::string & | name | ) |
find if name is in nested list
| name | name of nested scope |
Definition at line 2511 of file symboldatabase.cpp.
References nestedList.
Referenced by SymbolDatabase::addClassFunction().
| Scope * Scope::findInNestedListRecursive | ( | const std::string & | name | ) |
find if name is in nested list
| name | name of nested scope |
Definition at line 2550 of file symboldatabase.cpp.
References findInNestedListRecursive(), and nestedList.
Referenced by findInNestedListRecursive(), and SymbolDatabase::SymbolDatabase().
| const Scope * Scope::findRecordInNestedList | ( | const std::string & | name | ) | const |
Definition at line 2524 of file symboldatabase.cpp.
References eFunction, and nestedList.
Referenced by SymbolDatabase::findFunction(), SymbolDatabase::findScope(), and SymbolDatabase::findType().
| Scope* Scope::findRecordInNestedList | ( | const std::string & | name | ) | [inline] |
Definition at line 563 of file symboldatabase.h.
| const Type * Scope::findType | ( | const std::string & | name | ) | const |
Definition at line 2537 of file symboldatabase.cpp.
References definedTypes.
Referenced by SymbolDatabase::findType().
| Type* Scope::findType | ( | const std::string & | name | ) | [inline] |
Definition at line 568 of file symboldatabase.h.
| const Function * Scope::getDestructor | ( | ) | const |
Definition at line 2569 of file symboldatabase.cpp.
References Function::eDestructor, and functionList.
Referenced by CheckClass::virtualDestructor().
| unsigned int Scope::getNestedNonFunctions | ( | ) | const |
get the number of nested scopes that are not functions
This returns the number of user defined types (class, struct, union) that are defined in this user defined type or namespace.
Definition at line 2581 of file symboldatabase.cpp.
References eFunction, and nestedList.
| const Variable * Scope::getVariable | ( | const std::string & | varname | ) | const |
get variable from name
| varname | name of variable |
Definition at line 2258 of file symboldatabase.cpp.
References varlist.
Referenced by CheckClass::initializerListOrder(), and SymbolDatabase::SymbolDatabase().
| void Scope::getVariableList | ( | ) |
initialize varlist
Definition at line 2068 of file symboldatabase.cpp.
References SymbolDatabase::_tokenizer, check, checkVariable(), className, classStart, defaultAccess(), Token::link(), Token::Match(), Token::next(), Private, Protected, Public, Token::simpleMatch(), and Tokenizer::tokens().
Referenced by SymbolDatabase::SymbolDatabase().
| bool Scope::hasDefaultConstructor | ( | ) | const |
Definition at line 2036 of file symboldatabase.cpp.
References Function::eConstructor, functionList, and numConstructors.
| bool Scope::isClassOrStruct | ( | ) | const [inline] |
Definition at line 534 of file symboldatabase.h.
Referenced by CheckBufferOverrun::checkStructVariable(), Variable::evaluate(), SymbolDatabase::isFunction(), and SymbolDatabase::SymbolDatabase().
| bool Scope::isExecutable | ( | ) | const [inline] |
Definition at line 538 of file symboldatabase.h.
Referenced by CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), SymbolDatabase::findFunction(), and SymbolDatabase::SymbolDatabase().
| bool Scope::isLocal | ( | ) | const [inline] |
Definition at line 542 of file symboldatabase.h.
Referenced by isVariableDeclaration().
| bool Scope::isVariableDeclaration | ( | const Token * | tok, |
| const Token *& | vartok, | ||
| const Token *& | typetok | ||
| ) | const [private] |
helper function for getVariableList()
| tok | pointer to token to check |
| vartok | populated with pointer to the variable token, if found |
| typetok | populated with pointer to the type token, if found |
Definition at line 2291 of file symboldatabase.cpp.
References SymbolDatabase::_tokenizer, check, eCatch, eFunction, Token::findClosingBracket(), Tokenizer::isCPP(), isLocal(), Token::link(), Token::Match(), Token::next(), Token::simpleMatch(), skipPointers(), skipScopeIdentifiers(), Token::str(), Token::strAt(), Token::tokAt(), and type.
Referenced by checkVariable().
friend class TestSymbolDatabase [friend] |
Definition at line 501 of file symboldatabase.h.
| const SymbolDatabase* Scope::check |
Definition at line 514 of file symboldatabase.h.
Referenced by Function::argsMatch(), checkVariable(), getVariableList(), and isVariableDeclaration().
| const Token* Scope::classDef |
Definition at line 516 of file symboldatabase.h.
Referenced by CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckClass::checkMemsetType(), CheckBufferOverrun::checkStructVariable(), CheckClass::constructors(), CheckClass::copyconstructors(), CheckNullPointer::nullPointerLinkedList(), SymbolDatabase::printVariable(), Scope(), SymbolDatabase::SymbolDatabase(), and CheckClass::virtualDestructor().
| const Token* Scope::classEnd |
Definition at line 518 of file symboldatabase.h.
Referenced by SymbolDatabase::addNewFunction(), CheckBufferOverrun::arrayIndexThenCheck(), CheckAutoVariables::autoVariables(), CheckLeakAutoVar::check(), CheckMemoryLeakNoVar::check(), CheckOther::checkAssignBoolToPointer(), CheckOther::checkBitwiseOnBoolean(), CheckBoost::checkBoostForeachModification(), CheckBufferOverrun::checkBufferAllocatedWithStrlen(), CheckOther::checkCastIntToCharAndBack(), CheckOther::checkCharVariable(), CheckOther::checkComparisonOfBoolExpressionWithInt(), CheckOther::checkComparisonOfBoolWithBool(), CheckOther::checkComparisonOfBoolWithInt(), CheckOther::checkComparisonOfFuncReturningBool(), CheckClass::checkConstFunc(), CheckIO::checkCoutCerrMisusage(), CheckIO::checkFileUsage(), CheckBufferOverrun::checkFunctionParameter(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckBufferOverrun::checkGlobalAndLocalVariable(), CheckOther::checkIncompleteArrayFill(), CheckOther::checkIncorrectLogicOperator(), CheckOther::checkIncorrectStringCompare(), CheckOther::checkIncrementBoolean(), CheckOther::checkMathFunctions(), CheckOther::checkMemsetZeroBytes(), CheckOther::checkMisusedScopedObject(), CheckOther::checkModuloAlwaysTrueFalse(), CheckOther::checkNegativeBitwiseShift(), CheckOther::checkPipeParameterSize(), CheckMemoryLeakInFunction::checkReallocUsage(), CheckOther::checkRedundantAssignment(), CheckOther::checkSignOfUnsignedVariable(), CheckOther::checkSizeofForArrayParameter(), CheckOther::checkSizeofForNumericParameter(), CheckOther::checkSizeofForPointerSize(), CheckOther::checkSleepTimeInterval(), CheckBufferOverrun::checkStructVariable(), CheckMemoryLeakStructMember::checkStructVariable(), CheckOther::checkSuspiciousStringCompare(), CheckOther::checkUnsignedDivision(), CheckOther::checkVarFuncNullUB(), CheckOther::checkVariableScope(), CheckIO::checkWrongPrintfScanfArguments(), CheckOther::clarifyCalculation(), CheckOther::clarifyCondition(), CheckOther::clarifyStatement(), Tokenizer::createSymbolDatabase(), CheckExceptionSafety::deallocThrow(), CheckExceptionSafety::destructors(), CheckMemoryLeak::functionArgAlloc(), CheckMemoryLeak::functionReturnType(), CheckClass::hasAllocation(), CheckClass::hasAssignSelf(), CheckClass::initializationListUsage(), CheckClass::initializeVarList(), CheckOther::invalidPointerCast(), CheckIO::invalidScanf(), CheckMemoryLeakStructMember::isMalloc(), CheckStl::iterators(), CheckStl::mismatchingContainers(), CheckClass::noMemset(), CheckNullPointer::nullConstantDereference(), CheckNullPointer::nullPointerDefaultArgument(), CheckNullPointer::nullPointerStructByDeRefAndChec(), CheckObsoleteFunctions::obsoleteFunctions(), CheckMemoryLeakInFunction::parse_noreturn(), Check64BitPortability::pointerassignment(), CheckPostfixOperator::postfixOperator(), CheckClass::privateFunctions(), CheckStl::pushback(), CheckAutoVariables::returnPointerToLocalArray(), CheckAutoVariables::returnReference(), CheckStl::size(), CheckStl::stlBoundaries(), CheckOther::strPlusChar(), SymbolDatabase::SymbolDatabase(), CheckStl::uselessCalls(), variableIsUsedInScope(), and CheckBufferOverrun::writeOutsideBufferSize().
| std::string Scope::className |
Definition at line 515 of file symboldatabase.h.
Referenced by SymbolDatabase::addClassFunction(), Function::argsMatch(), CheckClass::checkConst(), CheckMemoryLeakInClass::checkPublicFunctions(), CheckClass::checkReturnPtrThis(), CheckUninitVar::checkScope(), CheckBufferOverrun::checkStructVariable(), CheckClass::constructors(), CheckClass::copyconstructors(), SymbolDatabase::findFunction(), getVariableList(), CheckClass::initializerListOrder(), CheckObsoleteFunctions::obsoleteFunctions(), CheckClass::operatorEq(), CheckClass::operatorEqRetRefThis(), CheckClass::operatorEqToSelf(), CheckMemoryLeakInFunction::parse_noreturn(), SymbolDatabase::printVariable(), CheckClass::privateFunctions(), Scope(), SymbolDatabase::SymbolDatabase(), and CheckMemoryLeakInClass::variable().
| const Token* Scope::classStart |
Definition at line 517 of file symboldatabase.h.
Referenced by SymbolDatabase::addNewFunction(), CheckBufferOverrun::arrayIndexThenCheck(), CheckAutoVariables::autoVariables(), CheckMemoryLeakInFunction::call_func(), CheckLeakAutoVar::check(), CheckMemoryLeakInFunction::check(), CheckOther::checkAssignBoolToPointer(), CheckOther::checkBitwiseOnBoolean(), CheckBoost::checkBoostForeachModification(), CheckBufferOverrun::checkBufferAllocatedWithStrlen(), CheckOther::checkCastIntToCharAndBack(), CheckOther::checkCharVariable(), CheckOther::checkComparisonOfBoolExpressionWithInt(), CheckOther::checkComparisonOfBoolWithBool(), CheckOther::checkComparisonOfBoolWithInt(), CheckOther::checkComparisonOfFuncReturningBool(), CheckClass::checkConstFunc(), CheckIO::checkCoutCerrMisusage(), CheckIO::checkFileUsage(), CheckBufferOverrun::checkFunctionParameter(), CheckBufferOverrun::checkGlobalAndLocalVariable(), CheckOther::checkIncompleteArrayFill(), CheckOther::checkIncorrectLogicOperator(), CheckOther::checkIncorrectStringCompare(), CheckOther::checkIncrementBoolean(), CheckOther::checkMathFunctions(), CheckOther::checkMemsetZeroBytes(), CheckOther::checkMisusedScopedObject(), CheckOther::checkModuloAlwaysTrueFalse(), CheckOther::checkNegativeBitwiseShift(), CheckOther::checkPipeParameterSize(), CheckMemoryLeakInFunction::checkReallocUsage(), CheckOther::checkSignOfUnsignedVariable(), CheckOther::checkSizeofForArrayParameter(), CheckOther::checkSizeofForNumericParameter(), CheckOther::checkSizeofForPointerSize(), CheckOther::checkSleepTimeInterval(), CheckBufferOverrun::checkStructVariable(), CheckOther::checkSuspiciousStringCompare(), CheckOther::checkUnsignedDivision(), CheckOther::checkVarFuncNullUB(), CheckIO::checkWrongPrintfScanfArguments(), CheckOther::clarifyCalculation(), CheckOther::clarifyCondition(), CheckOther::clarifyStatement(), Tokenizer::createSymbolDatabase(), CheckExceptionSafety::deallocThrow(), CheckExceptionSafety::destructors(), CheckMemoryLeak::functionArgAlloc(), CheckMemoryLeak::functionReturnType(), getVariableList(), CheckClass::hasAllocation(), CheckClass::hasAssignSelf(), CheckClass::initializationListUsage(), CheckOther::invalidPointerCast(), CheckIO::invalidScanf(), CheckStl::mismatchingContainers(), CheckClass::noMemset(), CheckNullPointer::nullConstantDereference(), CheckNullPointer::nullPointerDefaultArgument(), CheckNullPointer::nullPointerLinkedList(), CheckNullPointer::nullPointerStructByDeRefAndChec(), CheckObsoleteFunctions::obsoleteFunctions(), CheckMemoryLeakInFunction::parse_noreturn(), Check64BitPortability::pointerassignment(), CheckPostfixOperator::postfixOperator(), CheckClass::privateFunctions(), CheckStl::pushback(), CheckAutoVariables::returnPointerToLocalArray(), CheckAutoVariables::returnReference(), CheckStl::size(), CheckStl::stlBoundaries(), CheckOther::strPlusChar(), SymbolDatabase::SymbolDatabase(), CheckStl::uselessCalls(), and CheckBufferOverrun::writeOutsideBufferSize().
Definition at line 527 of file symboldatabase.h.
Referenced by CheckClass::checkConst(), CheckClass::checkMemsetType(), CheckClass::copyconstructors(), CheckClass::initializeVarList(), CheckClass::isBaseClassFunc(), CheckClass::isConstMemberFunc(), Function::isImplicitlyVirtual(), CheckClass::isMemberFunc(), CheckClass::isMemberVar(), CheckClass::operatorEqToSelf(), CheckClass::privateFunctions(), SymbolDatabase::SymbolDatabase(), and CheckClass::virtualDestructor().
| std::list<Type*> Scope::definedTypes |
Definition at line 528 of file symboldatabase.h.
Referenced by findType(), and SymbolDatabase::SymbolDatabase().
Definition at line 532 of file symboldatabase.h.
Referenced by SymbolDatabase::addClassFunction(), SymbolDatabase::addGlobalFunction(), CheckBufferOverrun::checkInsecureCmdLineArgs(), CheckExceptionSafety::destructors(), CheckClass::initializationListUsage(), CheckNullPointer::nullConstantDereference(), CheckNullPointer::nullPointerDefaultArgument(), CheckNullPointer::nullPointerStructByDeRefAndChec(), Check64BitPortability::pointerassignment(), CheckAutoVariables::returnPointerToLocalArray(), CheckAutoVariables::returnReference(), and SymbolDatabase::SymbolDatabase().
| std::list<Function> Scope::functionList |
Definition at line 519 of file symboldatabase.h.
Referenced by SymbolDatabase::addClassFunction(), SymbolDatabase::addGlobalFunction(), SymbolDatabase::addGlobalFunctionDecl(), CheckClass::canNotCopy(), CheckClass::checkConst(), checkFunctionUsage(), CheckClass::checkMemsetType(), CheckMemoryLeakInClass::checkPublicFunctions(), CheckClass::checkReturnPtrThis(), CheckClass::constructors(), CheckClass::copyconstructors(), findFunction(), getDestructor(), Type::getFunction(), hasDefaultConstructor(), CheckClass::initializerListOrder(), CheckClass::isBaseClassFunc(), CheckClass::isConstMemberFunc(), Function::isImplicitlyVirtual_rec(), CheckClass::isMemberFunc(), CheckClass::operatorEq(), CheckClass::operatorEqRetRefThis(), CheckClass::operatorEqToSelf(), CheckClass::privateFunctions(), SymbolDatabase::SymbolDatabase(), and CheckMemoryLeakInClass::variable().
| const Scope* Scope::functionOf |
Definition at line 531 of file symboldatabase.h.
Referenced by CheckMemoryLeakInFunction::check(), CheckBufferOverrun::checkStructVariable(), SymbolDatabase::findFunction(), findFunctionOf(), SymbolDatabase::findVariableType(), CheckClass::initializationListUsage(), isInMemberFunc(), and SymbolDatabase::SymbolDatabase().
| const Scope* Scope::nestedIn |
Definition at line 521 of file symboldatabase.h.
Referenced by Function::addArguments(), SymbolDatabase::addClassFunction(), CheckClass::checkConst(), CheckBufferOverrun::checkStructVariable(), checkVariable(), SymbolDatabase::findFunction(), findFunctionOf(), SymbolDatabase::findType(), SymbolDatabase::findVariableType(), isInMemberFunc(), CheckNullPointer::nullPointerByCheckAndDeRef(), UninitVar::parse(), and SymbolDatabase::SymbolDatabase().
| std::list<Scope *> Scope::nestedList |
Definition at line 522 of file symboldatabase.h.
Referenced by checkFunctionUsage(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckOther::checkInnerScope(), CheckClass::constructors(), findInNestedList(), findInNestedListRecursive(), findRecordInNestedList(), getNestedNonFunctions(), and SymbolDatabase::SymbolDatabase().
| unsigned int Scope::numConstructors |
Definition at line 523 of file symboldatabase.h.
Referenced by CheckUninitVar::checkScope(), CheckClass::constructors(), hasDefaultConstructor(), CheckMemoryLeak::isclass(), isRecordTypeWithoutSideEffects(), and SymbolDatabase::SymbolDatabase().
| unsigned int Scope::numCopyConstructors |
Definition at line 524 of file symboldatabase.h.
Referenced by SymbolDatabase::SymbolDatabase().
Definition at line 526 of file symboldatabase.h.
Referenced by SymbolDatabase::addClassFunction(), CheckClass::checkConst(), CheckOther::checkInnerScope(), CheckBufferOverrun::checkStructVariable(), TemplateSimplifier::cleanupAfterSimplify(), CheckClass::constructors(), CheckClass::copyconstructors(), defaultAccess(), doAssignment(), findFunctionOf(), SymbolDatabase::findVariableType(), Function::isImplicitlyVirtual_rec(), isVariableDeclaration(), CheckNullPointer::nullPointerByCheckAndDeRef(), CheckNullPointer::nullPointerLinkedList(), SymbolDatabase::printVariable(), Scope(), and SymbolDatabase::SymbolDatabase().
| std::list<UsingInfo> Scope::usingList |
Definition at line 525 of file symboldatabase.h.
Referenced by Function::addArguments(), checkVariable(), and SymbolDatabase::SymbolDatabase().
| std::list<Variable> Scope::varlist |
Definition at line 520 of file symboldatabase.h.
Referenced by CheckClass::assignVar(), CheckMemoryLeakInClass::check(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckClass::checkMemsetType(), CheckUninitVar::checkScope(), CheckBufferOverrun::checkStructVariable(), CheckClass::constructors(), getVariable(), CheckClass::initializeVarList(), CheckClass::initVar(), CheckMemoryLeak::isclass(), CheckClass::isMemberVar(), isRecordTypeWithoutSideEffects(), UninitVar::parse(), and SymbolDatabase::SymbolDatabase().
1.7.6.1