Cppcheck
|
Check for null pointer usage (using ExecutionPath) More...
Public Member Functions | |
Nullpointer (Check *c, const SymbolDatabase *symbolDatabase_, const Library *lib) | |
Startup constructor. More... | |
![]() | |
ExecutionPath (Check *c, unsigned int id) | |
virtual | ~ExecutionPath () |
void | print () const |
print checkdata More... | |
virtual void | end (const std::list< ExecutionPath * > &, const Token *) const |
going out of scope - all execution paths end More... | |
bool | operator== (const ExecutionPath &e) const |
Private Member Functions | |
Nullpointer (Check *c, const unsigned int id, const std::string &name, const SymbolDatabase *symbolDatabase_, const Library *lib) | |
Create checking of specific variable: More... | |
ExecutionPath * | copy () |
Copy this check. More... | |
void | operator= (const Nullpointer &) |
no implementation => compiler error if used by accident More... | |
bool | is_equal (const ExecutionPath *e) const |
is other execution path equal? More... | |
const Token * | parse (const Token &tok, std::list< ExecutionPath * > &checks) const |
parse tokens More... | |
bool | parseCondition (const Token &tok, std::list< ExecutionPath * > &checks) |
parse condition. More... | |
void | parseLoopBody (const Token *tok, std::list< ExecutionPath * > &checks) const |
Parse loop body. More... | |
Static Private Member Functions | |
static void | setnull (std::list< ExecutionPath * > &checks, const unsigned int varid, bool null) |
variable is set to null More... | |
static void | dereference (std::list< ExecutionPath * > &checks, const Token *tok) |
Dereferencing variable. More... | |
Private Attributes | |
const SymbolDatabase * | symbolDatabase |
const Library * | library |
const std::string | varname |
variable name for this check (empty => dummy check) More... | |
bool | null |
is this variable null? More... | |
Additional Inherited Members | |
![]() | |
static void | bailOut (std::list< ExecutionPath * > &checks) |
bail out all execution paths More... | |
static void | bailOutVar (std::list< ExecutionPath * > &checks, const unsigned int varid) |
bail out execution paths with given variable id More... | |
static void | checkScope (const Token *tok, std::list< ExecutionPath * > &checks) |
![]() | |
unsigned int | numberOfIf |
number of if blocks More... | |
const unsigned int | varId |
![]() | |
Check *const | owner |
Check for null pointer usage (using ExecutionPath)
Definition at line 1420 of file checknullpointer.cpp.
|
inline |
|
inlineprivate |
Create checking of specific variable:
Definition at line 1431 of file checknullpointer.cpp.
|
inlineprivatevirtual |
Copy this check.
Implements ExecutionPath.
Definition at line 1440 of file checknullpointer.cpp.
References Nullpointer().
|
inlinestaticprivate |
Dereferencing variable.
Check if it is safe (if the variable is null there's an error)
checks | Checks |
tok | token where dereferencing happens |
Definition at line 1474 of file checknullpointer.cpp.
References Token::Match(), null, CheckNullPointer::nullPointerError(), ExecutionPath::owner, Token::str(), ExecutionPath::varId, Token::varId(), and varname.
Referenced by parse(), and parseCondition().
|
inlineprivatevirtual |
is other execution path equal?
Implements ExecutionPath.
Definition at line 1448 of file checknullpointer.cpp.
|
private |
no implementation => compiler error if used by accident
|
inlineprivatevirtual |
parse tokens
Implements ExecutionPath.
Definition at line 1499 of file checknullpointer.cpp.
References ExecutionPath::bailOutVar(), Variable::declarationId(), dereference(), Check::inconclusiveFlag(), Token::isConstOp(), Token::isOp(), Variable::isPointer(), CheckNullPointer::isPointerDeRef(), library, Token::link(), Token::linkAt(), Token::Match(), Variable::name(), Variable::nameToken(), Token::next(), ExecutionPath::owner, CheckNullPointer::parseFunctionCall(), Token::previous(), setnull(), Token::simpleMatch(), Token::str(), symbolDatabase, Token::tokAt(), Token::variable(), and Token::varId().
Referenced by parseLoopBody().
|
inlineprivatevirtual |
parse condition.
Reimplemented from ExecutionPath.
Definition at line 1581 of file checknullpointer.cpp.
References dereference(), Check::inconclusiveFlag(), CheckNullPointer::isPointerDeRef(), library, Token::Match(), Token::next(), ExecutionPath::owner, ExecutionPath::parseCondition(), CheckNullPointer::parseFunctionCall(), and Token::str().
|
inlineprivatevirtual |
Parse loop body.
tok | the first token in the loop body (the token after the {) |
checks | The execution paths |
Reimplemented from ExecutionPath.
Definition at line 1601 of file checknullpointer.cpp.
References Token::Match(), Token::next(), and parse().
|
inlinestaticprivate |
variable is set to null
Definition at line 1460 of file checknullpointer.cpp.
References null, and ExecutionPath::varId.
Referenced by parse().
|
private |
Definition at line 1428 of file checknullpointer.cpp.
Referenced by parse(), and parseCondition().
|
private |
is this variable null?
Definition at line 1457 of file checknullpointer.cpp.
Referenced by dereference(), is_equal(), and setnull().
|
private |
Definition at line 1427 of file checknullpointer.cpp.
Referenced by parse().
|
private |
variable name for this check (empty => dummy check)
Definition at line 1454 of file checknullpointer.cpp.
Referenced by dereference(), and is_equal().