Cppcheck
Functions
symboldatabase.cpp File Reference
#include "symboldatabase.h"
#include "astutils.h"
#include "errorlogger.h"
#include "errortypes.h"
#include "keywords.h"
#include "library.h"
#include "mathlib.h"
#include "path.h"
#include "platform.h"
#include "settings.h"
#include "standards.h"
#include "templatesimplifier.h"
#include "token.h"
#include "tokenize.h"
#include "tokenlist.h"
#include "utils.h"
#include "valueflow.h"
#include <algorithm>
#include <cassert>
#include <cstring>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

Go to the source code of this file.

Functions

static const TokenskipScopeIdentifiers (const Token *tok)
 
static bool isExecutableScope (const Token *tok)
 
static bool isEnumDefinition (const Token *tok)
 
static bool isContainerYieldElement (Library::Container::Yield yield)
 
static bool isExpression (const Token *tok)
 
static std::string getIncompleteNameID (const Token *tok)
 
static bool isOperator (const Token *tokenDef)
 
static std::string qualifiedName (const Scope *scope)
 
static bool usingNamespace (const Scope *scope, const Token *first, const Token *second, int &offset)
 
static bool typesMatch (const Scope *first_scope, const Token *first_token, const Scope *second_scope, const Token *second_token, const Token *&new_first, const Token *&new_second)
 
static bool isUnknownType (const Token *start, const Token *end)
 
static const TokengetEnableIfReturnType (const Token *start)
 
template<class Predicate >
static bool checkReturns (const Function *function, bool unknown, bool emptyEnableIf, Predicate pred)
 
static std::string scopeTypeToString (Scope::ScopeType type)
 
static std::ostream & operator<< (std::ostream &s, Scope::ScopeType type)
 
static std::string accessControlToString (AccessControl access)
 
static const char * functionTypeToString (Function::Type type)
 
static std::string tokenToString (const Token *tok, const Tokenizer &tokenizer)
 
static std::string scopeToString (const Scope *scope, const Tokenizer &tokenizer)
 
static std::string tokenType (const Token *tok)
 
static const TypefindVariableTypeIncludingUsedNamespaces (const SymbolDatabase *symbolDatabase, const Scope *scope, const Token *typeTok)
 
static bool isDerivedFromItself (const std::string &thisName, const std::string &baseName)
 
static const TokenskipPointers (const Token *tok)
 
static const TokenskipPointersAndQualifiers (const Token *tok)
 
static const ScopefindEnumScopeInBase (const Scope *scope, const std::string &tokStr)
 
static bool hasEmptyCaptureList (const Token *tok)
 
static void checkVariableCallMatch (const Variable *callarg, const Variable *funcarg, size_t &same, size_t &fallback1, size_t &fallback2)
 
static std::string getTypeString (const Token *typeToken)
 
static bool hasMatchingConstructor (const Scope *classScope, const ValueType *argType)
 
template<class S , class T , REQUIRES("S must be a Scope class", std::is_convertible< S *, const Scope * >) , REQUIRES("T must be a Type class", std::is_convertible< T *, const Type * >) >
S * findRecordInNestedListImpl (S &thisScope, const std::string &name, bool isC)
 
template<class S , class T , REQUIRES("S must be a Scope class", std::is_convertible< S *, const Scope * >) , REQUIRES("T must be a Type class", std::is_convertible< T *, const Type * >) >
T * findTypeImpl (S &thisScope, const std::string &name)
 
static const Tokenparsedecl (const Token *type, ValueType *const valuetype, ValueType::Sign defaultSignedness, const Settings &settings, SourceLocation loc=SourceLocation::current())
 
static ValueType::Type getEnumType (const Scope *scope, const Platform &platform)
 
static void setAutoTokenProperties (Token *const autoTok)
 
static bool isContainerYieldPointer (Library::Container::Yield yield)
 
static const ScopegetClassScope (const Token *tok)
 
static const FunctiongetOperatorFunction (const Token *const tok)
 
static const FunctiongetFunction (const Token *tok)
 

Function Documentation

◆ accessControlToString()

static std::string accessControlToString ( AccessControl  access)
static

◆ checkReturns()

template<class Predicate >
static bool checkReturns ( const Function function,
bool  unknown,
bool  emptyEnableIf,
Predicate  pred 
)
static

◆ checkVariableCallMatch()

static void checkVariableCallMatch ( const Variable callarg,
const Variable funcarg,
size_t &  same,
size_t &  fallback1,
size_t &  fallback2 
)
static

◆ findEnumScopeInBase()

static const Scope* findEnumScopeInBase ( const Scope scope,
const std::string &  tokStr 
)
static

◆ findRecordInNestedListImpl()

template<class S , class T , REQUIRES("S must be a Scope class", std::is_convertible< S *, const Scope * >) , REQUIRES("T must be a Type class", std::is_convertible< T *, const Type * >) >
S* findRecordInNestedListImpl ( S &  thisScope,
const std::string &  name,
bool  isC 
)

Definition at line 6078 of file symboldatabase.cpp.

References Scope::eFunction.

◆ findTypeImpl()

template<class S , class T , REQUIRES("S must be a Scope class", std::is_convertible< S *, const Scope * >) , REQUIRES("T must be a Type class", std::is_convertible< T *, const Type * >) >
T* findTypeImpl ( S &  thisScope,
const std::string &  name 
)

Definition at line 6116 of file symboldatabase.cpp.

References emptyString.

◆ findVariableTypeIncludingUsedNamespaces()

static const Type* findVariableTypeIncludingUsedNamespaces ( const SymbolDatabase symbolDatabase,
const Scope scope,
const Token typeTok 
)
static

◆ functionTypeToString()

static const char* functionTypeToString ( Function::Type  type)
static

◆ getClassScope()

static const Scope* getClassScope ( const Token tok)
static

◆ getEnableIfReturnType()

static const Token* getEnableIfReturnType ( const Token start)
static

Definition at line 3049 of file symboldatabase.cpp.

References Token::link(), Token::Match(), Token::next(), precedes(), and Token::simpleMatch().

Referenced by checkReturns().

◆ getEnumType()

static ValueType::Type getEnumType ( const Scope scope,
const Platform platform 
)
static

◆ getFunction()

static const Function* getFunction ( const Token tok)
static

◆ getIncompleteNameID()

static std::string getIncompleteNameID ( const Token tok)
static

◆ getOperatorFunction()

static const Function* getOperatorFunction ( const Token *const  tok)
static

◆ getTypeString()

static std::string getTypeString ( const Token typeToken)
static

◆ hasEmptyCaptureList()

static bool hasEmptyCaptureList ( const Token tok)
static

Definition at line 5461 of file symboldatabase.cpp.

References Token::astParent(), and Token::simpleMatch().

◆ hasMatchingConstructor()

static bool hasMatchingConstructor ( const Scope classScope,
const ValueType argType 
)
static

Definition at line 5625 of file symboldatabase.cpp.

References Scope::functionList.

Referenced by Scope::findFunction().

◆ isContainerYieldElement()

static bool isContainerYieldElement ( Library::Container::Yield  yield)
static

◆ isContainerYieldPointer()

static bool isContainerYieldPointer ( Library::Container::Yield  yield)
static

◆ isDerivedFromItself()

static bool isDerivedFromItself ( const std::string &  thisName,
const std::string &  baseName 
)
static

Definition at line 4600 of file symboldatabase.cpp.

Referenced by Function::getOverriddenFunctionRecursive().

◆ isEnumDefinition()

static bool isEnumDefinition ( const Token tok)
static

◆ isExecutableScope()

static bool isExecutableScope ( const Token tok)
static

◆ isExpression()

static bool isExpression ( const Token tok)
static

◆ isOperator()

static bool isOperator ( const Token tokenDef)
static

Definition at line 2484 of file symboldatabase.cpp.

References Token::isOperatorKeyword(), startsWith(), and Token::str().

◆ isUnknownType()

static bool isUnknownType ( const Token start,
const Token end 
)
static

◆ operator<<()

static std::ostream& operator<< ( std::ostream &  s,
Scope::ScopeType  type 
)
static

Definition at line 3770 of file symboldatabase.cpp.

References scopeTypeToString().

◆ parsedecl()

static const Token * parsedecl ( const Token type,
ValueType *const  valuetype,
ValueType::Sign  defaultSignedness,
const Settings settings,
SourceLocation  loc = SourceLocation::current() 
)
static

◆ qualifiedName()

static std::string qualifiedName ( const Scope scope)
static

Definition at line 2691 of file symboldatabase.cpp.

References Scope::className, and Scope::nestedIn.

Referenced by usingNamespace().

◆ scopeToString()

static std::string scopeToString ( const Scope scope,
const Tokenizer tokenizer 
)
static

◆ scopeTypeToString()

static std::string scopeTypeToString ( Scope::ScopeType  type)
static

Definition at line 3729 of file symboldatabase.cpp.

Referenced by operator<<(), and SymbolDatabase::printXml().

◆ setAutoTokenProperties()

static void setAutoTokenProperties ( Token *const  autoTok)
static

◆ skipPointers()

static const Token* skipPointers ( const Token tok)
static

◆ skipPointersAndQualifiers()

static const Token* skipPointersAndQualifiers ( const Token tok)
static

Definition at line 5007 of file symboldatabase.cpp.

References Token::Match(), Token::next(), and skipPointers().

Referenced by Scope::isVariableDeclaration().

◆ skipScopeIdentifiers()

static const Token* skipScopeIdentifiers ( const Token tok)
static

◆ tokenToString()

static std::string tokenToString ( const Token tok,
const Tokenizer tokenizer 
)
static

◆ tokenType()

static std::string tokenType ( const Token tok)
static

◆ typesMatch()

static bool typesMatch ( const Scope first_scope,
const Token first_token,
const Scope second_scope,
const Token second_token,
const Token *&  new_first,
const Token *&  new_second 
)
static

◆ usingNamespace()

static bool usingNamespace ( const Scope scope,
const Token first,
const Token second,
int &  offset 
)
static