Cppcheck
Typedefs | Functions | Variables
token.cpp File Reference
#include "token.h"
#include "astutils.h"
#include "errortypes.h"
#include "library.h"
#include "settings.h"
#include "simplecpp.h"
#include "symboldatabase.h"
#include "tokenlist.h"
#include "utils.h"
#include "tokenrange.h"
#include "valueflow.h"
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <sstream>
#include <stack>
#include <type_traits>
#include <unordered_set>
#include <utility>

Go to the source code of this file.

Typedefs

using ValueIterator = std::list< ValueFlow::Value >::iterator
 

Functions

template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T * tokAtImpl (T *tok, int index)
 
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T * linkAtImpl (T *thisTok, int index)
 
static int multiComparePercent (const Token *tok, const char *&haystack, nonneg int varid)
 
static int multiCompareImpl (const Token *tok, const char *haystack, nonneg int varid)
 
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T * nextArgumentImpl (T *thisTok)
 
static bool isOperator (const Token *tok)
 
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T * findsimplematchImpl (T *const startTok, const char pattern[], size_t pattern_len)
 
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T * findsimplematchImpl (T *const startTok, const char pattern[], size_t pattern_len, const Token *const end)
 
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T * findmatchImpl (T *const startTok, const char pattern[], const nonneg int varId)
 
template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T * findmatchImpl (T *const startTok, const char pattern[], const Token *const end, const nonneg int varId)
 
static const TokengoToLeftParenthesis (const Token *start, const Token *end)
 
static const TokengoToRightParenthesis (const Token *start, const Token *end)
 
static std::string stringFromTokenRange (const Token *start, const Token *end)
 
static void astStringXml (const Token *tok, nonneg int indent, std::ostream &out)
 
static void indent (std::string &str, const nonneg int indent1, const nonneg int indent2)
 
static bool isAdjacent (const ValueFlow::Value &x, const ValueFlow::Value &y)
 
static bool removePointValue (std::list< ValueFlow::Value > &values, std::list< ValueFlow::Value >::iterator &x)
 
static bool removeContradiction (std::list< ValueFlow::Value > &values)
 
template<class Iterator >
static ValueIterator removeAdjacentValues (std::list< ValueFlow::Value > &values, ValueIterator x, Iterator start, Iterator last)
 
static void mergeAdjacent (std::list< ValueFlow::Value > &values)
 
static void removeOverlaps (std::list< ValueFlow::Value > &values)
 
static void removeContradictions (std::list< ValueFlow::Value > &values)
 
static bool sameValueType (const ValueFlow::Value &x, const ValueFlow::Value &y)
 
template<class Compare >
static const ValueFlow::ValuegetCompareValue (const std::list< ValueFlow::Value > &values, bool condition, MathLib::bigint path, Compare compare)
 
TokenfindTypeEnd (Token *tok)
 
TokenfindLambdaEndScope (Token *tok)
 
const TokenfindLambdaEndScope (const Token *tok)
 

Variables

static const std::unordered_set< std::string > controlFlowKeywords
 
static const std::unordered_set< std::string > stdTypes
 

Typedef Documentation

◆ ValueIterator

using ValueIterator = std::list<ValueFlow::Value>::iterator

Definition at line 2105 of file token.cpp.

Function Documentation

◆ astStringXml()

static void astStringXml ( const Token tok,
nonneg int  indent,
std::ostream &  out 
)
static

◆ findmatchImpl() [1/2]

template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T* findmatchImpl ( T *const  startTok,
const char  pattern[],
const nonneg int  varId 
)
static

Definition at line 1056 of file token.cpp.

References Token::Match().

Referenced by Token::findmatch().

◆ findmatchImpl() [2/2]

template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T* findmatchImpl ( T *const  startTok,
const char  pattern[],
const Token *const  end,
const nonneg int  varId 
)
static

Definition at line 1075 of file token.cpp.

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

◆ findsimplematchImpl() [1/2]

template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T* findsimplematchImpl ( T *const  startTok,
const char  pattern[],
size_t  pattern_len 
)
static

Definition at line 1017 of file token.cpp.

References Token::simpleMatch().

Referenced by Token::findsimplematch().

◆ findsimplematchImpl() [2/2]

template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T* findsimplematchImpl ( T *const  startTok,
const char  pattern[],
size_t  pattern_len,
const Token *const  end 
)
static

Definition at line 1037 of file token.cpp.

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

◆ getCompareValue()

template<class Compare >
static const ValueFlow::Value* getCompareValue ( const std::list< ValueFlow::Value > &  values,
bool  condition,
MathLib::bigint  path,
Compare  compare 
)
static

Definition at line 2573 of file token.cpp.

References ValueFlow::Value::intvalue.

Referenced by Token::getMaxValue(), and Token::getMinValue().

◆ goToLeftParenthesis()

static const Token* goToLeftParenthesis ( const Token start,
const Token end 
)
static

Definition at line 1480 of file token.cpp.

References Token::link(), and Token::next().

Referenced by Token::findExpressionStartEndTokens().

◆ goToRightParenthesis()

static const Token* goToRightParenthesis ( const Token start,
const Token end 
)
static

Definition at line 1497 of file token.cpp.

References Token::link(), and Token::previous().

Referenced by Token::findExpressionStartEndTokens().

◆ indent()

static void indent ( std::string &  str,
const nonneg int  indent1,
const nonneg int  indent2 
)
static

◆ isAdjacent()

static bool isAdjacent ( const ValueFlow::Value x,
const ValueFlow::Value y 
)
static

◆ isOperator()

static bool isOperator ( const Token tok)
static

Definition at line 909 of file token.cpp.

References Token::link(), and Token::strAt().

Referenced by Token::findClosingBracket().

◆ linkAtImpl()

template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T* linkAtImpl ( T *  thisTok,
int  index 
)
static

Definition at line 404 of file token.cpp.

Referenced by Token::linkAt().

◆ mergeAdjacent()

static void mergeAdjacent ( std::list< ValueFlow::Value > &  values)
static

◆ multiCompareImpl()

static int multiCompareImpl ( const Token tok,
const char *  haystack,
nonneg int  varid 
)
static

Definition at line 572 of file token.cpp.

References multiComparePercent(), and Token::str().

Referenced by Token::Match(), and Token::multiCompare().

◆ multiComparePercent()

static int multiComparePercent ( const Token tok,
const char *&  haystack,
nonneg int  varid 
)
static

◆ nextArgumentImpl()

template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T* nextArgumentImpl ( T *  thisTok)
static

Definition at line 856 of file token.cpp.

References Token::Match().

Referenced by Token::nextArgument().

◆ removeAdjacentValues()

template<class Iterator >
static ValueIterator removeAdjacentValues ( std::list< ValueFlow::Value > &  values,
ValueIterator  x,
Iterator  start,
Iterator  last 
)
static

Definition at line 2108 of file token.cpp.

References isAdjacent().

Referenced by mergeAdjacent().

◆ removeContradiction()

static bool removeContradiction ( std::list< ValueFlow::Value > &  values)
static

◆ removeContradictions()

static void removeContradictions ( std::list< ValueFlow::Value > &  values)
static

Definition at line 2208 of file token.cpp.

References removeContradiction(), and removeOverlaps().

Referenced by Token::addValue().

◆ removeOverlaps()

static void removeOverlaps ( std::list< ValueFlow::Value > &  values)
static

◆ removePointValue()

static bool removePointValue ( std::list< ValueFlow::Value > &  values,
std::list< ValueFlow::Value >::iterator &  x 
)
static

Definition at line 2035 of file token.cpp.

References ValueFlow::Value::Point.

Referenced by removeContradiction().

◆ sameValueType()

static bool sameValueType ( const ValueFlow::Value x,
const ValueFlow::Value y 
)
static

◆ stringFromTokenRange()

static std::string stringFromTokenRange ( const Token start,
const Token end 
)
static

Definition at line 1611 of file token.cpp.

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

Referenced by Token::expressionString().

◆ tokAtImpl()

template<class T , REQUIRES("T must be a Token class", std::is_convertible< T *, const Token * >) >
static T* tokAtImpl ( T *  tok,
int  index 
)
static

Definition at line 380 of file token.cpp.

Referenced by Token::tokAt().

Variable Documentation

◆ controlFlowKeywords

const std::unordered_set<std::string> controlFlowKeywords
static
Initial value:
= {
"goto",
"do",
"if",
"else",
"for",
"while",
"switch",
"case",
"break",
"continue",
"return"
}

Definition at line 89 of file token.cpp.

Referenced by Token::update_property_info().

◆ stdTypes

const std::unordered_set<std::string> stdTypes
static
Initial value:
= { "bool"
, "_Bool"
, "char"
, "double"
, "float"
, "int"
, "long"
, "short"
, "size_t"
, "void"
, "wchar_t"
}

Definition at line 168 of file token.cpp.

Referenced by Token::update_property_isStandardType().