Cppcheck
|
#include <symboldatabase.h>
Public Member Functions | |
SymbolDatabase (Tokenizer &tokenizer, const Settings &settings, ErrorLogger &errorLogger) | |
~SymbolDatabase () | |
const Type * | findVariableType (const Scope *start, const Token *typeTok) const |
find a variable type if it's a user defined type More... | |
const Function * | findFunction (const Token *tok) const |
find a function More... | |
const Scope * | findScopeByName (const std::string &name) const |
For unit testing only. More... | |
const Type * | findType (const Token *startTok, const Scope *startScope, bool lookOutside=false) const |
Type * | findType (const Token *startTok, Scope *startScope, bool lookOutside=false) |
const Scope * | findScope (const Token *tok, const Scope *startScope) const |
Scope * | findScope (const Token *tok, Scope *startScope) |
bool | isVarId (nonneg int varid) const |
const Variable * | getVariableFromVarId (nonneg int varId) const |
const std::vector< const Variable * > & | variableList () const |
void | debugMessage (const Token *tok, const std::string &type, const std::string &msg) const |
output a debug message More... | |
void | returnImplicitIntError (const Token *tok) const |
void | printOut (const char *title=nullptr) const |
void | printVariable (const Variable *var, const char *indent) const |
void | printXml (std::ostream &out) const |
void | validate () const |
void | setValueTypeInTokenList (bool reportDebugWarnings, Token *tokens=nullptr) |
Set valuetype in provided tokenlist. More... | |
nonneg int | sizeOfType (const Token *type) const |
Calculates sizeof value for given type. More... | |
void | setArrayDimensionsUsingValueFlow () |
Set array dimensions when valueflow analysis is completed. More... | |
void | clangSetVariables (const std::vector< const Variable * > &variableList) |
void | createSymbolDatabaseExprIds () |
Public Attributes | |
std::list< Scope > | scopeList |
Information about all namespaces/classes/structures. More... | |
std::vector< const Scope * > | functionScopes |
Fast access to function scopes. More... | |
std::vector< const Scope * > | classAndStructScopes |
Fast access to class and struct scopes. More... | |
std::list< Type > | typeList |
Fast access to types. More... | |
Private Types | |
using | MemberIdMap = std::map< unsigned int, unsigned int > |
using | VarIdMap = std::map< unsigned int, MemberIdMap > |
Static Private Member Functions | |
static Function * | addGlobalFunctionDecl (Scope *&scope, const Token *tok, const Token *argStart, const Token *funcStart) |
static Function * | findFunctionInScope (const Token *func, const Scope *ns, const std::string &path, nonneg int path_length) |
static const Type * | findVariableTypeInBase (const Scope *scope, const Token *typeTok) |
static bool | isReservedName (const Token *tok) |
Whether the token is a keyword as defined in http://en.cppreference.com/w/c/keyword and http://en.cppreference.com/w/cpp/keyword. More... | |
Private Attributes | |
Tokenizer & | mTokenizer |
const Settings & | mSettings |
ErrorLogger & | mErrorLogger |
std::vector< const Variable * > | mVariableList |
variable symbol table More... | |
std::list< Type > | mBlankTypes |
list for missing types More... | |
ValueType::Sign | mDefaultSignedness |
Friends | |
class | TestSymbolDatabase |
class | Scope |
class | Function |
Definition at line 1319 of file symboldatabase.h.
|
private |
Definition at line 1448 of file symboldatabase.h.
|
private |
Definition at line 1449 of file symboldatabase.h.
SymbolDatabase::SymbolDatabase | ( | Tokenizer & | tokenizer, |
const Settings & | settings, | ||
ErrorLogger & | errorLogger | ||
) |
Definition at line 55 of file symboldatabase.cpp.
References createSymbolDatabaseClassAndStructScopes(), createSymbolDatabaseClassInfo(), createSymbolDatabaseCopyAndMoveConstructors(), createSymbolDatabaseEnums(), createSymbolDatabaseEscapeFunctions(), createSymbolDatabaseExprIds(), createSymbolDatabaseFindAllScopes(), createSymbolDatabaseFunctionReturnTypes(), createSymbolDatabaseFunctionScopes(), createSymbolDatabaseIncompleteVars(), createSymbolDatabaseNeedInitialization(), createSymbolDatabaseSetFunctionPointers(), createSymbolDatabaseSetScopePointers(), createSymbolDatabaseSetSmartPointerType(), createSymbolDatabaseSetTypePointers(), createSymbolDatabaseSetVariablePointers(), createSymbolDatabaseVariableInfo(), createSymbolDatabaseVariableSymbolTable(), debugSymbolDatabase(), Platform::defaultSign, mDefaultSignedness, mSettings, mTokenizer, Settings::platform, setValueTypeInTokenList(), ValueType::SIGNED, Tokenizer::tokens(), ValueType::UNKNOWN_SIGN, and ValueType::UNSIGNED.
SymbolDatabase::~SymbolDatabase | ( | ) |
Definition at line 1876 of file symboldatabase.cpp.
References Token::enumerator(), TokenList::front(), Token::function(), Tokenizer::list, mTokenizer, Token::next(), Token::scope(), Token::setValueType(), Token::type(), and Token::variable().
|
private |
Definition at line 3247 of file symboldatabase.cpp.
References addNewFunction(), Function::arg, Scope::className, Function::eDestructor, Scope::eFunction, Scope::eNamespace, findFunctionInScope(), Scope::findRecordInNestedList(), Scope::function, Scope::functionMap, Scope::functionOf, Function::functionScope, Function::hasBody(), Function::isDefault(), Tokenizer::isFunctionHead(), Token::isName(), Token::isStandardType(), Token::link(), Token::linkAt(), Token::Match(), match(), Function::nestedIn, Scope::nestedIn, Token::next(), Token::previous(), Token::scope(), scopeList, Token::simpleMatch(), Token::str(), Token::strAt(), Token::tokAt(), Function::token, Scope::type, and Scope::usingList.
Referenced by createSymbolDatabaseFindAllScopes().
|
private |
Definition at line 3206 of file symboldatabase.cpp.
References addGlobalFunctionDecl(), addNewFunction(), Function::argDef, Function::argsMatch(), emptyString, Scope::function, Scope::functionMap, Function::functionScope, Function::hasBody(), and Token::str().
Referenced by createSymbolDatabaseFindAllScopes().
|
staticprivate |
Definition at line 3240 of file symboldatabase.cpp.
References Scope::addFunction(), and Scope::functionList.
Referenced by addGlobalFunction(), and createSymbolDatabaseFindAllScopes().
Definition at line 3418 of file symboldatabase.cpp.
References Scope::bodyEnd, Token::link(), Token::linkAt(), Token::Match(), mTokenizer, Scope::nestedList, Token::next(), scopeList, Scope::setBodyStartEnd(), Token::str(), Token::tokAt(), and Tokenizer::unmatchedToken().
Referenced by addClassFunction(), addGlobalFunction(), and createSymbolDatabaseFindAllScopes().
void SymbolDatabase::clangSetVariables | ( | const std::vector< const Variable * > & | variableList | ) |
Definition at line 2147 of file symboldatabase.cpp.
References mVariableList, and variableList().
|
private |
Definition at line 895 of file symboldatabase.cpp.
References classAndStructScopes, and scopeList.
Referenced by SymbolDatabase().
|
private |
Definition at line 796 of file symboldatabase.cpp.
References Type::findDependency(), findScope(), findType(), Tokenizer::isC(), mTokenizer, Type::FriendInfo::nameStart, Type::BaseInfo::nameTok, Scope::UsingInfo::scope, scopeList, Scope::UsingInfo::start, Token::tokAt(), Type::BaseInfo::type, Type::FriendInfo::type, and typeList.
Referenced by SymbolDatabase().
|
private |
Definition at line 859 of file symboldatabase.cpp.
References Function::eCopyConstructor, Function::eMoveConstructor, Variable::isPointer(), Variable::isReference(), Variable::isRValueReference(), scopeList, and Variable::type().
Referenced by SymbolDatabase().
|
private |
Definition at line 1403 of file symboldatabase.cpp.
References TokenList::back(), Scope::eEnum, Token::eName, Enumerator::end, Token::eVariable, findEnumerator(), TokenList::front(), Tokenizer::list, mTokenizer, Enumerator::name, Token::next(), scopeList, Enumerator::start, and Tokenizer::syntaxError().
Referenced by SymbolDatabase().
|
private |
Definition at line 1515 of file symboldatabase.cpp.
References Scope::eFunction, Token::findsimplematch(), Function::isEscapeFunction(), isReturnScope(), Settings::library, mSettings, and scopeList.
Referenced by SymbolDatabase().
void SymbolDatabase::createSymbolDatabaseExprIds | ( | ) |
Definition at line 1649 of file symboldatabase.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::astParent(), TokenList::back(), Scope::bodyEnd, Scope::bodyStart, compareTokenFlags(), Token::exprId(), TokenList::front(), functionScopes, getIncompleteNameID(), Token::isControlFlowKeyword(), isExpression(), Token::isIncompleteConstant(), Token::isIncompleteVar(), Token::isKeyword(), Token::isNumber(), Token::link(), Tokenizer::list, Token::Match(), mTokenizer, Variable::nameToken(), Token::next(), nonneg, precedes(), scopeList, Token::simpleMatch(), Token::str(), Token::tokType(), Token::variable(), and Token::varId().
Referenced by SymbolDatabase().
|
private |
Definition at line 140 of file symboldatabase.cpp.
References Function::access, addClassFunction(), Scope::addEnum(), addGlobalFunction(), addGlobalFunctionDecl(), addNewFunction(), Scope::addVariable(), Token::astParent(), Scope::bodyEnd, Scope::checkVariable(), Scope::classDef, Scope::className, Type::classScope, Scope::definedType, Scope::definedTypesMap, Scope::eCatch, Scope::eClass, Scope::eDo, Scope::eElse, Scope::eEnum, Scope::eFor, Scope::eGlobal, Scope::eIf, emptyString, Scope::eNamespace, Scope::eStruct, Scope::eSwitch, Scope::eTry, Scope::eUnconditional, Scope::eWhile, Scope::findInNestedListRecursive(), findLambdaEndToken(), findNamespace(), findScope(), findType(), Type::friendList, Scope::functionMap, Function::functionScope, TokenList::getSourceFilePath(), Type::initBaseInfo(), Token::isC(), Scope::isClassOrStruct(), Scope::isClassOrStructOrUnion(), Token::isCpp(), isEnumDefinition(), Scope::isExecutable(), isExecutableScope(), isFunction(), Tokenizer::isFunctionHead(), Token::isKeyword(), Token::isSimplifiedTypedef(), Token::isUpperCaseName(), Token::link(), Token::linkAt(), Tokenizer::list, Local, Token::Match(), mErrorLogger, mSettings, mTokenizer, Type::name(), Type::FriendInfo::nameEnd, Type::FriendInfo::nameStart, Function::nestedIn, Scope::nestedIn, Scope::nestedList, Token::next(), Token::previous(), Private, Token::progressValue(), Protected, Public, ErrorLogger::reportProgress(), Scope::UsingInfo::scope, scopeList, Scope::setBodyStartEnd(), Token::simpleMatch(), Scope::UsingInfo::start, Token::str(), Token::strAt(), succeeds(), InternalError::SYNTAX, Tokenizer::syntaxError(), Throw, Token::tokAt(), Function::token, Tokenizer::tokens(), Type::FriendInfo::type, Scope::type, typeList, and Scope::usingList.
Referenced by SymbolDatabase().
|
private |
Definition at line 904 of file symboldatabase.cpp.
References findTypeInNested(), findVariableTypeInBase(), Token::Match(), Token::next(), and scopeList.
Referenced by SymbolDatabase().
|
private |
Definition at line 886 of file symboldatabase.cpp.
References Scope::eFunction, functionScopes, and scopeList.
Referenced by SymbolDatabase().
|
private |
Definition at line 1451 of file symboldatabase.cpp.
References Token::astParent(), TokenList::back(), TokenList::front(), Library::functions, isCPPCast(), Scope::isExecutable(), Settings::library, Tokenizer::list, Token::Match(), mSettings, mTokenizer, Token::next(), Token::originalName(), Token::previous(), Token::simpleMatch(), Token::str(), and Token::tokAt().
Referenced by SymbolDatabase().
|
private |
check for arguments with default values
Definition at line 926 of file symboldatabase.cpp.
References Function::argCount(), ValueType::CONTAINER, debugMessage(), Settings::debugwarnings, Function::eConstructor, Scope::eUnion, Type::False, Variable::hasDefault(), Function::initializedArgCount(), Tokenizer::isC(), Variable::isClass(), Variable::isReference(), Variable::isStatic(), mBlankTypes, mSettings, mTokenizer, Type::needInitialization, scopeList, Token::simpleMatch(), Type::True, Variable::type(), Function::type, ValueType::type, Type::Unknown, and Variable::valueType().
Referenced by SymbolDatabase().
|
private |
Definition at line 1135 of file symboldatabase.cpp.
References Function::arg, TokenList::back(), Scope::bodyStart, findFunction(), Scope::findFunction(), TokenList::front(), Scope::functionOf, Function::functionScope, Function::isConstructor(), isReservedName(), Token::link(), Token::linkAt(), Tokenizer::list, Token::Match(), mTokenizer, Token::next(), scopeList, Token::str(), Function::token, and Function::tokenDef.
Referenced by setValueTypeInTokenList(), and SymbolDatabase().
|
private |
Definition at line 1094 of file symboldatabase.cpp.
References TokenList::back(), Scope::bodyStartList, Scope::eGlobal, TokenList::front(), Token::link(), Tokenizer::list, mTokenizer, Scope::nestedList, Token::next(), scopeList, and Scope::type.
Referenced by SymbolDatabase().
|
private |
Definition at line 1227 of file symboldatabase.cpp.
References scopeList, Variable::setValueType(), ValueType::smartPointerType, ValueType::smartPointerTypeToken, Token::type(), and Variable::valueType().
Referenced by SymbolDatabase().
|
private |
Definition at line 1206 of file symboldatabase.cpp.
References TokenList::back(), findVariableType(), TokenList::front(), Tokenizer::list, mTokenizer, Token::next(), and typeList.
Referenced by SymbolDatabase().
|
private |
Definition at line 1268 of file symboldatabase.cpp.
References astIsContainer(), Token::astOperand2(), Token::astParent(), TokenList::back(), Type::classScope, ValueType::CONTAINER, ValueType::container, ValueType::containerTypeToken, Scope::definedType, Library::detectSmartPointer(), Token::findsimplematch(), Scope::findType(), findTypeInNested(), fixVarId(), TokenList::front(), Token::function(), Library::Container::functions, Scope::getVariable(), getVariableFromVarId(), isContainerYieldElement(), ValueType::ITERATOR, Variable::iteratorType(), Settings::library, Token::link(), Tokenizer::list, Token::Match(), mSettings, mTokenizer, mVariableList, Scope::nestedIn, Token::next(), Token::scope(), Token::simpleMatch(), Variable::smartPointerType(), Token::str(), Variable::typeScope(), Token::valueType(), and Token::variable().
Referenced by setValueTypeInTokenList(), and SymbolDatabase().
|
private |
Definition at line 840 of file symboldatabase.cpp.
References mSettings, and scopeList.
Referenced by SymbolDatabase().
|
private |
Definition at line 1029 of file symboldatabase.cpp.
References Function::argumentList, Variable::declarationId(), findType(), findTypeInNested(), functionScopes, Scope::getVariable(), Token::isStandardType(), Token::link(), Token::Match(), mTokenizer, mVariableList, Variable::nameToken(), Token::next(), scopeList, Token::simpleMatch(), Token::str(), Variable::type(), Variable::typeScope(), Variable::typeStartToken(), Token::varId(), and Tokenizer::varIdCount().
Referenced by SymbolDatabase().
void SymbolDatabase::debugMessage | ( | const Token * | tok, |
const std::string & | type, | ||
const std::string & | msg | ||
) | const |
output a debug message
Definition at line 3586 of file symboldatabase.cpp.
References debug, Settings::debugwarnings, Tokenizer::list, mErrorLogger, mSettings, mTokenizer, normal, and ErrorLogger::reportErr().
Referenced by Function::addArguments(), CheckClass::checkConst(), Scope::checkVariable(), createSymbolDatabaseNeedInitialization(), CheckClass::isMemberVar(), setValueType(), and setValueTypeInTokenList().
|
private |
Definition at line 2152 of file symboldatabase.cpp.
References Token::astParent(), TokenList::back(), debug, Settings::debugnormal, ValueType::debugPath, Settings::debugwarnings, TokenList::front(), Token::getTokenDebug(), Tokenizer::list, mErrorLogger, mSettings, mTokenizer, Token::next(), normal, ErrorLogger::reportErr(), ValueType::str(), ValueType, and Token::valueType().
Referenced by SymbolDatabase().
|
private |
Definition at line 5183 of file symboldatabase.cpp.
References Token::astOperand1(), Token::astParent(), Token::astTop(), Type::classScope, Scope::definedType, Type::derivedFrom, Scope::eFunction, Scope::eGlobal, Scope::enumClass, Scope::findEnumerator(), findEnumScopeInBase(), Scope::findRecordInNestedList(), Token::function(), Scope::functionOf, Token::isKeyword(), Token::Match(), Scope::nestedIn, Scope::nestedList, Enumerator::scope, Token::scope(), scopeList, Token::simpleMatch(), Token::str(), Token::strAt(), Token::tokAt(), Type::type(), Scope::type, and Token::variable().
Referenced by createSymbolDatabaseEnums().
find a function
tok | token of function call |
Definition at line 5922 of file symboldatabase.cpp.
References Token::astOperand1(), Scope::className, Type::classScope, ValueType::constness, Scope::findFunction(), Scope::findRecordInNestedList(), Token::function(), Scope::functionOf, getVariableFromVarId(), Token::isCast(), Scope::isExecutable(), Variable::iteratorType(), Token::linkAt(), Token::Match(), mSettings, Scope::nestedIn, Token::next(), Token::originalName(), ValueType::parseDecl(), Token::previous(), Token::scope(), scopeList, Token::simpleMatch(), Variable::smartPointerType(), Token::str(), Token::strAt(), Token::tokAt(), Variable::typeScope(), ValueType::typeScope, Scope::usingList, Variable::valueType(), Token::valueType(), and Token::varId().
Referenced by createSymbolDatabaseSetFunctionPointers().
|
staticprivate |
Definition at line 6394 of file symboldatabase.cpp.
References Scope::findRecordInNestedList(), Scope::functionMap, Token::linkAt(), Token::Match(), Token::next(), Token::str(), Token::strAt(), and Token::tokAt().
Referenced by addClassFunction().
|
private |
Definition at line 6380 of file symboldatabase.cpp.
References findScope(), and Scope::nestedIn.
Referenced by createSymbolDatabaseFindAllScopes().
Definition at line 6180 of file symboldatabase.cpp.
References Scope::findRecordInNestedList(), Token::isName(), Token::linkAt(), Token::next(), scopeList, Token::simpleMatch(), Token::str(), Token::strAt(), and Token::tokAt().
Referenced by createSymbolDatabaseClassInfo(), createSymbolDatabaseFindAllScopes(), findNamespace(), and parsedecl().
Definition at line 1362 of file symboldatabase.h.
const Scope * SymbolDatabase::findScopeByName | ( | const std::string & | name | ) | const |
const Type * SymbolDatabase::findType | ( | const Token * | startTok, |
const Scope * | startScope, | ||
bool | lookOutside = false |
||
) | const |
Definition at line 6210 of file symboldatabase.cpp.
References Scope::className, Scope::definedType, Scope::findRecordInBase(), Scope::findRecordInNestedList(), Scope::findType(), Token::isC(), Scope::isClassOrStruct(), Token::isName(), Token::linkAt(), Token::Match(), Scope::nestedIn, Token::next(), scopeList, Token::simpleMatch(), Token::str(), Token::strAt(), Token::tokAt(), Scope::type, and Scope::usingList.
Referenced by createSymbolDatabaseClassInfo(), createSymbolDatabaseFindAllScopes(), createSymbolDatabaseVariableSymbolTable(), Type::initBaseInfo(), and typesMatch().
|
inline |
Definition at line 1356 of file symboldatabase.h.
|
private |
Definition at line 6325 of file symboldatabase.cpp.
References Scope::className, Scope::definedType, Scope::findRecordInNestedList(), Scope::findType(), Scope::isClassOrStruct(), Token::isName(), Token::linkAt(), Token::Match(), Scope::nestedIn, Token::next(), scopeList, Token::simpleMatch(), Token::str(), Token::strAt(), and Token::tokAt().
Referenced by createSymbolDatabaseFunctionReturnTypes(), createSymbolDatabaseSetVariablePointers(), createSymbolDatabaseVariableSymbolTable(), and setValueType().
find a variable type if it's a user defined type
start | scope to start looking in |
typeTok | token containing variable type |
Definition at line 5347 of file symboldatabase.cpp.
References Scope::className, Scope::definedType, Scope::eFunction, Scope::findRecordInNestedList(), Scope::findType(), findVariableTypeInBase(), Scope::functionOf, Scope::isClassOrStruct(), Token::isKeyword(), Token::linkAt(), Token::Match(), Scope::nestedIn, scopeList, Token::simpleMatch(), Token::str(), Token::strAt(), Token::tokAt(), and Scope::type.
Referenced by clangimport::AstNode::addTypeTokens(), createSymbolDatabaseSetTypePointers(), and findVariableTypeIncludingUsedNamespaces().
|
staticprivate |
Definition at line 5323 of file symboldatabase.cpp.
References Type::classScope, Scope::definedType, Type::derivedFrom, Scope::findType(), Token::str(), and Type::type().
Referenced by createSymbolDatabaseFunctionReturnTypes(), and findVariableType().
|
private |
Definition at line 1240 of file symboldatabase.cpp.
References mTokenizer, mVariableList, Variable::nameToken(), Tokenizer::newVarId(), and Token::varId().
Referenced by createSymbolDatabaseSetVariablePointers().
Definition at line 1371 of file symboldatabase.h.
Referenced by CheckIO::checkFileUsage(), CheckUnusedVar::checkFunctionVariableUsage(), createSymbolDatabaseSetVariablePointers(), findFunction(), and CheckLeakAutoVar::ret().
|
private |
Definition at line 1889 of file symboldatabase.cpp.
References Scope::eGlobal, endsWith(), Token::findmatch(), Token::isC(), Scope::isClassOrStructOrUnion(), Token::isCpp(), Tokenizer::isFunctionHead(), Token::isKeyword(), Token::isName(), Token::isNumber(), isReservedName(), Token::isStandardType(), Token::isUpperCaseName(), Token::link(), Token::linkAt(), Token::Match(), mTokenizer, Token::next(), Token::previous(), returnImplicitIntError(), Token::simpleMatch(), Token::str(), Token::strAt(), Tokenizer::syntaxError(), Scope::type, and Token::varId().
Referenced by createSymbolDatabaseFindAllScopes().
|
staticprivate |
Whether the token is a keyword as defined in http://en.cppreference.com/w/c/keyword and http://en.cppreference.com/w/cpp/keyword.
Definition at line 6428 of file symboldatabase.cpp.
References Keywords::getAll(), Token::isCpp(), and Token::str().
Referenced by createSymbolDatabaseSetFunctionPointers(), and isFunction().
|
inline |
Definition at line 1367 of file symboldatabase.h.
void SymbolDatabase::printOut | ( | const char * | title = nullptr | ) | const |
Definition at line 3933 of file symboldatabase.cpp.
References Type::BaseInfo::access, accessControlToString(), Scope::eEnum, Enumerator::end, Type::False, TokenList::fileLine(), functionTypeToString(), Type::BaseInfo::isVirtual, Tokenizer::list, Token::Match(), mTokenizer, mVariableList, Type::BaseInfo::name, Enumerator::name, Token::next(), printVariable(), Private, Protected, Public, scopeList, scopeToString(), Enumerator::start, Token::str(), Token::strAt(), Token::tokAt(), tokenToString(), tokenType(), Type::True, Type::BaseInfo::type, Token::type(), typeList, Type::Unknown, Enumerator::value, and Enumerator::value_known.
Referenced by Tokenizer::printDebugOutput().
void SymbolDatabase::printVariable | ( | const Variable * | var, |
const char * | indent | ||
) | const |
Definition at line 3863 of file symboldatabase.cpp.
References Variable::accessControl(), accessControlToString(), Type::classDef, Variable::declarationId(), Variable::dimension(), Variable::dimensions(), TokenList::fileLine(), Variable::hasDefault(), indent(), Variable::index(), Variable::isArray(), Variable::isClass(), Variable::isConst(), Variable::isExtern(), Variable::isLocal(), Variable::isMutable(), Variable::isPointer(), Variable::isReference(), Variable::isRValueReference(), Variable::isStatic(), Variable::isStlType(), Tokenizer::list, mTokenizer, Type::name(), Variable::nameToken(), Token::next(), Variable::scope(), scopeToString(), ValueType::str(), Token::str(), tokenToString(), tokenType(), Type::type(), Variable::type(), Variable::typeEndToken(), Variable::typeStartToken(), Variable::valueType(), and Token::valueType().
Referenced by printOut().
void SymbolDatabase::printXml | ( | std::ostream & | out | ) | const |
Definition at line 4161 of file symboldatabase.cpp.
References Type::BaseInfo::access, accessControlToString(), bool_to_string(), ValueType::constness, functionTypeToString(), Function::getOverriddenFunction(), id_string(), Variable::isArray(), Variable::isClass(), Variable::isConst(), Variable::isExtern(), Variable::isPointer(), Variable::isReference(), Variable::isStatic(), Type::BaseInfo::isVirtual, Variable::isVolatile(), Variable::mAccess, mVariableList, Type::BaseInfo::nameTok, Variable::nameToken(), Private, Protected, Public, Variable::scope(), scopeList, scopeTypeToString(), ErrorLogger::toxml(), Type::BaseInfo::type, Variable::typeEndToken(), typeList, Variable::typeStartToken(), Variable::valueType(), and ValueType::volatileness.
Referenced by Tokenizer::dump(), and Tokenizer::printDebugOutput().
void SymbolDatabase::returnImplicitIntError | ( | const Token * | tok | ) | const |
Definition at line 3599 of file symboldatabase.cpp.
References Standards::c, Standards::C89, Token::isC(), SimpleEnableGroup< T >::isEnabled(), Tokenizer::list, mErrorLogger, mSettings, mTokenizer, normal, portability, ErrorLogger::reportErr(), Settings::severity, Settings::standards, and Token::str().
Referenced by isFunction().
void SymbolDatabase::setArrayDimensionsUsingValueFlow | ( | ) |
Set array dimensions when valueflow analysis is completed.
Definition at line 1776 of file symboldatabase.cpp.
References TokenList::addtoken(), Platform::char_bit, TokenList::front(), Token::getKnownIntValue(), Token::hasKnownIntValue(), Platform::int_bit, Token::isName(), Platform::long_bit, Platform::long_long_bit, Token::Match(), mSettings, mVariableList, Token::next(), Settings::platform, Platform::short_bit, TemplateSimplifier::simplifyNumericCalculations(), Token::str(), and MathLib::toBigNumber().
Referenced by Tokenizer::simplifyTokens1().
|
private |
Definition at line 6492 of file symboldatabase.cpp.
References Settings::debugnormal, Settings::debugwarnings, Scope::enumType, ValueType::fromLibraryType(), getEnumType(), ValueType::isIntegral(), Token::isLong(), Token::isSigned(), Token::isStandardType(), Token::isUnsigned(), mDefaultSignedness, mSettings, Settings::platform, Enumerator::scope, ValueType::setDebugPath(), setValueType(), ValueType::sign, ValueType::SIGNED, Token::str(), ValueType::type, ValueType::typeFromString(), and ValueType::typeScope.
|
private |
Definition at line 6541 of file symboldatabase.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::astParent(), Type::classScope, ValueType::constness, ValueType::container, ValueType::containerTypeToken, Standards::cpp, Standards::CPP17, debugMessage(), Settings::debugnormal, Settings::debugwarnings, Scope::definedType, Token::eBitOp, Token::eIncDecOp, Scope::findFunction(), findTypeInNested(), Token::function(), Library::Container::getYield(), Token::isArithmeticalOp(), Token::isAssignmentOp(), isContainerYieldElement(), isContainerYieldPointer(), Token::isCpp(), ValueType::isIntegral(), ValueType::isPrimitive(), Library::isSmartPointer(), ValueType::isTypeEqual(), Settings::library, LValue, Token::Match(), mDefaultSignedness, mSettings, Token::next(), None, op1, Token::originalName(), ValueType::originalTypeName, parsedecl(), ValueType::pointer, Token::previous(), Library::Container::rangeItemRecordType, ValueType::reference, RValue, Token::scope(), setAutoTokenProperties(), Variable::setValueType(), Token::setValueType(), ValueType::sign, Token::simpleMatch(), ValueType::smartPointerType, ValueType::smartPointerTypeToken, Settings::standards, Token::str(), Token::strAt(), Token::tokAt(), Token::tokType(), Variable::type(), ValueType::type, Token::type(), ValueType::typeScope, ValueType, Token::valueType(), Token::variable(), Scope::varlist, and ValueType::volatileness.
Referenced by setValueType(), and setValueTypeInTokenList().
|
private |
Definition at line 6459 of file symboldatabase.cpp.
References Token::astOperand1(), ValueType::bits, Token::bits(), ValueType::constness, ValueType::container, ValueType::containerTypeToken, Settings::debugnormal, Settings::debugwarnings, Variable::dimensions(), mDefaultSignedness, mSettings, Variable::nameToken(), Token::next(), parsedecl(), ValueType::pointer, ValueType::setDebugPath(), setValueType(), Token::simpleMatch(), Variable::smartPointerType(), ValueType::smartPointerType, Token::str(), Variable::typeScope(), ValueType::typeScope, Variable::typeStartToken(), Variable::valueType(), and ValueType::volatileness.
void SymbolDatabase::setValueTypeInTokenList | ( | bool | reportDebugWarnings, |
Token * | tokens = nullptr |
||
) |
Set valuetype in provided tokenlist.
Definition at line 7334 of file symboldatabase.cpp.
References MathLib::abs(), astFunctionYield(), Token::astOperand1(), Token::astOperand2(), Token::astParent(), ValueType::constness, ValueType::container, ValueType::containerTypeToken, Standards::cpp, Standards::CPP20, createSymbolDatabaseSetFunctionPointers(), createSymbolDatabaseSetVariablePointers(), TokenList::createTokens(), debugMessage(), Settings::debugwarnings, Scope::definedType, Library::detectContainerOrIterator(), Library::detectSmartPointer(), Token::eChar, Scope::eFunction, Scope::eLambda, Token::eLogicalOp, Library::Container::END_ITERATOR, Token::enumerator(), Token::eString, ValueType::fromLibraryType(), TokenList::front(), Scope::function, Token::function(), Library::Container::functions, Library::getArgIteratorInfo(), getArguments(), getClassScope(), getFunction(), getOperatorFunction(), Token::isBoolean(), Token::isCast(), Token::isCChar(), Scope::isClassOrStruct(), Token::isCMultiChar(), Token::isComparisonOp(), Function::isConst(), Token::isCpp(), MathLib::isDec(), Scope::isExecutable(), MathLib::isFloat(), MathLib::isInt(), ValueType::isIntegral(), Platform::isIntValue(), isIterator(), Token::isKeyword(), isLambdaCaptureList(), Token::isLong(), Platform::isLongLongValue(), Platform::isLongValue(), Token::isNumber(), Token::isSigned(), Library::isSmartPointer(), Token::isStandardType(), Token::isUnsigned(), Token::isUtf16(), Token::isUtf32(), Token::isUtf8(), Function::isVolatile(), Library::ArgumentChecks::IteratorInfo::it, Library::Container::ITERATOR, Settings::library, Token::link(), Tokenizer::list, Token::Match(), mDefaultSignedness, mSettings, mTokenizer, Scope::nestedIn, Token::next(), nonneg, ValueType::originalTypeName, ValueType::parseDecl(), parsedecl(), Settings::platform, ValueType::pointer, Token::previous(), ValueType::RECORD, Function::retDef, Library::returnValueType(), Token::scope(), setValueType(), Token::setValueType(), sign(), ValueType::sign, Token::simpleMatch(), TokenList::simplifyPlatformTypes(), TokenList::simplifyStdType(), ValueType::smartPointer, Library::smartPointers, ValueType::smartPointerType, ValueType::smartPointerTypeToken, Settings::standards, Library::Container::START_ITERATOR, Token::str(), MathLib::toBigUNumber(), Token::tokAt(), Function::tokenDef, Token::tokType(), Platform::type, Scope::type, ValueType::type, Token::type(), ValueType::typeFromString(), ValueType::typeScope, ValueType::UNKNOWN_INT, ValueType, Token::valueType(), Token::variable(), and ValueType::volatileness.
Referenced by Tokenizer::simplifyTokens1(), and SymbolDatabase().
Calculates sizeof value for given type.
type | Token which will contain e.g. "int", "*", or string. |
Definition at line 6439 of file symboldatabase.cpp.
References mSettings, mTokenizer, Settings::platform, Platform::sizeof_int, Tokenizer::sizeOfType(), and Token::type().
void SymbolDatabase::validate | ( | ) | const |
Definition at line 2139 of file symboldatabase.cpp.
References Settings::debugwarnings, mSettings, validateExecutableScopes(), and validateVariables().
|
private |
Definition at line 2088 of file symboldatabase.cpp.
References Scope::classDef, debug, Scope::function, functionScopes, Scope::isExecutable(), Tokenizer::list, mErrorLogger, mTokenizer, normal, ErrorLogger::reportErr(), and Token::str().
Referenced by validate().
|
private |
Check variable list, e.g.
variables w/o scope
Definition at line 2124 of file symboldatabase.cpp.
References InternalError::INTERNAL, Variable::isArgument(), mVariableList, Variable::nameToken(), and Variable::scope().
Referenced by validate().
|
inline |
Definition at line 1375 of file symboldatabase.h.
Referenced by Tokenizer::arraySizeAfterValueFlow(), CheckMemoryLeakStructMember::check(), CheckOther::checkConstVariable(), CheckIO::checkFileUsage(), CheckOther::checkPassByReference(), CheckOther::checkRedundantCopy(), CheckUnusedVar::checkStructMemberUsage(), CheckOther::checkVariableScope(), clangSetVariables(), CheckStl::iterators(), CheckStl::mismatchingContainers(), CheckBufferOverrun::negativeArraySize(), Tokenizer::printDebugOutput(), CheckStl::stlBoundaries(), CheckVaarg::va_list_usage(), valueFlowContainerSize(), and CheckClass::virtualDestructor().
|
friend |
Definition at line 1413 of file symboldatabase.h.
|
friend |
Definition at line 1412 of file symboldatabase.h.
|
friend |
Definition at line 1320 of file symboldatabase.h.
std::vector<const Scope*> SymbolDatabase::classAndStructScopes |
Fast access to class and struct scopes.
Definition at line 1332 of file symboldatabase.h.
Referenced by CheckMemoryLeakInClass::check(), CheckClass::checkConst(), CheckClass::checkCopyCtorAndEqOperator(), CheckClass::checkExplicitConstructors(), CheckClass::checkOverride(), CheckClass::checkReturnByReference(), CheckUninitVar::checkStruct(), CheckClass::checkThisUseAfterFree(), CheckClass::checkUnsafeClassRefMember(), CheckClass::checkUselessOverride(), CheckClass::constructors(), CheckClass::copyconstructors(), createSymbolDatabaseClassAndStructScopes(), CheckClass::getFileInfo(), CheckClass::initializerListOrder(), CheckClass::operatorEqRetRefThis(), CheckClass::operatorEqToSelf(), CheckClass::privateFunctions(), and CheckClass::virtualDestructor().
std::vector<const Scope*> SymbolDatabase::functionScopes |
Fast access to function scopes.
Definition at line 1329 of file symboldatabase.h.
Referenced by CheckCondition::alwaysTrueFalse(), CheckBufferOverrun::argumentSize(), CheckNullPointer::arithmetic(), CheckBufferOverrun::arrayIndexThenCheck(), CheckAutoVariables::assignFunctionArg(), CheckAutoVariables::autoVariables(), CheckBufferOverrun::bufferOverflow(), CheckLeakAutoVar::check(), CheckMemoryLeakNoVar::check(), CheckOther::checkAccessOfMovedVariable(), CheckBool::checkAssignBoolToFloat(), CheckBool::checkAssignBoolToPointer(), CheckCondition::checkAssignmentInCondition(), CheckBool::checkBitwiseOnBoolean(), CheckBoost::checkBoostForeachModification(), CheckOther::checkCastIntToCharAndBack(), CheckOther::checkCharVariable(), CheckOther::checkComparePointers(), CheckCondition::checkCompareValueOutOfTypeRange(), CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalse(), CheckBool::checkComparisonOfBoolExpressionWithInt(), CheckBool::checkComparisonOfBoolWithBool(), CheckBool::checkComparisonOfBoolWithInt(), CheckBool::checkComparisonOfFuncReturningBool(), CheckIO::checkCoutCerrMisusage(), CheckCondition::checkDuplicateConditionalAssign(), CheckOther::checkDuplicateExpression(), CheckOther::checkEvaluationOrder(), CheckIO::checkFileUsage(), CheckStl::checkFindInsert(), CheckOther::checkFuncArgNamesDifferent(), CheckUnusedVar::checkFunctionVariableUsage(), CheckFunctions::checkIgnoredReturnValue(), CheckOther::checkIncompleteArrayFill(), CheckCondition::checkIncorrectLogicOperator(), CheckString::checkIncorrectStringCompare(), CheckBool::checkIncrementBoolean(), CheckOther::checkInvalidFree(), CheckOther::checkKnownArgument(), CheckOther::checkKnownPointerToBool(), CheckType::checkLongCast(), CheckFunctions::checkMathFunctions(), CheckClass::checkMemset(), CheckFunctions::checkMissingReturn(), CheckOther::checkMisusedScopedObject(), CheckCondition::checkModuloAlwaysTrueFalse(), CheckStl::checkMutexes(), CheckOther::checkOverlappingWrite(), CheckCondition::checkPointerAdditionResultNotNull(), CheckFunctions::checkProhibitedFunctions(), CheckMemoryLeakInFunction::checkReallocUsage(), CheckOther::checkRedundantAssignment(), CheckClass::checkSelfInitialization(), CheckOther::checkSignOfUnsignedVariable(), CheckSizeof::checkSizeofForArrayParameter(), CheckSizeof::checkSizeofForNumericParameter(), CheckSizeof::checkSizeofForPointerSize(), CheckString::checkSuspiciousStringCompare(), CheckOther::checkUnreachableCode(), CheckOther::checkUnusedLabel(), CheckOther::checkVarFuncNullUB(), CheckAutoVariables::checkVarLifetime(), CheckClass::checkVirtualFunctionCallInConstructor(), CheckIO::checkWrongPrintfScanfArguments(), CheckOther::clarifyCalculation(), CheckCondition::clarifyCondition(), CheckOther::clarifyStatement(), Summaries::create(), createSymbolDatabaseExprIds(), createSymbolDatabaseFunctionScopes(), createSymbolDatabaseVariableSymbolTable(), clangimport::AstNode::createTokensFunctionDecl(), CheckExceptionSafety::deallocThrow(), CheckExceptionSafety::destructors(), CheckStl::eraseIteratorOutOfBounds(), CheckClass::initializationListUsage(), CheckStl::invalidContainer(), CheckFunctions::invalidFunctionUsage(), CheckOther::invalidPointerCast(), CheckIO::invalidScanf(), CheckStl::knownEmptyContainer(), CheckFunctions::memsetInvalid2ndParam(), CheckFunctions::memsetZeroBytes(), CheckStl::mismatchingContainerIterator(), CheckStl::mismatchingContainers(), CheckBufferOverrun::negativeArraySize(), CheckStl::negativeIndex(), CheckExceptionSafety::nothrowThrows(), CheckNullPointer::nullConstantDereference(), CheckBufferOverrun::objectIndex(), CheckStl::outOfBounds(), CheckStl::outOfBoundsIndexExpression(), CheckString::overlappingStrcmp(), CheckUnusedFunctions::parseTokens(), Check64BitPortability::pointerassignment(), CheckPostfixOperator::postfixOperator(), CheckExceptionSafety::rethrowNoCurrentException(), CheckFunctions::returnLocalStdMove(), CheckBool::returnValueOfFunctionReturningBool(), CheckStl::size(), CheckString::sprintfOverlappingData(), CheckString::stringLiteralWrite(), CheckBufferOverrun::stringNotZeroTerminated(), CheckString::strPlusChar(), ConditionHandler::traverseCondition(), CheckExceptionSafety::unhandledExceptionSpecification(), CheckStl::uselessCalls(), CheckStl::useStlAlgorithm(), CheckVaarg::va_start_argument(), validateExecutableScopes(), valueFlowAfterAssign(), valueFlowAfterMove(), valueFlowAfterSwap(), valueFlowConditionExpressions(), valueFlowContainerSize(), valueFlowDynamicBufferSize(), valueFlowFunctionDefaultParameter(), valueFlowSafeFunctions(), valueFlowSubFunction(), valueFlowSymbolic(), valueFlowSymbolicInfer(), valueFlowSymbolicOperators(), CheckUninitVar::valueFlowUninit(), and CheckOther::warningOldStylePointerCast().
|
private |
list for missing types
Definition at line 1476 of file symboldatabase.h.
Referenced by createSymbolDatabaseNeedInitialization().
|
private |
Definition at line 1478 of file symboldatabase.h.
Referenced by setValueType(), setValueTypeInTokenList(), and SymbolDatabase().
|
private |
Definition at line 1470 of file symboldatabase.h.
Referenced by createSymbolDatabaseFindAllScopes(), debugMessage(), debugSymbolDatabase(), returnImplicitIntError(), and validateExecutableScopes().
|
private |
Definition at line 1469 of file symboldatabase.h.
Referenced by Function::addArguments(), createSymbolDatabaseEscapeFunctions(), createSymbolDatabaseFindAllScopes(), createSymbolDatabaseIncompleteVars(), createSymbolDatabaseNeedInitialization(), createSymbolDatabaseSetVariablePointers(), createSymbolDatabaseVariableInfo(), debugMessage(), debugSymbolDatabase(), findFunction(), Scope::isVariableDeclaration(), returnImplicitIntError(), setArrayDimensionsUsingValueFlow(), setValueType(), setValueTypeInTokenList(), sizeOfType(), SymbolDatabase(), and validate().
|
private |
Definition at line 1468 of file symboldatabase.h.
Referenced by Function::addArguments(), addNewFunction(), createSymbolDatabaseClassInfo(), createSymbolDatabaseEnums(), createSymbolDatabaseExprIds(), createSymbolDatabaseFindAllScopes(), createSymbolDatabaseIncompleteVars(), createSymbolDatabaseNeedInitialization(), createSymbolDatabaseSetFunctionPointers(), createSymbolDatabaseSetScopePointers(), createSymbolDatabaseSetTypePointers(), createSymbolDatabaseSetVariablePointers(), createSymbolDatabaseVariableSymbolTable(), debugMessage(), debugSymbolDatabase(), fixVarId(), Scope::getVariableList(), isFunction(), printOut(), printVariable(), returnImplicitIntError(), setValueTypeInTokenList(), sizeOfType(), SymbolDatabase(), validateExecutableScopes(), and ~SymbolDatabase().
|
private |
variable symbol table
Definition at line 1473 of file symboldatabase.h.
Referenced by clangSetVariables(), createSymbolDatabaseSetVariablePointers(), createSymbolDatabaseVariableSymbolTable(), fixVarId(), printOut(), printXml(), setArrayDimensionsUsingValueFlow(), and validateVariables().
std::list<Scope> SymbolDatabase::scopeList |
Information about all namespaces/classes/structures.
Definition at line 1326 of file symboldatabase.h.
Referenced by addClassFunction(), addNewFunction(), CheckUninitVar::check(), CheckExceptionSafety::checkCatchExceptionByValue(), CheckStl::checkDereferenceInvalidIterator(), CheckOther::checkDuplicateBranch(), CheckExceptionSafety::checkRethrowCopy(), CheckOther::checkShadowVariables(), CheckUnusedVar::checkStructMemberUsage(), CheckOther::checkSuspiciousCaseInSwitch(), CheckOther::checkSuspiciousSemicolon(), CheckClass::constructors(), clangimport::AstNode::createScope(), createSymbolDatabaseClassAndStructScopes(), createSymbolDatabaseClassInfo(), createSymbolDatabaseCopyAndMoveConstructors(), createSymbolDatabaseEnums(), createSymbolDatabaseEscapeFunctions(), createSymbolDatabaseExprIds(), createSymbolDatabaseFindAllScopes(), createSymbolDatabaseFunctionReturnTypes(), createSymbolDatabaseFunctionScopes(), createSymbolDatabaseNeedInitialization(), createSymbolDatabaseSetFunctionPointers(), createSymbolDatabaseSetScopePointers(), createSymbolDatabaseSetSmartPointerType(), createSymbolDatabaseVariableInfo(), createSymbolDatabaseVariableSymbolTable(), clangimport::AstNode::createTokensFunctionDecl(), CheckCondition::duplicateCondition(), CheckStl::erase(), findEnumerator(), findFunction(), findScope(), findScopeByName(), findType(), findTypeInNested(), findVariableType(), CTU::getFileInfo(), CTU::getUnsafeUsage(), CheckStl::if_find(), CheckStl::missingComparison(), CheckCondition::multiCondition(), CheckCondition::multiCondition2(), clangimport::parseClangAstDump(), CheckBool::pointerArithBool(), printOut(), printXml(), CheckOther::redundantBitwiseOperationInSwitchError(), CheckStl::redundantCondition(), setValues(), CheckStl::stlOutOfBounds(), CheckStl::string_c_str(), CheckFunctions::useStandardLibrary(), valueFlowEnumValue(), valueFlowForLoop(), and valueFlowSwitchVariable().
std::list<Type> SymbolDatabase::typeList |
Fast access to types.
Definition at line 1335 of file symboldatabase.h.
Referenced by CheckClass::checkDuplInheritedMembers(), createSymbolDatabaseClassInfo(), createSymbolDatabaseFindAllScopes(), createSymbolDatabaseSetTypePointers(), printOut(), and printXml().