Cppcheck
Functions | Variables
checkcondition.cpp File Reference
#include "checkcondition.h"
#include "astutils.h"
#include "library.h"
#include "platform.h"
#include "settings.h"
#include "symboldatabase.h"
#include "token.h"
#include "tokenize.h"
#include "utils.h"
#include "vfvalue.h"
#include "checkother.h"
#include <algorithm>
#include <limits>
#include <list>
#include <set>
#include <sstream>
#include <utility>
#include <vector>

Go to the source code of this file.

Functions

static bool isParameterChanged (const Token *partok)
 
static void getnumchildren (const Token *tok, std::list< MathLib::bigint > &numchildren)
 
static bool inBooleanFunction (const Token *tok)
 
static bool isOperandExpanded (const Token *tok)
 
static bool isNonConstFunctionCall (const Token *ftok, const Library &library)
 
static std::string innerSmtString (const Token *tok)
 
static std::string invertOperatorForOperandSwap (std::string s)
 
template<typename T >
static int sign (const T v)
 
template<typename T >
static int sufficientCondition (std::string op1, const bool not1, const T value1, std::string op2, const bool not2, const T value2, const bool isAnd)
 
template<typename T >
static bool checkIntRelation (const std::string &op, const T value1, const T value2)
 
static bool checkFloatRelation (const std::string &op, const double value1, const double value2)
 
template<class T >
static T getvalue3 (const T value1, const T value2)
 
template<>
double getvalue3 (const double value1, const double value2)
 
template<class T >
static T getvalue (const int test, const T value1, const T value2)
 
static bool parseComparison (const Token *comp, bool &not1, std::string &op, std::string &value, const Token *&expr, bool &inconclusive)
 
static std::string conditionString (bool not1, const Token *expr1, const std::string &op, const std::string &value1)
 
static std::string conditionString (const Token *tok)
 
static bool isIfConstexpr (const Token *tok)
 
static int countPar (const Token *tok1, const Token *tok2)
 

Variables

static const CWE uncheckedErrorConditionCWE (391U)
 
static const CWE CWE398 (398U)
 
static const CWE CWE570 (570U)
 
static const CWE CWE571 (571U)
 

Function Documentation

◆ checkFloatRelation()

static bool checkFloatRelation ( const std::string &  op,
const double  value1,
const double  value2 
)
static

Definition at line 989 of file checkcondition.cpp.

Referenced by CheckCondition::checkIncorrectLogicOperator().

◆ checkIntRelation()

template<typename T >
static bool checkIntRelation ( const std::string &  op,
const T  value1,
const T  value2 
)
static

Definition at line 979 of file checkcondition.cpp.

Referenced by CheckCondition::checkIncorrectLogicOperator().

◆ conditionString() [1/2]

static std::string conditionString ( bool  not1,
const Token expr1,
const std::string &  op,
const std::string &  value1 
)
static

◆ conditionString() [2/2]

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

◆ countPar()

static int countPar ( const Token tok1,
const Token tok2 
)
static

Definition at line 1401 of file checkcondition.cpp.

References Token::next().

Referenced by CheckCondition::clarifyCondition().

◆ getnumchildren()

static void getnumchildren ( const Token tok,
std::list< MathLib::bigint > &  numchildren 
)
static

◆ getvalue()

template<class T >
static T getvalue ( const int  test,
const T  value1,
const T  value2 
)
inlinestatic

Definition at line 1014 of file checkcondition.cpp.

◆ getvalue3() [1/2]

template<>
double getvalue3 ( const double  value1,
const double  value2 
)

Definition at line 1007 of file checkcondition.cpp.

◆ getvalue3() [2/2]

template<class T >
static T getvalue3 ( const T  value1,
const T  value2 
)
static

Definition at line 998 of file checkcondition.cpp.

◆ inBooleanFunction()

static bool inBooleanFunction ( const Token tok)
static

◆ innerSmtString()

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

◆ invertOperatorForOperandSwap()

static std::string invertOperatorForOperandSwap ( std::string  s)
static

Definition at line 914 of file checkcondition.cpp.

Referenced by parseComparison().

◆ isIfConstexpr()

static bool isIfConstexpr ( const Token tok)
static

◆ isNonConstFunctionCall()

static bool isNonConstFunctionCall ( const Token ftok,
const Library library 
)
static

◆ isOperandExpanded()

static bool isOperandExpanded ( const Token tok)
static

◆ isParameterChanged()

static bool isParameterChanged ( const Token partok)
static

◆ parseComparison()

static bool parseComparison ( const Token comp,
bool &  not1,
std::string &  op,
std::string &  value,
const Token *&  expr,
bool &  inconclusive 
)
static

◆ sign()

template<typename T >
static int sign ( const T  v)
static

◆ sufficientCondition()

template<typename T >
static int sufficientCondition ( std::string  op1,
const bool  not1,
const T  value1,
std::string  op2,
const bool  not2,
const T  value2,
const bool  isAnd 
)
static

Definition at line 930 of file checkcondition.cpp.

References op1, op2, and sign().

Referenced by CheckCondition::checkIncorrectLogicOperator().

Variable Documentation

◆ CWE398

const CWE CWE398(398U) ( 398U  )
static

◆ CWE570

const CWE CWE570(570U) ( 570U  )
static

◆ CWE571

const CWE CWE571(571U) ( 571U  )
static

◆ uncheckedErrorConditionCWE

const CWE uncheckedErrorConditionCWE(391U) ( 391U  )
static