Cppcheck
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ValueType Class Reference

Value type. More...

#include <symboldatabase.h>

Public Types

enum  Sign { UNKNOWN_SIGN , SIGNED , UNSIGNED }
 
enum  Type {
  UNKNOWN_TYPE , POD , NONSTD , RECORD ,
  SMART_POINTER , CONTAINER , ITERATOR , VOID ,
  BOOL , CHAR , SHORT , WCHAR_T ,
  INT , LONG , LONGLONG , UNKNOWN_INT ,
  FLOAT , DOUBLE , LONGDOUBLE
}
 
enum class  MatchResult {
  UNKNOWN , SAME , FALLBACK1 , FALLBACK2 ,
  NOMATCH
}
 

Public Member Functions

 ValueType ()=default
 
 ValueType (Sign s, Type t, nonneg int p)
 
 ValueType (Sign s, Type t, nonneg int p, nonneg int c)
 
 ValueType (Sign s, Type t, nonneg int p, nonneg int c, nonneg int v)
 
 ValueType (Sign s, Type t, nonneg int p, nonneg int c, std::string otn)
 
bool isPrimitive () const
 
bool isIntegral () const
 
bool isFloat () const
 
bool fromLibraryType (const std::string &typestr, const Settings &settings)
 
bool isEnum () const
 
bool isConst (nonneg int indirect=0) const
 
bool isVolatile (nonneg int indirect=0) const
 
MathLib::bigint typeSize (const Platform &platform, bool p=false) const
 
bool isTypeEqual (const ValueType *that) const
 Check if type is the same ignoring const and references. More...
 
std::string str () const
 
std::string dump () const
 
void setDebugPath (const Token *tok, SourceLocation ctx, const SourceLocation &local=SourceLocation::current())
 

Static Public Member Functions

static ValueType parseDecl (const Token *type, const Settings &settings)
 
static Type typeFromString (const std::string &typestr, bool longType)
 
static MatchResult matchParameter (const ValueType *call, const ValueType *func)
 
static MatchResult matchParameter (const ValueType *call, const Variable *callVar, const Variable *funcVar)
 

Public Attributes

enum ValueType::Sign sign = UNKNOWN_SIGN
 
enum ValueType::Type type = UNKNOWN_TYPE
 
nonneg int bits {}
 bitfield bitcount More...
 
nonneg int pointer {}
 0=>not pointer, 1=>*, 2=>**, 3=>***, etc More...
 
nonneg int constness {}
 bit 0=data, bit 1=*, bit 2=** More...
 
nonneg int volatileness {}
 bit 0=data, bit 1=*, bit 2=** More...
 
Reference reference = Reference::None
 Is the outermost indirection of this type a reference or rvalue. More...
 
const ScopetypeScope {}
 if the type definition is seen this point out the type scope More...
 
const ::TypesmartPointerType {}
 Smart pointer type. More...
 
const TokensmartPointerTypeToken {}
 Smart pointer type token. More...
 
const Library::SmartPointersmartPointer {}
 Smart pointer. More...
 
const Library::Containercontainer {}
 If the type is a container defined in a cfg file, this is the used. More...
 
const TokencontainerTypeToken {}
 The container type token. More...
 
std::string originalTypeName
 original type name as written in the source code. More...
 
ErrorPath debugPath
 debug path to the type More...
 

Detailed Description

Value type.

Definition at line 1208 of file symboldatabase.h.

Member Enumeration Documentation

◆ MatchResult

Enumerator
UNKNOWN 
SAME 
FALLBACK1 
FALLBACK2 
NOMATCH 

Definition at line 1281 of file symboldatabase.h.

◆ Sign

Enumerator
UNKNOWN_SIGN 
SIGNED 
UNSIGNED 

Definition at line 1210 of file symboldatabase.h.

◆ Type

Enumerator
UNKNOWN_TYPE 
POD 
NONSTD 
RECORD 
SMART_POINTER 
CONTAINER 
ITERATOR 
VOID 
BOOL 
CHAR 
SHORT 
WCHAR_T 
INT 
LONG 
LONGLONG 
UNKNOWN_INT 
FLOAT 
DOUBLE 
LONGDOUBLE 

Definition at line 1211 of file symboldatabase.h.

Constructor & Destructor Documentation

◆ ValueType() [1/5]

ValueType::ValueType ( )
default

◆ ValueType() [2/5]

ValueType::ValueType ( Sign  s,
Type  t,
nonneg int  p 
)
inline

Definition at line 1251 of file symboldatabase.h.

◆ ValueType() [3/5]

ValueType::ValueType ( Sign  s,
Type  t,
nonneg int  p,
nonneg int  c 
)
inline

Definition at line 1256 of file symboldatabase.h.

◆ ValueType() [4/5]

ValueType::ValueType ( Sign  s,
Type  t,
nonneg int  p,
nonneg int  c,
nonneg int  v 
)
inline

Definition at line 1262 of file symboldatabase.h.

◆ ValueType() [5/5]

ValueType::ValueType ( Sign  s,
Type  t,
nonneg int  p,
nonneg int  c,
std::string  otn 
)
inline

Definition at line 1269 of file symboldatabase.h.

Member Function Documentation

◆ dump()

std::string ValueType::dump ( ) const

◆ fromLibraryType()

bool ValueType::fromLibraryType ( const std::string &  typestr,
const Settings settings 
)

◆ isConst()

bool ValueType::isConst ( nonneg int  indirect = 0) const

◆ isEnum()

bool ValueType::isEnum ( ) const
inline

Definition at line 1299 of file symboldatabase.h.

References Scope::eEnum.

Referenced by CheckOther::clarifyCalculation(), and matchParameter().

◆ isFloat()

bool ValueType::isFloat ( ) const
inline

◆ isIntegral()

bool ValueType::isIntegral ( ) const
inline

◆ isPrimitive()

bool ValueType::isPrimitive ( ) const
inline

◆ isTypeEqual()

bool ValueType::isTypeEqual ( const ValueType that) const

Check if type is the same ignoring const and references.

Definition at line 8049 of file symboldatabase.cpp.

Referenced by CheckCondition::checkCompareValueOutOfTypeRange(), SymbolDatabase::setValueType(), and valueFlowIsSameContainerType().

◆ isVolatile()

bool ValueType::isVolatile ( nonneg int  indirect = 0) const

Definition at line 8006 of file symboldatabase.cpp.

References pointer, and volatileness.

◆ matchParameter() [1/2]

ValueType::MatchResult ValueType::matchParameter ( const ValueType call,
const ValueType func 
)
static

◆ matchParameter() [2/2]

ValueType::MatchResult ValueType::matchParameter ( const ValueType call,
const Variable callVar,
const Variable funcVar 
)
static

◆ parseDecl()

ValueType ValueType::parseDecl ( const Token type,
const Settings settings 
)
static

◆ setDebugPath()

void ValueType::setDebugPath ( const Token tok,
SourceLocation  ctx,
const SourceLocation local = SourceLocation::current() 
)

◆ str()

std::string ValueType::str ( ) const

◆ typeFromString()

ValueType::Type ValueType::typeFromString ( const std::string &  typestr,
bool  longType 
)
static

◆ typeSize()

MathLib::bigint ValueType::typeSize ( const Platform platform,
bool  p = false 
) const

Member Data Documentation

◆ bits

nonneg int ValueType::bits {}

bitfield bitcount

Definition at line 1232 of file symboldatabase.h.

Referenced by dump(), and SymbolDatabase::setValueType().

◆ constness

nonneg int ValueType::constness {}

◆ container

const Library::Container* ValueType::container {}

◆ containerTypeToken

const Token* ValueType::containerTypeToken {}

◆ debugPath

ErrorPath ValueType::debugPath

debug path to the type

Definition at line 1248 of file symboldatabase.h.

Referenced by SymbolDatabase::debugSymbolDatabase(), and setDebugPath().

◆ originalTypeName

std::string ValueType::originalTypeName

◆ pointer

nonneg int ValueType::pointer {}

0=>not pointer, 1=>*, 2=>**, 3=>***, etc

Definition at line 1233 of file symboldatabase.h.

Referenced by CheckIO::ArgumentInfo::ArgumentInfo(), astIsBool(), astIsCharWithSign(), astIsFloat(), astIsIntegral(), astIsPointer(), CheckBufferOverrun::bufferOverflow(), CheckCondition::checkCompareValueOutOfTypeRange(), CheckClass::checkConstFunc(), CheckOther::checkConstPointer(), CheckCondition::checkDuplicateConditionalAssign(), CheckOther::checkDuplicateExpression(), CheckStl::checkFindInsert(), CheckUnusedVar::checkFunctionVariableUsage(), CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(), CheckOther::checkIncompleteArrayFill(), CheckType::checkLongCast(), CheckCondition::checkPointerAdditionResultNotNull(), FwdAnalysis::checkRecursive(), CheckOther::checkRedundantPointerOp(), CheckOther::checkSignOfUnsignedVariable(), CheckSizeof::checkSizeofForPointerSize(), CheckString::checkSuspiciousStringCompare(), CheckType::checkTooBigBitwiseShift(), CheckOther::comparisonNonZeroExpressionLessThanZero(), CheckClass::constructors(), dump(), Scope::findFunction(), fromLibraryType(), CheckLeakAutoVar::functionCall(), getAlignOf(), getBufAndOffset(), getDimensionsEtc(), CTU::getFileInfo(), ContainerExpressionAnalyzer::getIndirect(), getInitListSize(), getMinMaxValues(), getPointerDepth(), ValueFlow::getSizeOf(), Token::getStrSize(), getUnsafeFunction(), CheckClass::initializeVarList(), CheckOther::invalidPointerCast(), CheckCondition::invalidTestForOverflow(), isConst(), isContainerOfPointers(), isContainerSizeChangedByFunction(), isLifetimeBorrowed(), isLifetimeOwned(), isNullOperand(), isSameConstantValue(), isSameExpression(), isTemporary(), isTruncated(), isVariableChangedByFunctionCall(), CheckUninitVar::isVariableUsage(), isVoidCast(), isVolatile(), matchParameter(), CheckBufferOverrun::objectIndex(), parsedecl(), CheckBufferOverrun::pointerArithmetic(), Check64BitPortability::pointerassignment(), CheckLeakAutoVar::ret(), setTokenValueCast(), Variable::setValueType(), SymbolDatabase::setValueType(), SymbolDatabase::setValueTypeInTokenList(), CheckSizeof::sizeofVoid(), CheckString::sprintfOverlappingData(), str(), CheckSizeof::suspiciousSizeofCalculation(), CheckOther::testIfNonZeroExpressionIsPositive(), typeSize(), useFunctionArgs(), valueFlowDynamicBufferSize(), valueFlowGlobalConstVar(), valueFlowGlobalStaticVar(), and valueFlowSetConstantValue().

◆ reference

Reference ValueType::reference = Reference::None

◆ sign

enum ValueType::Sign ValueType::sign = UNKNOWN_SIGN

◆ smartPointer

const Library::SmartPointer* ValueType::smartPointer {}

◆ smartPointerType

const ::Type* ValueType::smartPointerType {}

◆ smartPointerTypeToken

const Token* ValueType::smartPointerTypeToken {}

◆ type

enum ValueType::Type ValueType::type = UNKNOWN_TYPE

Referenced by CheckIO::ArgumentInfo::ArgumentInfo(), CheckBufferOverrun::argumentSize(), astIsBool(), astIsCharWithSign(), astIsFloat(), astIsGenericChar(), astIsIterator(), CheckOther::checkCharVariable(), CheckCondition::checkCompareValueOutOfTypeRange(), CheckCondition::checkDuplicateConditionalAssign(), CheckType::checkFloatToIntegerOverflow(), CheckUnusedVar::checkFunctionVariableUsage(), CheckOther::checkIncompleteArrayFill(), CheckCondition::checkIncorrectLogicOperator(), CheckType::checkIntegerOverflow(), CheckSizeof::checkSizeofForPointerSize(), CheckMemoryLeakStructMember::checkStructVariable(), CheckType::checkTooBigBitwiseShift(), checkTypeCombination(), CheckCondition::clarifyCondition(), SymbolDatabase::createSymbolDatabaseNeedInitialization(), dump(), Scope::findFunction(), fromLibraryType(), getAlignOf(), getInitListSize(), getMinMaxValues(), ValueFlow::getSizeOf(), CheckCondition::identicalConditionAfterEarlyExitError(), CheckClass::initializationListUsage(), CheckFunctions::invalidFunctionUsage(), CheckOther::invalidPointerCast(), isAutoDealloc(), isConvertedToIntegral(), isIterator(), isLifetimeBorrowed(), isLifetimeOwned(), isNonReferenceArg(), isRaiiClass(), isSameConstantValue(), isSameExpression(), isStdMoveOrStdForwarded(), isTruncated(), isVariableCopyNeeded(), CheckUninitVar::isVariableUsage(), CheckUnusedVar::isVariableWithoutSideEffects(), isVoidCast(), Variable::iteratorType(), matchParameter(), needsInitialization(), CheckBufferOverrun::objectIndex(), CheckStl::outOfBoundsError(), parseDecl(), parsedecl(), Check64BitPortability::pointerassignment(), setTokenValueCast(), Variable::setValueType(), clangimport::AstNode::setValueType(), SymbolDatabase::setValueType(), SymbolDatabase::setValueTypeInTokenList(), CheckSizeof::sizeofVoid(), str(), CheckStl::string_c_str(), typeSize(), CheckStl::uselessCalls(), CheckStl::useStlAlgorithm(), valueFlowIsSameContainerType(), valueFlowLifetimeClassConstructor(), and valueFlowSafeFunctions().

◆ typeScope

const Scope* ValueType::typeScope {}

◆ volatileness

nonneg int ValueType::volatileness {}

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