doc: updated doxygen comments. three groups where created - 'GUI', 'Core' and 'Checks'

This commit is contained in:
Daniel Marjamäki 2009-07-17 10:49:01 +02:00
parent 968a6bdd2d
commit 7df3670128
36 changed files with 265 additions and 72 deletions

View File

@ -24,6 +24,8 @@
#include "ui_about.h"
/// @addtogroup GUI
/// @{
/**
* @brief About dialog
@ -38,5 +40,5 @@ public:
private:
Ui::About mUI;
};
/// @}
#endif // ABOUT_DIALOG_H

View File

@ -23,6 +23,9 @@
#include <QLineEdit>
#include "ui_application.h"
/// @addtogroup GUI
/// @{
/**
* @brief Dialog to edit a startable application.
* User can open errors with user specified applications. This is a dialog
@ -79,5 +82,5 @@ protected:
Ui::ApplicationDialog mUI;
private:
};
/// @}
#endif // APPLICATIONDIALOG_H

View File

@ -22,6 +22,9 @@
#include <QObject>
#include <QSettings>
/// @addtogroup GUI
/// @{
/**
* @brief List of applications user has specified to open errors with
@ -159,5 +162,5 @@ protected:
QList<ApplicationType> mApplications;
private:
};
/// @}
#endif // APPLICATIONLIST_H

View File

@ -25,6 +25,9 @@
#include "../src/settings.h"
#include "threadresult.h"
/// @addtogroup GUI
/// @{
/**
* @brief Thread to run cppcheck
*
@ -91,5 +94,5 @@ protected:
CppCheck mCppcheck;
private:
};
/// @}
#endif // CHECKTHREAD_H

View File

@ -19,6 +19,10 @@
#ifndef COMMON_H
#define COMMON_H
/// @addtogroup GUI
/// @{
/**
* @brief List of error types to show
*
@ -56,5 +60,5 @@ ShowTypes;
#define SETTINGS_LANGUAGE "Application language"
#define SETTINGS_TOOLBARS_SHOW "Toolbars/ShowStandard"
/// @}
#endif

View File

@ -26,6 +26,10 @@
#include <QTextStream>
#include "report.h"
/// @addtogroup GUI
/// @{
/**
* @brief CSV text file report.
* This report exports results as CSV (comma separated values). CSV files are
@ -68,5 +72,5 @@ private:
*/
QTextStream mTxtWriter;
};
/// @}
#endif // CSV_REPORT_H

View File

@ -23,6 +23,9 @@
#include <QString>
#include "ui_file.h"
/// @addtogroup GUI
/// @{
/**
* @brief File view -dialog.
@ -58,5 +61,5 @@ protected:
Ui::Fileview mUI;
};
/// @}
#endif // FILEVIEW_DIALOG_H

View File

@ -34,6 +34,11 @@
#include "ui_main.h"
class ThreadHandler;
/// @addtogroup GUI
/// @{
/**
* @brief Main window for cppcheck-gui
*
@ -308,5 +313,5 @@ protected:
QString mCurrentDirectory;
};
/// @}
#endif // MAINWINDOW_H

View File

@ -24,6 +24,10 @@
#include <QStringList>
#include <QXmlStreamReader>
/// @addtogroup GUI
/// @{
/**
* @brief A class that reads and writes (TODO) project files.
* The project files contain project-specific settings for checking. For
@ -85,5 +89,5 @@ private:
*/
QStringList mIncludeDirs;
};
/// @}
#endif // PROJECT_FILE_H

View File

@ -24,6 +24,9 @@
#include <QStringList>
#include <QFile>
/// @addtogroup GUI
/// @{
/**
* @brief A base class for reports.
*/
@ -88,5 +91,5 @@ private:
*/
QFile mFile;
};
/// @}
#endif // REPORT_H

View File

@ -31,6 +31,10 @@
class Report;
/// @addtogroup GUI
/// @{
/**
* @brief Cppcheck's results are shown in this tree
*
@ -362,5 +366,5 @@ protected:
private:
};
/// @}
#endif // RESULTSTREE_H

View File

@ -29,6 +29,9 @@
#include "report.h"
#include "ui_resultsview.h"
/// @addtogroup GUI
/// @{
/**
* @brief Widget to show cppcheck progressbar and result
*
@ -179,5 +182,5 @@ protected:
private:
};
/// @}
#endif // RESULTSVIEW_H

View File

@ -33,6 +33,8 @@
#include <QKeyEvent>
#include "ui_settings.h"
/// @addtogroup GUI
/// @{
/**
* @brief Settings dialog
@ -186,5 +188,5 @@ protected:
Ui::Settings mUI;
private:
};
/// @}
#endif // SETTINGSDIALOG_H

View File

@ -28,6 +28,10 @@
#include "checkthread.h"
#include "resultsview.h"
/// @addtogroup GUI
/// @{
/**
* @brief This class handles creating threadresult and starting threads
*
@ -147,5 +151,5 @@ protected:
int mRunningThreadCount;
private:
};
/// @}
#endif // THREADHANDLER_H

View File

@ -26,6 +26,9 @@
#include <QVariant>
#include "../src/errorlogger.h"
/// @addtogroup GUI
/// @{
/**
* @brief Threads use this class to obtain new files to process and to publish results
*
@ -125,5 +128,5 @@ protected:
int mProgress;
private:
};
/// @}
#endif // THREADRESULT_H

View File

@ -23,6 +23,10 @@
#include <QTranslator>
#include <QObject>
/// @addtogroup GUI
/// @{
class TranslationHandler : QObject
{
Q_OBJECT
@ -41,5 +45,5 @@ protected:
QTranslator *mTranslator;
private:
};
/// @}
#endif // TRANSLATIONHANDLER_H

View File

@ -26,6 +26,10 @@
#include <QTextStream>
#include "report.h"
/// @addtogroup GUI
/// @{
/**
* @brief Text file report.
* This report mimics the output of the command line cppcheck.
@ -66,5 +70,5 @@ private:
*/
QTextStream mTxtWriter;
};
/// @}
#endif // TXT_REPORT_H

View File

@ -26,6 +26,10 @@
#include <QXmlStreamWriter>
#include "report.h"
/// @addtogroup GUI
/// @{
/**
* @brief XML file report.
* This report outputs XML-formatted report. The XML format must match command
@ -66,5 +70,5 @@ private:
*/
QXmlStreamWriter mXmlWriter;
};
/// @}
#endif // XML_REPORT_H

View File

@ -27,6 +27,9 @@
#include <list>
#include <iostream>
/// @addtogroup Core
/// @{
/**
* @brief Interface class that cppcheck uses to communicate with the checks.
* All checking classes must inherit from this class
@ -52,7 +55,7 @@ public:
instances().remove(this);
}
/** get instances of this */
/** List of registered check classes. This is used by Cppcheck to run checks and generate documentation */
static std::list<Check *> &instances()
{
static std::list<Check *> _instances;
@ -69,10 +72,10 @@ public:
/** get error messages */
virtual void getErrorMessages() = 0;
/** class name */
/** class name, used to generate documentation */
virtual std::string name() const = 0;
/** get information about this class */
/** get information about this class, used to generate documentation */
virtual std::string classInfo() const = 0;
protected:
@ -119,7 +122,7 @@ protected:
}
private:
/** compare the names of Check classes */
/** compare the names of Check classes, used when sorting the Check descendants */
bool operator<(const Check *other) const
{
return (name() < other->name());
@ -127,7 +130,7 @@ private:
};
/// @}
#endif

View File

@ -26,6 +26,10 @@
#include "token.h"
#include <list>
/// @addtogroup Checks
/// @{
class CheckAutoVariables : public Check
{
public:
@ -84,7 +88,7 @@ private:
" * assigning address of an variable to an effective parameter of a function\n";
}
};
/// @}
//---------------------------------------------------------------------------
#endif

View File

@ -30,6 +30,10 @@ class ErrorLogger;
class Token;
class Tokenizer;
/// @addtogroup Checks
/// @{
class CheckBufferOverrun : public Check
{
public:
@ -93,7 +97,7 @@ private:
return "out of bounds checking";
}
};
/// @}
//---------------------------------------------------------------------------
#endif

View File

@ -26,6 +26,10 @@
class Token;
/// @addtogroup Checks
/// @{
class CheckClass : public Check
{
public:
@ -137,6 +141,7 @@ private:
" * Are there unused private functions\n";
}
};
/// @}
//---------------------------------------------------------------------------
#endif

View File

@ -24,6 +24,9 @@
#include "check.h"
/// @addtogroup Checks
/// @{
class CheckDangerousFunctions : public Check
{
public:
@ -75,7 +78,7 @@ private:
" * scanf\n";
}
};
/// @}
//---------------------------------------------------------------------------
#endif

View File

@ -25,6 +25,10 @@
#include "tokenize.h"
#include "errorlogger.h"
/// @addtogroup Checks
/// @{
class CheckHeaders
{
public:
@ -42,7 +46,7 @@ private:
return "Headers";
}
};
/// @}
//---------------------------------------------------------------------------
#endif

View File

@ -23,12 +23,16 @@
#define checkmemoryleakH
//---------------------------------------------------------------------------
/// @addtogroup Checks
/// @{
/**
* Check for memory leaks
*
* The checking is split up into two specialized classes.
* CheckMemoryLeakInFunction can detect when a function variable is allocated but not deallocated properly.
* CheckMemoryLeakInClass can detect when a class variable is allocated but not deallocated properly.
* - CheckMemoryLeakInFunction can detect when a function variable is allocated but not deallocated properly.
* - CheckMemoryLeakInClass can detect when a class variable is allocated but not deallocated properly.
*/
#include "check.h"
@ -39,15 +43,35 @@
class Token;
/** Base class for memory leaks checking */
/** @brief Base class for memory leaks checking */
class CheckMemoryLeak
{
private:
const Tokenizer * const tokenizer;
ErrorLogger * const errorLogger;
ErrorLogger::ErrorMessage errmsg(const Token *tok, Severity::e severity, const std::string &id, const std::string &msg) const;
/** Disable the default constructors */
CheckMemoryLeak();
/** Disable the default constructors */
CheckMemoryLeak(const CheckMemoryLeak &);
/**
* Report error. Similar with the function Check::reportError
* @param location the token where the error occurs
* @param severity the severity of the bug
* @param id type of message
* @param msg text
*/
ErrorLogger::ErrorMessage errmsg(const Token *location, Severity::e severity, const std::string &id, const std::string &msg) const;
/**
* Report error. Similar with the function Check::reportError
* @param callstack callstack of error
* @param severity the severity of the bug
* @param id type of message
* @param msg text
*/
ErrorLogger::ErrorMessage errmsg(const std::list<const Token *> &callstack, Severity::e severity, const std::string &id, const std::string &msg) const;
public:
@ -82,21 +106,23 @@ public:
/**
* Check function variables.
* @brief CheckMemoryLeakInFunction detects when a function variable is allocated but not deallocated properly.
*
* The checking is done by looking at each function variable separately. By repeating these 4 steps over and over:
* 1. locate a function variable
* 2. create a simple token list that describes the usage of the function variable.
* 3. simplify the token list.
* 4. finally, check if the simplified token list contain any leaks.
* -# locate a function variable
* -# create a simple token list that describes the usage of the function variable.
* -# simplify the token list.
* -# finally, check if the simplified token list contain any leaks.
*/
class CheckMemoryLeakInFunction : public Check, private CheckMemoryLeak
class CheckMemoryLeakInFunction : private Check, private CheckMemoryLeak
{
public:
/** This constructor is used when registering this class */
CheckMemoryLeakInFunction() : Check(), CheckMemoryLeak(0, 0)
{ }
/** This constructor is used when running checks */
CheckMemoryLeakInFunction(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger)
{ }
@ -107,9 +133,6 @@ public:
checkMemoryLeak.check();
}
#ifndef UNIT_TESTING
private:
#endif
void check();
private:
@ -125,27 +148,75 @@ private:
*/
bool notvar(const Token *tok, const char *varnames[], bool endpar = false);
/**
* Inspect a function call. the call_func and getcode are recursive
* @param tok token where the function call occurs
* @param callstack callstack
* @param varnames the variable name that is currently checked
* @param alloctype if memory is allocated, this indicates the type of allocation
* @param dealloctype if memory is deallocated, this indicates the type of deallocation
* @param all is the code simplified according to the "--all" rules or not?
* @param sz not used by call_func - see getcode
* @return These are the possible return values:
* - NULL : no significant code
* - "recursive" : recursive function
* - "alloc" : the function returns allocated memory
* - "dealloc" : the function deallocates the variable
* - "dealloc_"
* - "use" : the variable is used (unknown usage of the variable => the checking bails out)
* - "callfunc"
* - "&use"
*/
const char * call_func(const Token *tok, std::list<const Token *> callstack, const char *varnames[], AllocType &alloctype, AllocType &dealloctype, bool &all, unsigned int sz);
/**
* Extract a new tokens list that is easier to parse than the "tokens"
* Extract a new tokens list that is easier to parse than the "_tokenizer->tokens()", the
* extracted tokens list describes how the given variable is used.
* The getcode and call_func are recursive
* @param tok start parse token
* @param callstack callstack
* @param varname name of variable
* @param alloctype
* @param dealloctype
* @param alloctype keep track of what type of allocation is used
* @param dealloctype keeps track of what type of deallocation is used
* @param classmember should be set if the inspected function is a class member
* @param all has the getcode been simplified according to the "--all" rules?
* @param sz size of type, used to check for mismatching size of allocation. for example "int *a;" => the sz is "sizeof(int)"
* @return Newly allocated token array. Caller needs to release reserved
* memory by calling Tokenizer::deleteTokens(returnValue);
* Returned tokens:
* - alloc : the variable is allocated
* - dealloc : the variable is deallocated
* - realloc : the variable is reallocated
* - use : unknown usage -> bail out checking of this execution path
* - &use : the address of the variable is taken
* - ::use : calling member function of class
* - assign : the variable is assigned a new value
* - if : there is an "if"
* - if(var) : corresponds with "if ( var != 0 )"
* - if(!var) : corresponds with "if ( var == 0 )"
* - ifv : the variable is used in some way in a "if"
* - loop : corresponds to either a "for" or a "while"
* - continue : corresponds to "continue"
* - break : corresponds to "break"
* - goto : corresponds to a "goto"
* - return : corresponds to a "return"
*/
Token *getcode(const Token *tok, std::list<const Token *> callstack, const char varname[], AllocType &alloctype, AllocType &dealloctype, bool classmember, bool &all, unsigned int sz);
/**
* Simplify code e.g. by replacing empty "{ }" with ";"
* @param tok first token. The tokens list can be modified.
* @param all is the code simplified according to the "--all" rules or not
*/
void simplifycode(Token *tok, bool &all);
/**
* Checking the variable varname
* @param Tok1 start token
* @param varname name of variable
* @param classmember is the scope inside a class member function
* @param sz size of type.. if the variable is a "int *" then sz should be "sizeof(int)"
*/
void checkScope(const Token *Tok1, const char varname[], bool classmember, unsigned int sz);
void getErrorMessages()
@ -165,11 +236,10 @@ private:
/**
* Check class variables
* variables that are allocated in the constructor should be deallocated in the destructor
* @brief %Check class variables, variables that are allocated in the constructor should be deallocated in the destructor
*/
class CheckMemoryLeakInClass : public Check, private CheckMemoryLeak
class CheckMemoryLeakInClass : private Check, private CheckMemoryLeak
{
public:
CheckMemoryLeakInClass() : Check(), CheckMemoryLeak(0, 0)
@ -185,9 +255,6 @@ public:
checkMemoryLeak.check();
}
#ifndef UNIT_TESTING
private:
#endif
void check();
private:
@ -210,12 +277,9 @@ private:
/**
* Check class variables
* variables that are allocated in the constructor should be deallocated in the destructor
*/
/** @brief detect simple memory leaks for struct members */
class CheckMemoryLeakStructMember : public Check, private CheckMemoryLeak
class CheckMemoryLeakStructMember : private Check, private CheckMemoryLeak
{
public:
CheckMemoryLeakStructMember() : Check(), CheckMemoryLeak(0, 0)
@ -238,16 +302,6 @@ public:
private:
void error(const Token *tok, const Severity::e severity, const std::string &id, const std::string &msg)
{
reportError(tok, severity, id, msg);
}
void error(const std::list<const Token *> &callstack, const Severity::e severity, const std::string &id, const std::string &msg)
{
reportError(callstack, severity, id, msg);
}
void getErrorMessages()
{ }
@ -258,9 +312,9 @@ private:
std::string classInfo() const
{
return "Don't forget to free struct members";
return "Don't forget to deallocate struct members";
}
};
/// @}
//---------------------------------------------------------------------------
#endif

View File

@ -27,6 +27,9 @@
class Token;
/// @addtogroup Checks
/// @{
class CheckOther : public Check
{
public:
@ -186,7 +189,7 @@ private:
" * [[IncompleteStatement|Incomplete statement]]\n";
}
};
/// @}
//---------------------------------------------------------------------------
#endif

View File

@ -26,6 +26,10 @@
class Token;
/// @addtogroup Checks
/// @{
/** @brief %Check STL usage */
class CheckStl : public Check
{
@ -123,7 +127,7 @@ private:
" * for vectors: using iterator/pointer after push_back has been used\n";
}
};
/// @}
//---------------------------------------------------------------------------
#endif

View File

@ -25,6 +25,9 @@
#include "tokenize.h"
#include "errorlogger.h"
/// @addtogroup Checks
/// @{
class CheckUnusedFunctions
{
public:
@ -63,7 +66,7 @@ private:
std::map<std::string, FunctionUsage> _functions;
};
/// @}
//---------------------------------------------------------------------------
#endif

View File

@ -28,6 +28,9 @@
#include "errorlogger.h"
#include "checkunusedfunctions.h"
/// @addtogroup Core
/// @{
/**
* This is the base class which will use other classes to do
* static code analysis for C and C++ code to find possible
@ -144,4 +147,6 @@ private:
std::list<std::string> _xmllist;
};
/// @}
#endif // CPPCHECK_H

View File

@ -26,6 +26,9 @@
class Token;
class Tokenizer;
/// @addtogroup Core
/// @{
/**
* This is an interface, which the class responsible of error logging
* should implement.
@ -358,4 +361,6 @@ public:
};
/// @}
#endif

View File

@ -22,6 +22,10 @@
#include <vector>
#include <string>
/// @addtogroup Core
/// @{
// Check that the compiler are supported
// This program should be compiled with either GCC/BORLAND/MSC to work..
#ifndef __GNUC__
@ -46,4 +50,6 @@ private:
};
/// @}
#endif // #ifndef FILELISTER_H

View File

@ -22,6 +22,10 @@
#include "token.h"
/// @addtogroup Core
/// @{
class MathLib
{
public:
@ -44,4 +48,6 @@ public:
static bool isGreater(const std::string & first, const std::string & second);
};
/// @}
#endif

View File

@ -27,6 +27,9 @@
#include <list>
#include "errorlogger.h"
/// @addtogroup Core
/// @{
/** @brief The cppcheck preprocessor. It has special functionality for extracting the various ifdef configurations that exist in a source file. */
class Preprocessor
{
@ -141,6 +144,8 @@ private:
};
/// @}
//---------------------------------------------------------------------------
#endif

View File

@ -23,6 +23,10 @@
#include <string>
#include <istream>
/// @addtogroup Core
/// @{
/**
* This is just a container for general settings so that we don't need
* to pass individual values to functions or constructors now or in the
@ -75,4 +79,6 @@ public:
bool isAutoDealloc(const char classname[]) const;
};
/// @}
#endif // SETTINGS_H

View File

@ -21,6 +21,9 @@
#include <string>
/// @addtogroup Core
/// @{
/**
* @brief The token list that the Tokenizer generates is a linked-list of this class.
*
@ -226,4 +229,6 @@ private:
unsigned int _linenr;
};
/// @}
#endif // TokenH

View File

@ -30,10 +30,14 @@ class Token;
class ErrorLogger;
class Settings;
/// @addtogroup Core
/// @{
/** @brief The main purpose is to tokenize the source code. It also has functions that simplify the token list */
class Tokenizer
{
private:
// Deallocate lists..
/** Deallocate lists.. */
void deallocateTokens();
public:
@ -280,5 +284,7 @@ private:
ErrorLogger * const _errorLogger;
};
/// @}
//---------------------------------------------------------------------------
#endif