Cppcheck
|
#include "checkautovariables.h"
#include "astutils.h"
#include "library.h"
#include "settings.h"
#include "symboldatabase.h"
#include "token.h"
#include "tokenize.h"
#include "valueflow.h"
#include "vfvalue.h"
#include <algorithm>
#include <list>
#include <unordered_set>
#include <utility>
#include <vector>
Go to the source code of this file.
Functions | |
static bool | isPtrArg (const Token *tok) |
static bool | isArrayArg (const Token *tok, const Settings &settings) |
static bool | isArrayVar (const Token *tok) |
static bool | isRefPtrArg (const Token *tok) |
static bool | isNonReferenceArg (const Token *tok) |
static bool | isAutoVar (const Token *tok) |
static bool | isAutoVarArray (const Token *tok) |
static bool | isLocalContainerBuffer (const Token *tok) |
static bool | isAddressOfLocalVariable (const Token *expr) |
static bool | variableIsUsedInScope (const Token *start, nonneg int varId, const Scope *scope) |
static bool | isAutoVariableRHS (const Token *tok) |
static bool | hasOverloadedAssignment (const Token *tok, bool &inconclusive) |
static bool | isInScope (const Token *tok, const Scope *scope) |
static bool | isDeadScope (const Token *tok, const Scope *scope) |
static int | getPointerDepth (const Token *tok) |
static bool | isDeadTemporary (const Token *tok, const Token *expr, const Library *library) |
static bool | isEscapedReference (const Variable *var) |
static bool | isDanglingSubFunction (const Token *tokvalue, const Token *tok) |
static const Variable * | getParentVar (const Token *tok) |
static bool | isAssignedToNonLocal (const Token *tok) |
Variables | |
static const CWE | CWE398 (398U) |
static const CWE | CWE562 (562U) |
static const CWE | CWE590 (590U) |
Definition at line 520 of file checkautovariables.cpp.
References Token::astOperand1(), Token::simpleMatch(), and Token::variable().
Referenced by CheckAutoVariables::checkVarLifetimeScope(), and isAssignedToNonLocal().
|
static |
Definition at line 452 of file checkautovariables.cpp.
References Token::next(), ValueType::pointer, Token::simpleMatch(), Token::typeDecl(), and Token::valueType().
Referenced by CheckAutoVariables::checkVarLifetimeScope().
|
static |
Definition at line 244 of file checkautovariables.cpp.
References Token::astParent(), inconclusive, Token::isC(), Token::simpleMatch(), and Token::valueType().
Referenced by CheckAutoVariables::autoVariables().
|
static |
Definition at line 169 of file checkautovariables.cpp.
References Token::astOperand1(), Token::astOperand2(), isAutoVar(), Token::isCast(), Token::isUnaryOp(), Token::Match(), Token::originalName(), Token::str(), and Token::variable().
Referenced by isAutoVariableRHS().
Definition at line 58 of file checkautovariables.cpp.
References Scope::className, Variable::isArgument(), Variable::isArray(), Library::isentrypoint(), Settings::library, Variable::scope(), and Token::variable().
Referenced by CheckAutoVariables::autoVariables().
|
static |
Definition at line 64 of file checkautovariables.cpp.
References Variable::isArgument(), Variable::isArray(), and Token::variable().
Referenced by CheckAutoVariables::autoVariables().
|
static |
Definition at line 529 of file checkautovariables.cpp.
References astIsRHS(), Token::astParent(), getParentVar(), Variable::isLocal(), Variable::isStatic(), and Token::simpleMatch().
Referenced by CheckAutoVariables::checkVarLifetimeScope().
|
static |
Definition at line 82 of file checkautovariables.cpp.
References Variable::isLocal(), Variable::isReference(), Variable::isStatic(), Token::Match(), Token::tokAt(), and Token::variable().
Referenced by CheckAutoVariables::autoVariables(), and isAddressOfLocalVariable().
|
static |
Definition at line 106 of file checkautovariables.cpp.
References Token::astOperand1(), Token::astOperand2(), Variable::isArgument(), Variable::isArray(), Variable::isLocal(), Variable::isPointer(), Variable::isStatic(), ValueFlow::Value::isTokValue(), Token::isUnaryOp(), Token::simpleMatch(), Token::str(), ValueFlow::Value::tokvalue, Token::values(), and Token::variable().
Referenced by isAutoVariableRHS().
|
static |
Definition at line 240 of file checkautovariables.cpp.
References isAddressOfLocalVariable(), isAutoVarArray(), and isLocalContainerBuffer().
Referenced by CheckAutoVariables::autoVariables().
Definition at line 501 of file checkautovariables.cpp.
References Token::astParent(), exprDependsOnThis(), Variable::isLocal(), Token::Match(), Scope::nestedInFunction(), Token::previous(), Token::scope(), Token::simpleMatch(), and Token::variable().
Referenced by CheckAutoVariables::checkVarLifetimeScope().
Definition at line 438 of file checkautovariables.cpp.
References Scope::bodyEnd, Variable::isExtern(), Variable::isLocal(), Variable::isStatic(), precedes(), Token::scope(), and Token::variable().
Referenced by CheckAutoVariables::checkVarLifetimeScope().
|
static |
Definition at line 466 of file checkautovariables.cpp.
References astIsRHS(), Token::astParent(), Token::astTop(), isTemporary(), Token::link(), nextAfterAstRightmostLeaf(), precedes(), and Token::simpleMatch().
Referenced by CheckAutoVariables::checkVarLifetimeScope().
|
static |
Definition at line 486 of file checkautovariables.cpp.
References Token::astOperand2(), Variable::declEndToken(), Variable::isReference(), isTemporary(), and Token::simpleMatch().
Referenced by CheckAutoVariables::checkVarLifetimeScope().
Definition at line 413 of file checkautovariables.cpp.
References Variable::isArgument(), Variable::isExtern(), Variable::isGlobal(), Variable::isReference(), Variable::isStatic(), Scope::nestedList, Token::scope(), and Token::variable().
Referenced by CheckAutoVariables::checkVarLifetimeScope().
|
static |
Definition at line 146 of file checkautovariables.cpp.
References astContainerYield(), Token::astOperand1(), Token::astOperand2(), Library::Container::BUFFER, Library::Container::BUFFER_NT, Variable::isLocal(), Variable::isStatic(), Token::simpleMatch(), Token::str(), and Token::variable().
Referenced by isAutoVariableRHS().
|
static |
Definition at line 76 of file checkautovariables.cpp.
References Variable::isArgument(), Variable::isPointer(), Variable::isReference(), Variable::type(), ValueType::type, Variable::valueType(), and Token::variable().
Referenced by CheckAutoVariables::assignFunctionArg().
|
static |
Definition at line 52 of file checkautovariables.cpp.
References Variable::isArgument(), Variable::isPointer(), and Token::variable().
Referenced by CheckAutoVariables::autoVariables().
|
static |
Definition at line 70 of file checkautovariables.cpp.
References Variable::isArgument(), Variable::isPointer(), Variable::isReference(), and Token::variable().
Referenced by CheckAutoVariables::autoVariables().
|
static |
Definition at line 192 of file checkautovariables.cpp.
References Scope::bodyEnd, Scope::eDo, Scope::eFor, Scope::eWhile, Token::next(), and Token::simpleMatch().
Referenced by CheckAutoVariables::assignFunctionArg().
|
static |
|
static |
Referenced by CheckAutoVariables::errorAutoVariableAssignment(), CheckAutoVariables::errorDanglingReference(), CheckAutoVariables::errorDanglingTemporaryLifetime(), CheckAutoVariables::errorDanglingTempReference(), CheckAutoVariables::errorDanglngLifetime(), CheckAutoVariables::errorInvalidLifetime(), CheckAutoVariables::errorReturnDanglingLifetime(), CheckAutoVariables::errorReturnReference(), and CheckAutoVariables::errorReturnTempReference().
|
static |
Referenced by CheckAutoVariables::errorInvalidDeallocation().