Cppcheck
|
Information about a member variable. More...
#include <symboldatabase.h>
Public Member Functions | |
Variable (const Token *name_, const Token *start_, const Token *end_, nonneg int index_, AccessControl access_, const Type *type_, const Scope *scope_, const Settings &settings) | |
Variable (const Token *name_, const std::string &clangType, const Token *typeStart, const Token *typeEnd, nonneg int index_, AccessControl access_, const Type *type_, const Scope *scope_) | |
Variable (const Variable &var, const Scope *scope) | |
Variable (const Variable &var) | |
~Variable () | |
Variable & | operator= (const Variable &var) |
const Token * | nameToken () const |
Get name token. More... | |
const Token * | typeStartToken () const |
Get type start token. More... | |
const Token * | typeEndToken () const |
Get type end token. More... | |
const Token * | declEndToken () const |
Get end token of variable declaration E.g. More... | |
const std::string & | name () const |
Get name string. More... | |
nonneg int | declarationId () const |
Get declaration ID (varId used for variable in its declaration). More... | |
nonneg int | index () const |
Get index of variable in declared order. More... | |
bool | isPublic () const |
Is variable public. More... | |
bool | isProtected () const |
Is variable protected. More... | |
bool | isPrivate () const |
Is variable private. More... | |
bool | isGlobal () const |
Is variable global. More... | |
bool | isNamespace () const |
Is variable in a namespace. More... | |
bool | isArgument () const |
Is variable a function argument. More... | |
bool | isLocal () const |
Is variable local. More... | |
bool | isMember () const |
Is variable a member of a user-defined type. More... | |
bool | isMutable () const |
Is variable mutable. More... | |
bool | isVolatile () const |
Is variable volatile. More... | |
bool | isStatic () const |
Is variable static. More... | |
bool | isExtern () const |
Is variable extern. More... | |
bool | isConst () const |
Is variable const. More... | |
bool | isThrow () const |
Is variable a throw type. More... | |
bool | isClass () const |
Is variable a user defined (or unknown) type. More... | |
bool | isArray () const |
Is variable an array. More... | |
bool | isPointer () const |
Is pointer variable. More... | |
bool | isPointerToArray () const |
Is variable a pointer to an array. More... | |
bool | isPointerArray () const |
Is variable an array of pointers. More... | |
bool | isArrayOrPointer () const |
Is array or pointer variable. More... | |
bool | isReference () const |
Is reference variable. More... | |
bool | isRValueReference () const |
Is reference variable. More... | |
bool | isUnsigned () const |
Is variable unsigned. More... | |
bool | hasDefault () const |
Does variable have a default value. More... | |
bool | isInit () const |
Is variable initialized in its declaration. More... | |
const Type * | type () const |
Get Type pointer of known type. More... | |
const Scope * | typeScope () const |
Get Scope pointer of known type. More... | |
const Scope * | scope () const |
Get Scope pointer of enclosing scope. More... | |
const std::vector< Dimension > & | dimensions () const |
Get array dimensions. More... | |
MathLib::bigint | dimension (nonneg int index_) const |
Get array dimension length. More... | |
bool | dimensionKnown (nonneg int index_) const |
Get array dimension known. More... | |
void | setDimensions (const std::vector< Dimension > &dimensions_) |
bool | isStlType () const |
Checks if the variable is an STL type ('std::') E.g. More... | |
bool | isStlStringType () const |
Checks if the variable is an STL type ('std::') E.g. More... | |
bool | isStlStringViewType () const |
bool | isSmartPointer () const |
const Type * | smartPointerType () const |
const Type * | iteratorType () const |
bool | isStlType (const std::string &stlType) const |
Checks if the variable is of any of the STL types passed as arguments ('std::') E.g. More... | |
bool | isStlType (const std::set< std::string > &stlTypes) const |
Checks if the variable is of any of the STL types passed as arguments ('std::') E.g. More... | |
bool | isFloatingType () const |
Determine whether it's a floating number type. More... | |
bool | isEnumType () const |
Determine whether it's an enumeration type. More... | |
bool | isMaybeUnused () const |
const ValueType * | valueType () const |
void | setValueType (const ValueType &valueType) |
AccessControl | accessControl () const |
std::string | getTypeName () const |
Private Types | |
enum | { fIsMutable = (1 << 0) , fIsStatic = (1 << 1) , fIsConst = (1 << 2) , fIsExtern = (1 << 3) , fIsClass = (1 << 4) , fIsArray = (1 << 5) , fIsPointer = (1 << 6) , fIsReference = (1 << 7) , fIsRValueRef = (1 << 8) , fHasDefault = (1 << 9) , fIsStlType = (1 << 10) , fIsStlString = (1 << 11) , fIsFloatType = (1 << 12) , fIsVolatile = (1 << 13) , fIsSmartPointer = (1 << 14) , fIsMaybeUnused = (1 << 15) , fIsInit = (1 << 16) } |
flags mask used to access specific bit. More... | |
Private Member Functions | |
bool | getFlag (unsigned int flag_) const |
Get specified flag state. More... | |
void | setFlag (unsigned int flag_, bool state_) |
Set specified flag state. More... | |
bool | arrayDimensions (const Settings &settings, bool &isContainer) |
parse and save array dimension information More... | |
void | type (const Type *t) |
Set Type pointer to known type. More... | |
void | evaluate (const Settings &settings) |
fill in information, depending on Tokens given at instantiation More... | |
Private Attributes | |
const Token * | mNameToken |
variable name token More... | |
const Token * | mTypeStartToken |
variable type start token More... | |
const Token * | mTypeEndToken |
variable type end token More... | |
nonneg int | mIndex |
order declared More... | |
AccessControl | mAccess |
what section is this variable declared in? More... | |
unsigned int | mFlags |
flags More... | |
const Type * | mType |
pointer to user defined type info (for known types) More... | |
const Scope * | mScope |
pointer to scope this variable is in More... | |
const ValueType * | mValueType {} |
std::vector< Dimension > | mDimensions |
array dimensions More... | |
Friends | |
class | SymbolDatabase |
Information about a member variable.
Definition at line 165 of file symboldatabase.h.
|
private |
flags mask used to access specific bit.
Definition at line 167 of file symboldatabase.h.
|
inline |
Definition at line 214 of file symboldatabase.h.
References evaluate().
Variable::Variable | ( | const Token * | name_, |
const std::string & | clangType, | ||
const Token * | typeStart, | ||
const Token * | typeEnd, | ||
nonneg int | index_, | ||
AccessControl | access_, | ||
const Type * | type_, | ||
const Scope * | scope_ | ||
) |
Definition at line 2177 of file symboldatabase.cpp.
References fIsArray, fIsInit, fIsReference, fIsRValueRef, fIsStatic, Token::isSplittedVarDeclEq(), Dimension::known, Token::link(), Token::Match(), mDimensions, mNameToken, mTypeEndToken, mTypeStartToken, Token::next(), Dimension::num, Token::previous(), setFlag(), Token::simpleMatch(), Token::str(), MathLib::toBigNumber(), and Dimension::tok.
Definition at line 2234 of file symboldatabase.cpp.
Variable::Variable | ( | const Variable & | var | ) |
Definition at line 2240 of file symboldatabase.cpp.
Variable::~Variable | ( | ) |
Definition at line 2245 of file symboldatabase.cpp.
References mValueType.
|
inline |
Definition at line 647 of file symboldatabase.h.
Referenced by SymbolDatabase::printVariable().
|
private |
parse and save array dimension information
settings | Platform settings and library |
isContainer | Is the array container-like? |
Definition at line 3670 of file symboldatabase.cpp.
References Library::Container::arrayLike_indexOp, Token::astOperand2(), Library::detectContainer(), Token::findsimplematch(), Token::getKnownIntValue(), Token::hasKnownIntValue(), Token::isCpp(), Dimension::known, Settings::library, Token::link(), Token::Match(), mDimensions, mNameToken, mTypeEndToken, mTypeStartToken, Token::next(), Token::nextTemplateArgument(), Dimension::num, Library::Container::size_templateArgNo, Token::str(), MathLib::toBigNumber(), Dimension::tok, and ValueFlow::valueFlowConstantFoldAST().
Referenced by evaluate().
|
inline |
Get declaration ID (varId used for variable in its declaration).
Definition at line 297 of file symboldatabase.h.
Referenced by Variables::addVar(), Variables::alias(), CheckBufferOverrun::arrayIndex(), CheckCondition::assignIf(), bifurcate(), bifurcateVariableChanged(), LifetimeStore::byDerefCopy(), CheckOther::checkConstPointer(), CheckUninitVar::checkExpr(), checkFunctionUsage(), CheckUninitVar::checkIfForWhileHead(), CheckOther::checkInnerScope(), CheckUninitVar::checkLoopBodyRecursive(), CheckStl::checkMutexes(), CheckUninitVar::checkRhs(), CheckUninitVar::checkScope(), CheckUninitVar::checkScopeForVariable(), CheckMemoryLeakStructMember::checkStructVariable(), CheckClass::checkThisUseAfterFree(), CheckAutoVariables::checkVarLifetimeScope(), Variables::clearAliases(), SymbolDatabase::createSymbolDatabaseVariableSymbolTable(), CheckStl::eraseCheckLoopVar(), findVarBound(), followAllReferences(), CheckMemoryLeak::functionReturnType(), getLifetimeTokens(), getUnsafeFunction(), getVariableInitExpression(), isAliased(), CheckMemoryLeakStructMember::isMalloc(), isVariableChanged(), isVariableUsed(), SymbolDatabase::printVariable(), clangimport::Data::Decl::ref(), CheckStl::stlBoundaries(), Token::typeDecl(), valueFlowForwardConst(), valueFlowInjectParameter(), and valueFlowLifetime().
const Token * Variable::declEndToken | ( | ) | const |
Get end token of variable declaration E.g.
int i[2][3] = ... end token ^
Definition at line 2288 of file symboldatabase.cpp.
References Token::link(), Token::Match(), Token::next(), and typeStartToken().
Referenced by bifurcate(), LifetimeStore::byDerefCopy(), evaluate(), followAllReferences(), getLifetimeTokens(), getVariableInitExpression(), CheckFunctions::invalidFunctionUsage(), isAliased(), isEscapedReference(), isVariableChanged(), isVariableDecl(), and Token::typeDecl().
|
inline |
Get array dimension length.
Definition at line 544 of file symboldatabase.h.
Referenced by CheckIO::checkFormatString(), CheckOther::checkIncompleteArrayFill(), CheckIO::invalidScanfFormatWidthError(), SymbolDatabase::printVariable(), and valueFlowSetConstantValue().
|
inline |
Get array dimension known.
Definition at line 552 of file symboldatabase.h.
Referenced by valueFlowSetConstantValue().
|
inline |
Get array dimensions.
Definition at line 536 of file symboldatabase.h.
Referenced by accumulateStructMembers(), CheckBufferOverrun::argumentSize(), CheckIO::checkFormatString(), CheckOther::checkIncompleteArrayFill(), CheckClass::checkMemset(), CheckBufferOverrun::getBufferSize(), CheckUnusedVar::isFunctionWithoutSideEffects(), SymbolDatabase::printVariable(), setValues(), SymbolDatabase::setValueType(), valueFlowSetConstantValue(), and valueFlowUninit().
|
private |
fill in information, depending on Tokens given at instantiation
Definition at line 2299 of file symboldatabase.cpp.
References Argument, arrayDimensions(), declEndToken(), fHasDefault, fIsArray, fIsClass, fIsConst, fIsExtern, fIsFloatType, fIsInit, fIsMaybeUnused, fIsMutable, fIsPointer, fIsReference, fIsRValueRef, fIsSmartPointer, fIsStatic, fIsStlString, fIsStlType, fIsVolatile, isArray(), Token::isAttributeMaybeUnused(), Scope::isClassOrStruct(), Token::isCpp(), isEnumType(), Token::isName(), isPointer(), isReference(), Library::isSmartPointer(), Token::isSplittedVarDeclEq(), Token::isStandardType(), isStlStringType(), Settings::library, Token::link(), mAccess, Token::Match(), mNameToken, mScope, mTypeEndToken, mTypeStartToken, Token::next(), ValueType::parseDecl(), Library::podtype(), Token::previous(), setFlag(), setValueType(), Token::simpleMatch(), Token::str(), and Token::strAt().
|
inlineprivate |
Get specified flag state.
flag_ | flag to get state of |
Definition at line 192 of file symboldatabase.h.
Referenced by isStlStringViewType().
std::string Variable::getTypeName | ( | ) | const |
Definition at line 2472 of file symboldatabase.cpp.
References Token::Match(), mTypeStartToken, and Token::simpleMatch().
Referenced by CheckUnusedVar::checkFunctionVariableUsage(), CheckClass::checkMemset(), CheckClass::constructors(), and CheckStl::string_c_str().
|
inline |
Does variable have a default value.
Definition at line 496 of file symboldatabase.h.
Referenced by CheckUninitVar::checkStruct(), CheckClass::constructors(), SymbolDatabase::createSymbolDatabaseNeedInitialization(), isVariableCopyNeeded(), needsInitialization(), SymbolDatabase::printVariable(), and valueFlowFunctionDefaultParameter().
|
inline |
Get index of variable in declared order.
Definition at line 309 of file symboldatabase.h.
Referenced by SymbolDatabase::printVariable(), and CheckVaarg::va_start_argument().
|
inline |
Is variable a function argument.
Definition at line 358 of file symboldatabase.h.
References Argument.
Referenced by CheckBufferOverrun::arrayIndex(), CheckAssert::assertWithSideEffects(), bifurcate(), CheckBufferOverrun::bufferOverflow(), LifetimeStore::byVal(), CheckOther::checkConstPointer(), CheckSizeof::checkSizeofForArrayParameter(), CheckMemoryLeakStructMember::checkStructVariable(), CheckClass::checkUnsafeClassRefMember(), CheckAutoVariables::checkVarLifetimeScope(), CheckOther::constVariableError(), followAllReferences(), followVariableExpression(), LifetimeStore::fromFunctionArg(), getLifetimeTokens(), getParentLifetime(), getVariableChangedStart(), hasUniqueOwnership(), isArrayArg(), isArrayVar(), isAutoVarArray(), FwdAnalysis::isEscapedAlias(), isInScope(), isLocalVarNoAutoDealloc(), isNonReferenceArg(), isPtrArg(), isRefPtrArg(), ValueFlow::lifetimeMessage(), CheckCondition::multiCondition2(), nonLocal(), ExpressionAnalyzer::nonLocal(), SymbolDatabase::validateVariables(), valueFlowAfterMove(), valueFlowArrayBool(), valueFlowLifetime(), valueFlowLifetimeFunction(), valueFlowLifetimeUserConstructor(), and valueFlowSwitchVariable().
|
inline |
Is variable an array.
Definition at line 436 of file symboldatabase.h.
Referenced by CheckBufferOverrun::argumentSize(), CheckIO::argumentType(), CheckOther::checkConstPointer(), CheckIO::checkFormatString(), CheckOther::checkIncompleteArrayFill(), CheckOther::checkInnerScope(), CheckClass::checkMemset(), CheckClass::checkMemsetType(), CheckUninitVar::checkScope(), CheckUninitVar::checkScopeForVariable(), CheckSizeof::checkSizeofForArrayParameter(), CheckSizeof::checkSizeofForPointerSize(), CheckUninitVar::checkStruct(), CheckOther::constVariableError(), evaluate(), hasUniqueOwnership(), CheckFunctions::invalidFunctionUsage(), isArrayArg(), isArrayVar(), isAutoVarArray(), isChar(), CheckUnusedVar::isFunctionWithoutSideEffects(), isPointerArray(), CheckNullPointer::isPointerDeRef(), isUniqueExpression(), isVariableUsed(), ValueType::matchParameter(), CheckNullPointer::nullConstantDereference(), CheckBufferOverrun::objectIndex(), CheckPostfixOperator::postfixOperator(), SymbolDatabase::printVariable(), SymbolDatabase::printXml(), setValueType(), CheckSizeof::suspiciousSizeofCalculation(), valueFlowArrayBool(), valueFlowLifetime(), and valueFlowUninit().
|
inline |
Is array or pointer variable.
Definition at line 466 of file symboldatabase.h.
Referenced by CheckClass::checkConstFunc(), CheckOther::checkInnerScope(), CheckClass::checkMemset(), CheckMemoryLeakStructMember::checkStructVariable(), checkVariableCallMatch(), getUnsafeFunction(), and CheckNullPointer::parseFunctionCall().
|
inline |
Is variable a user defined (or unknown) type.
Definition at line 428 of file symboldatabase.h.
Referenced by CheckExceptionSafety::checkCatchExceptionByValue(), CheckUnusedVar::checkFunctionVariableUsage(), CheckUninitVar::checkStruct(), CheckClass::constructors(), SymbolDatabase::createSymbolDatabaseNeedInitialization(), isUniqueExpression(), isVariableMutableInInitializer(), isWithoutSideEffects(), SymbolDatabase::printVariable(), SymbolDatabase::printXml(), and valueFlowInjectParameter().
|
inline |
Is variable const.
Definition at line 412 of file symboldatabase.h.
Referenced by bifurcate(), CheckClass::checkConstFunc(), CheckOther::checkConstVariable(), CheckClass::checkMemsetType(), CheckClass::checkUnsafeClassRefMember(), CheckAssert::checkVariableAssignment(), CheckClass::constructors(), followAllReferences(), followVariableExpression(), getLifetimeTokens(), CheckFunctions::invalidFunctionUsage(), isConstFunctionCall(), isContainerSizeChangedByFunction(), isParameterChanged(), isVariableChanged(), isVariableMutableInInitializer(), SymbolDatabase::printVariable(), SymbolDatabase::printXml(), CheckStl::string_c_str(), valueFlowInjectParameter(), valueFlowLifetimeFunction(), valueFlowLifetimeUserConstructor(), and valueFlowSwitchVariable().
|
inline |
Determine whether it's an enumeration type.
Definition at line 633 of file symboldatabase.h.
Referenced by CheckIO::ArgumentInfo::ArgumentInfo(), evaluate(), CheckClass::initializationListUsage(), isUniqueExpression(), and valueFlowSetConstantValue().
|
inline |
Is variable extern.
Definition at line 404 of file symboldatabase.h.
Referenced by CheckUninitVar::checkScope(), isDeadScope(), isInScope(), nonLocal(), ExpressionAnalyzer::nonLocal(), SymbolDatabase::printVariable(), SymbolDatabase::printXml(), and valueFlowUninit().
|
inline |
Determine whether it's a floating number type.
Definition at line 625 of file symboldatabase.h.
Referenced by CheckClass::checkMemsetType(), and isUniqueExpression().
|
inline |
Is variable global.
Definition at line 341 of file symboldatabase.h.
References Global.
Referenced by bifurcateVariableChanged(), CheckIO::checkFileUsage(), CheckStl::checkMutexes(), CheckAutoVariables::checkVarLifetimeScope(), CheckExceptionSafety::deallocThrow(), CheckAutoVariables::errorInvalidDeallocation(), getLifetimeTokens(), CheckFunctions::invalidFunctionUsage(), CheckUnusedVar::isFunctionWithoutSideEffects(), isInScope(), and ValueFlow::lifetimeMessage().
|
inline |
Is variable initialized in its declaration.
Definition at line 504 of file symboldatabase.h.
Referenced by CheckOther::checkInnerScope(), CheckClass::constructors(), and valueFlowUninit().
|
inline |
Is variable local.
Definition at line 366 of file symboldatabase.h.
References Local.
Referenced by CheckAssert::assertWithSideEffects(), CheckCondition::assignIf(), CheckOther::checkConstPointer(), CheckIO::checkFileUsage(), CheckAutoVariables::checkVarLifetimeScope(), followVariableExpression(), CheckMemoryLeak::functionReturnType(), getParentLifetime(), CheckFunctions::invalidFunctionUsage(), isAssignedToNonLocal(), isAutoVar(), isAutoVarArray(), isDanglingSubFunction(), isDeadScope(), FwdAnalysis::isEscapedAlias(), isIterator(), isLocal(), isLocalContainerBuffer(), isLocalVarNoAutoDealloc(), isVariableChanged(), ValueFlow::lifetimeMessage(), CheckCondition::multiCondition2(), nonLocal(), ExpressionAnalyzer::nonLocal(), SymbolDatabase::printVariable(), ExpressionAnalyzer::setupExprVarIds(), valueFlowAfterMove(), valueFlowForLoopSimplifyAfter(), valueFlowLifetime(), valueFlowSwitchVariable(), and valueFlowUninit().
|
inline |
Definition at line 637 of file symboldatabase.h.
Referenced by CheckUnusedVar::checkFunctionVariableUsage().
bool Variable::isMember | ( | ) | const |
Is variable a member of a user-defined type.
Definition at line 2274 of file symboldatabase.cpp.
References Scope::isClassOrStructOrUnion(), and mScope.
|
inline |
Is variable mutable.
Definition at line 380 of file symboldatabase.h.
Referenced by CheckClass::checkConstFunc(), and SymbolDatabase::printVariable().
|
inline |
Is variable in a namespace.
Definition at line 350 of file symboldatabase.h.
References Namespace.
|
inline |
Is pointer variable.
Definition at line 444 of file symboldatabase.h.
Referenced by CheckAssert::assertWithSideEffects(), bifurcateVariableChanged(), CheckBufferOverrun::bufferOverflow(), CheckMemoryLeakInClass::check(), CheckExceptionSafety::checkCatchExceptionByValue(), CheckUninitVar::checkExpr(), CheckUninitVar::checkIfForWhileHead(), CheckOther::checkIncompleteArrayFill(), CheckOther::checkInnerScope(), CheckUninitVar::checkLoopBodyRecursive(), CheckClass::checkMemset(), CheckClass::checkMemsetType(), checkNullpointerFunctionCallPlausibility(), CheckOther::checkRedundantPointerOp(), CheckUninitVar::checkRhs(), CheckUninitVar::checkScope(), CheckUninitVar::checkScopeForVariable(), CheckSizeof::checkSizeofForPointerSize(), CheckUnusedVar::checkStructMemberUsage(), CheckClass::constructors(), CheckOther::constVariableError(), CheckClass::copyconstructors(), SymbolDatabase::createSymbolDatabaseCopyAndMoveConstructors(), evaluate(), Scope::findFunction(), CheckBufferOverrun::getBufferSize(), CheckClass::initializationListUsage(), CheckClass::initializerListOrder(), isAliasOf(), isAutoVarArray(), isCallFunction(), isChar(), CheckUnusedVar::isFunctionWithoutSideEffects(), isLocalVarNoAutoDealloc(), isNonReferenceArg(), isParameterChanged(), CheckNullPointer::isPointerDeRef(), isPtrArg(), isRefPtrArg(), isUniqueExpression(), isVariableChanged(), isVariableCopyNeeded(), isWithoutSideEffects(), CheckCondition::multiCondition2(), needsInitialization(), nonLocal(), ExpressionAnalyzer::nonLocal(), CheckNullPointer::nullConstantDereference(), CheckBufferOverrun::objectIndex(), CheckPostfixOperator::postfixOperator(), SymbolDatabase::printVariable(), SymbolDatabase::printXml(), CheckStl::string_c_str(), CheckSizeof::suspiciousSizeofCalculation(), and valueFlowUninit().
bool Variable::isPointerArray | ( | ) | const |
Is variable an array of pointers.
Definition at line 2278 of file symboldatabase.cpp.
References isArray(), nameToken(), Token::previous(), and Token::str().
Referenced by CheckMemoryLeakInClass::check(), CheckClass::constructors(), and CheckBufferOverrun::getBufferSize().
|
inline |
Is variable a pointer to an array.
Definition at line 452 of file symboldatabase.h.
Referenced by CheckUninitVar::checkScope().
|
inline |
Is variable private.
Definition at line 333 of file symboldatabase.h.
References Private.
Referenced by CheckMemoryLeakInClass::check(), CheckUnusedVar::checkStructMemberUsage(), CheckClass::constructors(), exprDependsOnThis(), and getDuplInheritedMembersRecursive().
|
inline |
Is variable protected.
Definition at line 325 of file symboldatabase.h.
References Protected.
Referenced by exprDependsOnThis().
|
inline |
Is variable public.
Definition at line 317 of file symboldatabase.h.
References Public.
Referenced by exprDependsOnThis(), and valueFlowUninit().
|
inline |
Is reference variable.
Definition at line 474 of file symboldatabase.h.
Referenced by CheckAssert::assertWithSideEffects(), CheckBufferOverrun::bufferOverflow(), CheckExceptionSafety::checkCatchExceptionByValue(), CheckOther::checkComparePointers(), CheckClass::checkConstFunc(), CheckOther::checkConstVariable(), CheckUnusedVar::checkFunctionVariableUsage(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckClass::checkMemsetType(), CheckUninitVar::checkScope(), CheckSizeof::checkSizeofForArrayParameter(), CheckClass::checkUnsafeClassRefMember(), CheckAutoVariables::checkVarLifetimeScope(), CheckOther::constVariableError(), SymbolDatabase::createSymbolDatabaseCopyAndMoveConstructors(), SymbolDatabase::createSymbolDatabaseNeedInitialization(), evaluate(), followAllReferences(), getLifetimeTokens(), getUnsafeFunction(), CheckClass::initializationListUsage(), CheckClass::initializerListOrder(), isAutoVar(), isContainerSizeChangedByFunction(), isEscapedReference(), isInScope(), isLocalMutex(), isLocalVarNoAutoDealloc(), isNonReferenceArg(), isParameterChanged(), isRefPtrArg(), isVariableChanged(), isVariableMutableInInitializer(), CheckUninitVar::isVariableUsage(), isWithoutSideEffects(), CheckCondition::multiCondition2(), nonLocal(), ExpressionAnalyzer::nonLocal(), CheckBufferOverrun::objectIndex(), SymbolDatabase::printVariable(), SymbolDatabase::printXml(), CheckLeakAutoVar::ret(), ExpressionAnalyzer::setupExprVarIds(), CheckStl::string_c_str(), CheckVaarg::va_start_argument(), valueFlowInjectParameter(), valueFlowLifetimeClassConstructor(), valueFlowLifetimeFunction(), valueFlowLifetimeUserConstructor(), and valueFlowUninit().
|
inline |
Is reference variable.
Definition at line 482 of file symboldatabase.h.
Referenced by CheckOther::checkComparePointers(), CheckAutoVariables::checkVarLifetimeScope(), SymbolDatabase::createSymbolDatabaseCopyAndMoveConstructors(), followAllReferences(), getLifetimeTokens(), isLocalMutex(), CheckBufferOverrun::objectIndex(), SymbolDatabase::printVariable(), valueFlowLifetimeClassConstructor(), valueFlowLifetimeFunction(), and valueFlowLifetimeUserConstructor().
|
inline |
Definition at line 586 of file symboldatabase.h.
Referenced by CheckClass::checkConstFunc(), Scope::findFunction(), smartPointerType(), and valueFlowSmartPointer().
|
inline |
Is variable static.
Definition at line 396 of file symboldatabase.h.
Referenced by accumulateStructMembers(), CheckMemoryLeakInClass::check(), CheckOther::checkConstPointer(), CheckIO::checkFileUsage(), checkFunctionUsage(), CheckUnusedVar::checkFunctionVariableUsage(), CheckClass::checkMemsetType(), CheckStl::checkMutexes(), CheckUninitVar::checkScope(), CheckUninitVar::checkStruct(), CheckClass::checkThisUseAfterFree(), CheckAutoVariables::checkVarLifetimeScope(), CheckClass::constructors(), CheckClass::copyconstructors(), SymbolDatabase::createSymbolDatabaseNeedInitialization(), CheckExceptionSafety::deallocThrow(), CheckAutoVariables::errorInvalidDeallocation(), exprDependsOnThis(), followVariableExpression(), CheckMemoryLeak::functionReturnType(), getLifetimeTokens(), CheckClass::initializationListUsage(), isAssignedToNonLocal(), isAutoVar(), isAutoVarArray(), isDeadScope(), isInScope(), isLocal(), isLocalContainerBuffer(), isLocalMutex(), isLocalVarNoAutoDealloc(), CheckClass::isMemberVar(), Variables::modified(), nonLocal(), ExpressionAnalyzer::nonLocal(), SymbolDatabase::printVariable(), SymbolDatabase::printXml(), valueFlowUninit(), and Variables::write().
|
inline |
Checks if the variable is an STL type ('std::') E.g.
: std::string s; ... sVar->isStlType() == true
Definition at line 580 of file symboldatabase.h.
Referenced by checkVariableCallMatch(), evaluate(), Scope::findFunction(), CheckNullPointer::isPointerDeRef(), CheckNullPointer::nullConstantDereference(), CheckNullPointer::parseFunctionCall(), and CheckStl::string_c_str().
bool Variable::isStlStringViewType | ( | ) | const |
Definition at line 2467 of file symboldatabase.cpp.
References ValueType::container, fIsStlType, getFlag(), Library::Container::stdStringLike, valueType(), and Library::Container::view.
Referenced by CheckStl::string_c_str().
|
inline |
Checks if the variable is an STL type ('std::') E.g.
: std::string s; ... sVar->isStlType() == true
Definition at line 568 of file symboldatabase.h.
Referenced by CheckClass::checkConstFunc(), CheckUnusedVar::checkFunctionVariableUsage(), CheckClass::checkMemsetType(), CheckUninitVar::checkScope(), CheckClass::constructors(), isCpp03ContainerSizeSlow(), CheckNullPointer::isPointerDeRef(), CheckIO::ArgumentInfo::isStdContainer(), isWithoutSideEffects(), ValueType::matchParameter(), CheckNullPointer::nullConstantDereference(), SymbolDatabase::printVariable(), CheckStl::string_c_str(), CheckStl::uselessCalls(), valueFlowArrayBool(), and valueFlowLifetime().
|
inline |
Checks if the variable is of any of the STL types passed as arguments ('std::') E.g.
: std::string s; ... const std::set<std::string> str = make_container< std::set<std::string> >() << "string" << "wstring"; sVar->isStlType(str) == true
stlTypes | set of stl types |
Definition at line 617 of file symboldatabase.h.
|
inline |
Checks if the variable is of any of the STL types passed as arguments ('std::') E.g.
: std::string s; ... const char *str[] = {"string", "wstring"}; sVar->isStlType(str) == true
stlType | stl type |
Definition at line 603 of file symboldatabase.h.
|
inline |
Is variable a throw type.
Definition at line 420 of file symboldatabase.h.
References Throw.
Referenced by CheckUninitVar::checkScope(), and valueFlowUninit().
bool Variable::isUnsigned | ( | ) | const |
Is variable unsigned.
Definition at line 2283 of file symboldatabase.cpp.
References Token::isUnsigned(), mTypeStartToken, mValueType, and ValueType::sign.
|
inline |
Is variable volatile.
Definition at line 388 of file symboldatabase.h.
Referenced by followVariableExpression(), and SymbolDatabase::printXml().
const Type * Variable::iteratorType | ( | ) | const |
Definition at line 2456 of file symboldatabase.cpp.
References ValueType::containerTypeToken, ValueType::ITERATOR, mValueType, ValueType::type, and Token::type().
Referenced by SymbolDatabase::createSymbolDatabaseSetVariablePointers(), and SymbolDatabase::findFunction().
|
inline |
Get name string.
Definition at line 285 of file symboldatabase.h.
References emptyString.
Referenced by CheckBufferOverrun::argumentSizeError(), CheckUnusedVar::checkFunctionVariableUsage(), CheckOther::checkRedundantPointerOp(), CheckUninitVar::checkScopeForVariable(), CheckOther::checkShadowVariables(), CheckUninitVar::checkStruct(), CheckUnusedVar::checkStructMemberUsage(), CheckMemoryLeakStructMember::checkStructVariable(), CheckClass::checkUnsafeClassRefMember(), CheckAssert::checkVariableAssignment(), CheckClass::constructors(), CheckOther::constVariableError(), CheckAutoVariables::errorDanglingReference(), findShadowed(), getDuplInheritedMembersRecursive(), CheckIO::invalidScanfFormatWidthError(), CheckClass::isMemberVar(), isUniqueExpression(), ValueFlow::lifetimeMessage(), CheckOther::passedByValueError(), CheckLeakAutoVar::ret(), CheckClass::returnByReferenceError(), CheckVaarg::va_start_argument(), valueFlowForLoopSimplifyAfter(), valueFlowSafeFunctions(), and valueFlowSwitchVariable().
|
inline |
Get name token.
Definition at line 244 of file symboldatabase.h.
Referenced by accumulateStructMembers(), CheckBufferOverrun::argumentSize(), CheckBufferOverrun::argumentSizeError(), CheckMemoryLeakInClass::check(), CheckClass::checkConstFunc(), CheckOther::checkConstPointer(), CheckOther::checkConstVariable(), CheckOther::checkFuncArgNamesDifferent(), CheckUnusedVar::checkFunctionVariableUsage(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckOther::checkInnerScope(), CheckUninitVar::checkRhs(), CheckUninitVar::checkScope(), CheckUninitVar::checkScopeForVariable(), CheckOther::checkShadowVariables(), CheckUnusedVar::checkStructMemberUsage(), CheckMemoryLeakStructMember::checkStructVariable(), CheckClass::checkThisUseAfterFreeRecursive(), CheckOther::checkVariableScope(), CheckAutoVariables::checkVarLifetimeScope(), CheckClass::constructors(), CheckOther::constVariableError(), SymbolDatabase::createSymbolDatabaseExprIds(), SymbolDatabase::createSymbolDatabaseVariableSymbolTable(), CheckStl::eraseCheckLoopVar(), findShadowed(), findStartToken(), findVarBound(), SymbolDatabase::fixVarId(), followAllReferences(), getLifetimeTokens(), MultiValueFlowAnalyzer::getProgramState(), getVariableChangedStart(), isContainerSizeChangedByFunction(), isExpression(), isIterator(), isLockGuard(), CheckMemoryLeakStructMember::isMalloc(), isMutex(), isPointerArray(), isStructuredBindingVariable(), isVariableChanged(), isVariableDecl(), CheckUninitVar::isVariableUsage(), ValueFlow::lifetimeMessage(), needsInitialization(), CheckStl::negativeIndex(), CheckOther::passedByValueError(), CheckPostfixOperator::postfixOperator(), SymbolDatabase::printVariable(), SymbolDatabase::printXml(), ExpressionAnalyzer::setupExprVarIds(), SymbolDatabase::setValueType(), skipLocalVars(), CheckStl::stlBoundaries(), Token::typeDecl(), SymbolDatabase::validateVariables(), valueFlowForwardAssign(), valueFlowForwardConst(), valueFlowFunctionDefaultParameter(), valueFlowFunctionReturn(), valueFlowInjectParameter(), valueFlowLifetime(), valueFlowSafeFunctions(), valueFlowSmartPointer(), and valueFlowUninit().
Definition at line 2250 of file symboldatabase.cpp.
References mAccess, mDimensions, mFlags, mIndex, mNameToken, mScope, mType, mTypeEndToken, mTypeStartToken, mValueType, and ValueType.
|
inline |
Get Scope pointer of enclosing scope.
Definition at line 528 of file symboldatabase.h.
Referenced by CheckBufferOverrun::arrayIndex(), CheckMemoryLeakStructMember::checkStructVariable(), CheckAssert::checkVariableAssignment(), CheckClass::constructors(), CheckClass::copyconstructors(), doAssignment(), findAllUsages(), findStartToken(), followVariableExpression(), getEndOfVarScope(), getVariableChangedStart(), CheckClass::initializationListUsage(), isAliased(), isArrayArg(), isLocalMutex(), CheckMemoryLeakStructMember::isMalloc(), isSimpleExpr(), isUniqueExpression(), isVariableChanged(), isWithinScope(), ValueType::matchParameter(), CheckOther::passedByValueError(), SymbolDatabase::printVariable(), SymbolDatabase::printXml(), CheckLeakAutoVar::ret(), skipLocalVars(), smartPointerType(), CheckStl::stlBoundaries(), SymbolDatabase::validateVariables(), valueFlowAfterMove(), valueFlowForLoopSimplifyAfter(), valueFlowForwardLifetime(), valueFlowLifetime(), and Variable().
|
inline |
Definition at line 556 of file symboldatabase.h.
|
inlineprivate |
Set specified flag state.
flag_ | flag to set state |
state_ | new state of flag |
Definition at line 201 of file symboldatabase.h.
Referenced by evaluate(), setValueType(), and Variable().
void Variable::setValueType | ( | const ValueType & | valueType | ) |
Definition at line 2413 of file symboldatabase.cpp.
References ValueType::constness, Token::findsimplematch(), fIsConst, fIsPointer, fIsSmartPointer, fIsVolatile, isArray(), Token::Match(), mNameToken, mTypeEndToken, mTypeStartToken, mValueType, Token::next(), ValueType::pointer, Token::previous(), setFlag(), ValueType::smartPointerType, ValueType::type, valueType(), ValueType, Token::valueType(), and ValueType::volatileness.
Referenced by SymbolDatabase::createSymbolDatabaseSetSmartPointerType(), evaluate(), SymbolDatabase::setValueType(), and clangimport::Data::varDecl().
const Type * Variable::smartPointerType | ( | ) | const |
Definition at line 2431 of file symboldatabase.cpp.
References Scope::findType(), isSmartPointer(), Token::Match(), mValueType, Scope::nestedIn, Token::next(), scope(), Token::scope(), ValueType::smartPointerType, Token::str(), and typeStartToken().
Referenced by CheckClass::checkConstFunc(), SymbolDatabase::createSymbolDatabaseSetVariablePointers(), SymbolDatabase::findFunction(), and SymbolDatabase::setValueType().
|
inline |
Get Type pointer of known type.
Definition at line 512 of file symboldatabase.h.
Referenced by CheckIO::ArgumentInfo::ArgumentInfo(), CheckMemoryLeakInClass::check(), CheckClass::checkCopyCtorAndEqOperator(), CheckUnusedVar::checkFunctionVariableUsage(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckUninitVar::checkScope(), CheckUninitVar::checkScopeForVariable(), CheckUninitVar::checkStruct(), CheckUnusedVar::checkStructMemberUsage(), CheckClass::constructors(), CheckClass::copyconstructors(), SymbolDatabase::createSymbolDatabaseCopyAndMoveConstructors(), SymbolDatabase::createSymbolDatabaseNeedInitialization(), SymbolDatabase::createSymbolDatabaseVariableSymbolTable(), Scope::findFunction(), isAutoDealloc(), isIterator(), isNonReferenceArg(), CheckIO::ArgumentInfo::isStdContainer(), isUniqueExpression(), isVariableCopyNeeded(), CheckUnusedVar::isVariableWithoutSideEffects(), needsInitialization(), CheckPostfixOperator::postfixOperator(), SymbolDatabase::printVariable(), SymbolDatabase::setValueType(), and valueFlowSetConstantValue().
|
inlineprivate |
|
inline |
Get type end token.
The type end token doesn't account the forward 'const' qualifier E.g.: static const int * const p = ...; type end token ^
Definition at line 268 of file symboldatabase.h.
Referenced by CheckOther::checkCastIntToCharAndBack(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckClass::checkMemset(), CheckClass::checkMemsetType(), isBool(), isIterator(), SymbolDatabase::printVariable(), SymbolDatabase::printXml(), Token::typeDecl(), CheckStl::uselessCalls(), and valueFlowSetConstantValue().
|
inline |
Get Scope pointer of known type.
Definition at line 520 of file symboldatabase.h.
Referenced by CheckClass::checkConstFunc(), CheckClass::checkMemset(), CheckClass::checkMemsetType(), CheckOther::checkOverlappingWrite(), CheckUninitVar::checkScopeForVariable(), CheckMemoryLeakStructMember::checkStructVariable(), CheckClass::constructors(), CheckClass::copyconstructors(), SymbolDatabase::createSymbolDatabaseSetVariablePointers(), SymbolDatabase::createSymbolDatabaseVariableSymbolTable(), SymbolDatabase::findFunction(), SymbolDatabase::setValueType(), and valueFlowUninit().
|
inline |
Get type start token.
The type start token doesn't account 'static' and 'const' qualifiers E.g.: static const int * const p = ...; type start token ^
Definition at line 256 of file symboldatabase.h.
Referenced by CheckIO::ArgumentInfo::ArgumentInfo(), CheckMemoryLeakInClass::check(), CheckOther::checkConstPointer(), CheckOther::checkIncompleteArrayFill(), CheckClass::checkMemset(), CheckClass::checkMemsetType(), CheckUninitVar::checkScope(), CheckUninitVar::checkScopeForVariable(), CheckUninitVar::checkStruct(), CheckUnusedVar::checkStructMemberUsage(), CheckClass::checkThisUseAfterFree(), checkVariableCallMatch(), SymbolDatabase::createSymbolDatabaseVariableSymbolTable(), declEndToken(), Scope::findFunction(), getEndOfVarScope(), isChar(), CheckUninitVar::isFunctionParUsage(), isLocalVarNoAutoDealloc(), CheckUninitVar::isMemberVariableAssignment(), CheckNullPointer::isPointerDeRef(), CheckIO::ArgumentInfo::isStdContainer(), CheckUnusedVar::isVariableWithoutSideEffects(), isVector(), CheckStl::iterators(), ValueType::matchParameter(), CheckStl::negativeIndex(), SymbolDatabase::printVariable(), SymbolDatabase::printXml(), SymbolDatabase::setValueType(), smartPointerType(), CheckStl::stlBoundaries(), Token::typeDecl(), CheckStl::uselessCalls(), and valueFlowSetConstantValue().
|
inline |
Definition at line 641 of file symboldatabase.h.
Referenced by accumulateStructMembers(), CheckBufferOverrun::argumentSize(), CheckClass::checkConstFunc(), CheckOther::checkConstPointer(), CheckMemoryLeakNoVar::checkForUnreleasedInputArgument(), CheckUnusedVar::checkFunctionVariableUsage(), CheckOther::checkIncompleteArrayFill(), CheckOther::checkInnerScope(), CheckUninitVar::checkScope(), CheckMemoryLeakStructMember::checkStructVariable(), CheckClass::checkThisUseAfterFree(), checkVariableCallMatch(), CheckClass::constructors(), SymbolDatabase::createSymbolDatabaseNeedInitialization(), SymbolDatabase::createSymbolDatabaseSetSmartPointerType(), SymbolDatabase::findFunction(), Scope::findFunction(), followVariableExpression(), CTU::getFileInfo(), getUnsafeFunction(), CheckClass::initializationListUsage(), isAutoDealloc(), isContainerSizeChangedByFunction(), isNonReferenceArg(), isStlStringViewType(), isVariableCopyNeeded(), CheckUnusedVar::isVariableWithoutSideEffects(), ValueType::matchParameter(), needsInitialization(), CheckBufferOverrun::objectIndex(), SymbolDatabase::printVariable(), SymbolDatabase::printXml(), setValues(), setValueType(), SymbolDatabase::setValueType(), CheckSizeof::suspiciousSizeofCalculation(), Token::typeDecl(), valueFlowSafeFunctions(), and valueFlowSetConstantValue().
|
friend |
Definition at line 655 of file symboldatabase.h.
|
private |
what section is this variable declared in?
Definition at line 678 of file symboldatabase.h.
Referenced by evaluate(), operator=(), and SymbolDatabase::printXml().
|
private |
array dimensions
Definition at line 692 of file symboldatabase.h.
Referenced by arrayDimensions(), operator=(), and Variable().
|
private |
|
private |
|
private |
variable name token
Definition at line 666 of file symboldatabase.h.
Referenced by arrayDimensions(), evaluate(), operator=(), setValueType(), and Variable().
|
private |
pointer to scope this variable is in
Definition at line 687 of file symboldatabase.h.
Referenced by evaluate(), isMember(), operator=(), and Variable().
|
private |
pointer to user defined type info (for known types)
Definition at line 684 of file symboldatabase.h.
Referenced by operator=().
|
private |
variable type end token
Definition at line 672 of file symboldatabase.h.
Referenced by arrayDimensions(), evaluate(), operator=(), setValueType(), and Variable().
|
private |
variable type start token
Definition at line 669 of file symboldatabase.h.
Referenced by arrayDimensions(), evaluate(), getTypeName(), isUnsigned(), operator=(), setValueType(), and Variable().
|
private |
Definition at line 689 of file symboldatabase.h.
Referenced by isUnsigned(), iteratorType(), operator=(), setValueType(), smartPointerType(), and ~Variable().