Cppcheck
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Nullpointer Class Reference

Check for null pointer usage (using ExecutionPath) More...

Inheritance diagram for Nullpointer:
ExecutionPath

Public Member Functions

 Nullpointer (Check *c, const SymbolDatabase *symbolDatabase_, const Library *lib)
 Startup constructor. More...
 
- Public Member Functions inherited from ExecutionPath
 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...
 
ExecutionPathcopy ()
 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 Tokenparse (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 SymbolDatabasesymbolDatabase
 
const Librarylibrary
 
const std::string varname
 variable name for this check (empty => dummy check) More...
 
bool null
 is this variable null? More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ExecutionPath
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)
 
- Public Attributes inherited from ExecutionPath
unsigned int numberOfIf
 number of if blocks More...
 
const unsigned int varId
 
- Protected Attributes inherited from ExecutionPath
Check *const owner
 

Detailed Description

Check for null pointer usage (using ExecutionPath)

Definition at line 1420 of file checknullpointer.cpp.

Constructor & Destructor Documentation

Nullpointer::Nullpointer ( Check c,
const SymbolDatabase symbolDatabase_,
const Library lib 
)
inline

Startup constructor.

Definition at line 1423 of file checknullpointer.cpp.

Referenced by copy().

Nullpointer::Nullpointer ( Check c,
const unsigned int  id,
const std::string &  name,
const SymbolDatabase symbolDatabase_,
const Library lib 
)
inlineprivate

Create checking of specific variable:

Definition at line 1431 of file checknullpointer.cpp.

Member Function Documentation

ExecutionPath* Nullpointer::copy ( )
inlineprivatevirtual

Copy this check.

Implements ExecutionPath.

Definition at line 1440 of file checknullpointer.cpp.

References Nullpointer().

static void Nullpointer::dereference ( std::list< ExecutionPath * > &  checks,
const Token tok 
)
inlinestaticprivate

Dereferencing variable.

Check if it is safe (if the variable is null there's an error)

Parameters
checksChecks
toktoken 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().

bool Nullpointer::is_equal ( const ExecutionPath e) const
inlineprivatevirtual

is other execution path equal?

Implements ExecutionPath.

Definition at line 1448 of file checknullpointer.cpp.

References null, and varname.

void Nullpointer::operator= ( const Nullpointer )
private

no implementation => compiler error if used by accident

const Token* Nullpointer::parse ( const Token tok,
std::list< ExecutionPath * > &  checks 
) const
inlineprivatevirtual
bool Nullpointer::parseCondition ( const Token tok,
std::list< ExecutionPath * > &  checks 
)
inlineprivatevirtual
void Nullpointer::parseLoopBody ( const Token tok,
std::list< ExecutionPath * > &  checks 
) const
inlineprivatevirtual

Parse loop body.

Parameters
tokthe first token in the loop body (the token after the {)
checksThe execution paths

Reimplemented from ExecutionPath.

Definition at line 1601 of file checknullpointer.cpp.

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

static void Nullpointer::setnull ( std::list< ExecutionPath * > &  checks,
const unsigned int  varid,
bool  null 
)
inlinestaticprivate

variable is set to null

Definition at line 1460 of file checknullpointer.cpp.

References null, and ExecutionPath::varId.

Referenced by parse().

Member Data Documentation

const Library* Nullpointer::library
private

Definition at line 1428 of file checknullpointer.cpp.

Referenced by parse(), and parseCondition().

bool Nullpointer::null
private

is this variable null?

Definition at line 1457 of file checknullpointer.cpp.

Referenced by dereference(), is_equal(), and setnull().

const SymbolDatabase* Nullpointer::symbolDatabase
private

Definition at line 1427 of file checknullpointer.cpp.

Referenced by parse().

const std::string Nullpointer::varname
private

variable name for this check (empty => dummy check)

Definition at line 1454 of file checknullpointer.cpp.

Referenced by dereference(), and is_equal().


The documentation for this class was generated from the following file: