doc: updated doxygen comments. three groups where created - 'GUI', 'Core' and 'Checks'
This commit is contained in:
parent
968a6bdd2d
commit
7df3670128
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#include "ui_about.h"
|
#include "ui_about.h"
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief About dialog
|
* @brief About dialog
|
||||||
|
@ -38,5 +40,5 @@ public:
|
||||||
private:
|
private:
|
||||||
Ui::About mUI;
|
Ui::About mUI;
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // ABOUT_DIALOG_H
|
#endif // ABOUT_DIALOG_H
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include "ui_application.h"
|
#include "ui_application.h"
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Dialog to edit a startable application.
|
* @brief Dialog to edit a startable application.
|
||||||
* User can open errors with user specified applications. This is a dialog
|
* User can open errors with user specified applications. This is a dialog
|
||||||
|
@ -79,5 +82,5 @@ protected:
|
||||||
Ui::ApplicationDialog mUI;
|
Ui::ApplicationDialog mUI;
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // APPLICATIONDIALOG_H
|
#endif // APPLICATIONDIALOG_H
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief List of applications user has specified to open errors with
|
* @brief List of applications user has specified to open errors with
|
||||||
|
@ -159,5 +162,5 @@ protected:
|
||||||
QList<ApplicationType> mApplications;
|
QList<ApplicationType> mApplications;
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // APPLICATIONLIST_H
|
#endif // APPLICATIONLIST_H
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
#include "../src/settings.h"
|
#include "../src/settings.h"
|
||||||
#include "threadresult.h"
|
#include "threadresult.h"
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Thread to run cppcheck
|
* @brief Thread to run cppcheck
|
||||||
*
|
*
|
||||||
|
@ -91,5 +94,5 @@ protected:
|
||||||
CppCheck mCppcheck;
|
CppCheck mCppcheck;
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // CHECKTHREAD_H
|
#endif // CHECKTHREAD_H
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
#ifndef COMMON_H
|
#ifndef COMMON_H
|
||||||
#define COMMON_H
|
#define COMMON_H
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief List of error types to show
|
* @brief List of error types to show
|
||||||
*
|
*
|
||||||
|
@ -56,5 +60,5 @@ ShowTypes;
|
||||||
#define SETTINGS_LANGUAGE "Application language"
|
#define SETTINGS_LANGUAGE "Application language"
|
||||||
#define SETTINGS_TOOLBARS_SHOW "Toolbars/ShowStandard"
|
#define SETTINGS_TOOLBARS_SHOW "Toolbars/ShowStandard"
|
||||||
|
|
||||||
|
/// @}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CSV text file report.
|
* @brief CSV text file report.
|
||||||
* This report exports results as CSV (comma separated values). CSV files are
|
* This report exports results as CSV (comma separated values). CSV files are
|
||||||
|
@ -68,5 +72,5 @@ private:
|
||||||
*/
|
*/
|
||||||
QTextStream mTxtWriter;
|
QTextStream mTxtWriter;
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // CSV_REPORT_H
|
#endif // CSV_REPORT_H
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "ui_file.h"
|
#include "ui_file.h"
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief File view -dialog.
|
* @brief File view -dialog.
|
||||||
|
@ -58,5 +61,5 @@ protected:
|
||||||
|
|
||||||
Ui::Fileview mUI;
|
Ui::Fileview mUI;
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // FILEVIEW_DIALOG_H
|
#endif // FILEVIEW_DIALOG_H
|
||||||
|
|
|
@ -34,6 +34,11 @@
|
||||||
#include "ui_main.h"
|
#include "ui_main.h"
|
||||||
class ThreadHandler;
|
class ThreadHandler;
|
||||||
|
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Main window for cppcheck-gui
|
* @brief Main window for cppcheck-gui
|
||||||
*
|
*
|
||||||
|
@ -308,5 +313,5 @@ protected:
|
||||||
QString mCurrentDirectory;
|
QString mCurrentDirectory;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -24,6 +24,10 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A class that reads and writes (TODO) project files.
|
* @brief A class that reads and writes (TODO) project files.
|
||||||
* The project files contain project-specific settings for checking. For
|
* The project files contain project-specific settings for checking. For
|
||||||
|
@ -85,5 +89,5 @@ private:
|
||||||
*/
|
*/
|
||||||
QStringList mIncludeDirs;
|
QStringList mIncludeDirs;
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // PROJECT_FILE_H
|
#endif // PROJECT_FILE_H
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A base class for reports.
|
* @brief A base class for reports.
|
||||||
*/
|
*/
|
||||||
|
@ -88,5 +91,5 @@ private:
|
||||||
*/
|
*/
|
||||||
QFile mFile;
|
QFile mFile;
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // REPORT_H
|
#endif // REPORT_H
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
|
|
||||||
class Report;
|
class Report;
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Cppcheck's results are shown in this tree
|
* @brief Cppcheck's results are shown in this tree
|
||||||
*
|
*
|
||||||
|
@ -362,5 +366,5 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // RESULTSTREE_H
|
#endif // RESULTSTREE_H
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
#include "ui_resultsview.h"
|
#include "ui_resultsview.h"
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Widget to show cppcheck progressbar and result
|
* @brief Widget to show cppcheck progressbar and result
|
||||||
*
|
*
|
||||||
|
@ -179,5 +182,5 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // RESULTSVIEW_H
|
#endif // RESULTSVIEW_H
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include "ui_settings.h"
|
#include "ui_settings.h"
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Settings dialog
|
* @brief Settings dialog
|
||||||
|
@ -186,5 +188,5 @@ protected:
|
||||||
Ui::Settings mUI;
|
Ui::Settings mUI;
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // SETTINGSDIALOG_H
|
#endif // SETTINGSDIALOG_H
|
||||||
|
|
|
@ -28,6 +28,10 @@
|
||||||
#include "checkthread.h"
|
#include "checkthread.h"
|
||||||
#include "resultsview.h"
|
#include "resultsview.h"
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class handles creating threadresult and starting threads
|
* @brief This class handles creating threadresult and starting threads
|
||||||
*
|
*
|
||||||
|
@ -147,5 +151,5 @@ protected:
|
||||||
int mRunningThreadCount;
|
int mRunningThreadCount;
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // THREADHANDLER_H
|
#endif // THREADHANDLER_H
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "../src/errorlogger.h"
|
#include "../src/errorlogger.h"
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Threads use this class to obtain new files to process and to publish results
|
* @brief Threads use this class to obtain new files to process and to publish results
|
||||||
*
|
*
|
||||||
|
@ -125,5 +128,5 @@ protected:
|
||||||
int mProgress;
|
int mProgress;
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // THREADRESULT_H
|
#endif // THREADRESULT_H
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
class TranslationHandler : QObject
|
class TranslationHandler : QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -41,5 +45,5 @@ protected:
|
||||||
QTranslator *mTranslator;
|
QTranslator *mTranslator;
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // TRANSLATIONHANDLER_H
|
#endif // TRANSLATIONHANDLER_H
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Text file report.
|
* @brief Text file report.
|
||||||
* This report mimics the output of the command line cppcheck.
|
* This report mimics the output of the command line cppcheck.
|
||||||
|
@ -66,5 +70,5 @@ private:
|
||||||
*/
|
*/
|
||||||
QTextStream mTxtWriter;
|
QTextStream mTxtWriter;
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // TXT_REPORT_H
|
#endif // TXT_REPORT_H
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
|
|
||||||
|
/// @addtogroup GUI
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief XML file report.
|
* @brief XML file report.
|
||||||
* This report outputs XML-formatted report. The XML format must match command
|
* This report outputs XML-formatted report. The XML format must match command
|
||||||
|
@ -66,5 +70,5 @@ private:
|
||||||
*/
|
*/
|
||||||
QXmlStreamWriter mXmlWriter;
|
QXmlStreamWriter mXmlWriter;
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
#endif // XML_REPORT_H
|
#endif // XML_REPORT_H
|
||||||
|
|
13
src/check.h
13
src/check.h
|
@ -27,6 +27,9 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
/// @addtogroup Core
|
||||||
|
/// @{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Interface class that cppcheck uses to communicate with the checks.
|
* @brief Interface class that cppcheck uses to communicate with the checks.
|
||||||
* All checking classes must inherit from this class
|
* All checking classes must inherit from this class
|
||||||
|
@ -52,7 +55,7 @@ public:
|
||||||
instances().remove(this);
|
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()
|
||||||
{
|
{
|
||||||
static std::list<Check *> _instances;
|
static std::list<Check *> _instances;
|
||||||
|
@ -69,10 +72,10 @@ public:
|
||||||
/** get error messages */
|
/** get error messages */
|
||||||
virtual void getErrorMessages() = 0;
|
virtual void getErrorMessages() = 0;
|
||||||
|
|
||||||
/** class name */
|
/** class name, used to generate documentation */
|
||||||
virtual std::string name() const = 0;
|
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;
|
virtual std::string classInfo() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -119,7 +122,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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
|
bool operator<(const Check *other) const
|
||||||
{
|
{
|
||||||
return (name() < other->name());
|
return (name() < other->name());
|
||||||
|
@ -127,7 +130,7 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
/// @addtogroup Checks
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
class CheckAutoVariables : public Check
|
class CheckAutoVariables : public Check
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -84,7 +88,7 @@ private:
|
||||||
" * assigning address of an variable to an effective parameter of a function\n";
|
" * assigning address of an variable to an effective parameter of a function\n";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ class ErrorLogger;
|
||||||
class Token;
|
class Token;
|
||||||
class Tokenizer;
|
class Tokenizer;
|
||||||
|
|
||||||
|
/// @addtogroup Checks
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
class CheckBufferOverrun : public Check
|
class CheckBufferOverrun : public Check
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -93,7 +97,7 @@ private:
|
||||||
return "out of bounds checking";
|
return "out of bounds checking";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
|
|
||||||
class Token;
|
class Token;
|
||||||
|
|
||||||
|
/// @addtogroup Checks
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
class CheckClass : public Check
|
class CheckClass : public Check
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -137,6 +141,7 @@ private:
|
||||||
" * Are there unused private functions\n";
|
" * Are there unused private functions\n";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
|
|
||||||
|
/// @addtogroup Checks
|
||||||
|
/// @{
|
||||||
|
|
||||||
class CheckDangerousFunctions : public Check
|
class CheckDangerousFunctions : public Check
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -75,7 +78,7 @@ private:
|
||||||
" * scanf\n";
|
" * scanf\n";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,10 @@
|
||||||
#include "tokenize.h"
|
#include "tokenize.h"
|
||||||
#include "errorlogger.h"
|
#include "errorlogger.h"
|
||||||
|
|
||||||
|
/// @addtogroup Checks
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
class CheckHeaders
|
class CheckHeaders
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -42,7 +46,7 @@ private:
|
||||||
return "Headers";
|
return "Headers";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,16 @@
|
||||||
#define checkmemoryleakH
|
#define checkmemoryleakH
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// @addtogroup Checks
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for memory leaks
|
* Check for memory leaks
|
||||||
*
|
*
|
||||||
* The checking is split up into two specialized classes.
|
* The checking is split up into two specialized classes.
|
||||||
* CheckMemoryLeakInFunction can detect when a function 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.
|
* - CheckMemoryLeakInClass can detect when a class variable is allocated but not deallocated properly.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
|
@ -39,15 +43,35 @@
|
||||||
|
|
||||||
class Token;
|
class Token;
|
||||||
|
|
||||||
/** Base class for memory leaks checking */
|
/** @brief Base class for memory leaks checking */
|
||||||
|
|
||||||
class CheckMemoryLeak
|
class CheckMemoryLeak
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const Tokenizer * const tokenizer;
|
const Tokenizer * const tokenizer;
|
||||||
ErrorLogger * const errorLogger;
|
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;
|
ErrorLogger::ErrorMessage errmsg(const std::list<const Token *> &callstack, Severity::e severity, const std::string &id, const std::string &msg) const;
|
||||||
|
|
||||||
public:
|
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:
|
* The checking is done by looking at each function variable separately. By repeating these 4 steps over and over:
|
||||||
* 1. locate a function variable
|
* -# locate a function variable
|
||||||
* 2. create a simple token list that describes the usage of the function variable.
|
* -# create a simple token list that describes the usage of the function variable.
|
||||||
* 3. simplify the token list.
|
* -# simplify the token list.
|
||||||
* 4. finally, check if the simplified token list contain any leaks.
|
* -# finally, check if the simplified token list contain any leaks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class CheckMemoryLeakInFunction : public Check, private CheckMemoryLeak
|
class CheckMemoryLeakInFunction : private Check, private CheckMemoryLeak
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/** This constructor is used when registering this class */
|
||||||
CheckMemoryLeakInFunction() : Check(), CheckMemoryLeak(0, 0)
|
CheckMemoryLeakInFunction() : Check(), CheckMemoryLeak(0, 0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
/** This constructor is used when running checks */
|
||||||
CheckMemoryLeakInFunction(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
CheckMemoryLeakInFunction(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
: Check(tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger)
|
: Check(tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger)
|
||||||
{ }
|
{ }
|
||||||
|
@ -107,9 +133,6 @@ public:
|
||||||
checkMemoryLeak.check();
|
checkMemoryLeak.check();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef UNIT_TESTING
|
|
||||||
private:
|
|
||||||
#endif
|
|
||||||
void check();
|
void check();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -125,27 +148,75 @@ private:
|
||||||
*/
|
*/
|
||||||
bool notvar(const Token *tok, const char *varnames[], bool endpar = false);
|
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);
|
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 tok start parse token
|
||||||
* @param callstack callstack
|
* @param callstack callstack
|
||||||
* @param varname name of variable
|
* @param varname name of variable
|
||||||
* @param alloctype
|
* @param alloctype keep track of what type of allocation is used
|
||||||
* @param dealloctype
|
* @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
|
* @return Newly allocated token array. Caller needs to release reserved
|
||||||
* memory by calling Tokenizer::deleteTokens(returnValue);
|
* 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);
|
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 ";"
|
* Simplify code e.g. by replacing empty "{ }" with ";"
|
||||||
* @param tok first token. The tokens list can be modified.
|
* @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);
|
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 checkScope(const Token *Tok1, const char varname[], bool classmember, unsigned int sz);
|
||||||
|
|
||||||
void getErrorMessages()
|
void getErrorMessages()
|
||||||
|
@ -165,11 +236,10 @@ private:
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check class variables
|
* @brief %Check class variables, variables that are allocated in the constructor should be deallocated in the destructor
|
||||||
* 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:
|
public:
|
||||||
CheckMemoryLeakInClass() : Check(), CheckMemoryLeak(0, 0)
|
CheckMemoryLeakInClass() : Check(), CheckMemoryLeak(0, 0)
|
||||||
|
@ -185,9 +255,6 @@ public:
|
||||||
checkMemoryLeak.check();
|
checkMemoryLeak.check();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef UNIT_TESTING
|
|
||||||
private:
|
|
||||||
#endif
|
|
||||||
void check();
|
void check();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -210,12 +277,9 @@ private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** @brief detect simple memory leaks for struct members */
|
||||||
* Check class variables
|
|
||||||
* variables that are allocated in the constructor should be deallocated in the destructor
|
|
||||||
*/
|
|
||||||
|
|
||||||
class CheckMemoryLeakStructMember : public Check, private CheckMemoryLeak
|
class CheckMemoryLeakStructMember : private Check, private CheckMemoryLeak
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CheckMemoryLeakStructMember() : Check(), CheckMemoryLeak(0, 0)
|
CheckMemoryLeakStructMember() : Check(), CheckMemoryLeak(0, 0)
|
||||||
|
@ -238,16 +302,6 @@ public:
|
||||||
|
|
||||||
private:
|
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()
|
void getErrorMessages()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -258,9 +312,9 @@ private:
|
||||||
|
|
||||||
std::string classInfo() const
|
std::string classInfo() const
|
||||||
{
|
{
|
||||||
return "Don't forget to free struct members";
|
return "Don't forget to deallocate struct members";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
|
|
||||||
class Token;
|
class Token;
|
||||||
|
|
||||||
|
/// @addtogroup Checks
|
||||||
|
/// @{
|
||||||
|
|
||||||
class CheckOther : public Check
|
class CheckOther : public Check
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -186,7 +189,7 @@ private:
|
||||||
" * [[IncompleteStatement|Incomplete statement]]\n";
|
" * [[IncompleteStatement|Incomplete statement]]\n";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
|
|
||||||
class Token;
|
class Token;
|
||||||
|
|
||||||
|
/// @addtogroup Checks
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/** @brief %Check STL usage */
|
/** @brief %Check STL usage */
|
||||||
class CheckStl : public Check
|
class CheckStl : public Check
|
||||||
{
|
{
|
||||||
|
@ -123,7 +127,7 @@ private:
|
||||||
" * for vectors: using iterator/pointer after push_back has been used\n";
|
" * for vectors: using iterator/pointer after push_back has been used\n";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
#include "tokenize.h"
|
#include "tokenize.h"
|
||||||
#include "errorlogger.h"
|
#include "errorlogger.h"
|
||||||
|
|
||||||
|
/// @addtogroup Checks
|
||||||
|
/// @{
|
||||||
|
|
||||||
class CheckUnusedFunctions
|
class CheckUnusedFunctions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -63,7 +66,7 @@ private:
|
||||||
|
|
||||||
std::map<std::string, FunctionUsage> _functions;
|
std::map<std::string, FunctionUsage> _functions;
|
||||||
};
|
};
|
||||||
|
/// @}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
#include "errorlogger.h"
|
#include "errorlogger.h"
|
||||||
#include "checkunusedfunctions.h"
|
#include "checkunusedfunctions.h"
|
||||||
|
|
||||||
|
/// @addtogroup Core
|
||||||
|
/// @{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the base class which will use other classes to do
|
* This is the base class which will use other classes to do
|
||||||
* static code analysis for C and C++ code to find possible
|
* static code analysis for C and C++ code to find possible
|
||||||
|
@ -144,4 +147,6 @@ private:
|
||||||
std::list<std::string> _xmllist;
|
std::list<std::string> _xmllist;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
#endif // CPPCHECK_H
|
#endif // CPPCHECK_H
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
class Token;
|
class Token;
|
||||||
class Tokenizer;
|
class Tokenizer;
|
||||||
|
|
||||||
|
/// @addtogroup Core
|
||||||
|
/// @{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an interface, which the class responsible of error logging
|
* This is an interface, which the class responsible of error logging
|
||||||
* should implement.
|
* should implement.
|
||||||
|
@ -358,4 +361,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
/// @addtogroup Core
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
// Check that the compiler are supported
|
// Check that the compiler are supported
|
||||||
// This program should be compiled with either GCC/BORLAND/MSC to work..
|
// This program should be compiled with either GCC/BORLAND/MSC to work..
|
||||||
#ifndef __GNUC__
|
#ifndef __GNUC__
|
||||||
|
@ -46,4 +50,6 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
#endif // #ifndef FILELISTER_H
|
#endif // #ifndef FILELISTER_H
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
|
|
||||||
|
/// @addtogroup Core
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
class MathLib
|
class MathLib
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -44,4 +48,6 @@ public:
|
||||||
static bool isGreater(const std::string & first, const std::string & second);
|
static bool isGreater(const std::string & first, const std::string & second);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "errorlogger.h"
|
#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. */
|
/** @brief The cppcheck preprocessor. It has special functionality for extracting the various ifdef configurations that exist in a source file. */
|
||||||
class Preprocessor
|
class Preprocessor
|
||||||
{
|
{
|
||||||
|
@ -141,6 +144,8 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
|
||||||
|
/// @addtogroup Core
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is just a container for general settings so that we don't need
|
* 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
|
* to pass individual values to functions or constructors now or in the
|
||||||
|
@ -75,4 +79,6 @@ public:
|
||||||
bool isAutoDealloc(const char classname[]) const;
|
bool isAutoDealloc(const char classname[]) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
#endif // SETTINGS_H
|
#endif // SETTINGS_H
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
/// @addtogroup Core
|
||||||
|
/// @{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The token list that the Tokenizer generates is a linked-list of this class.
|
* @brief The token list that the Tokenizer generates is a linked-list of this class.
|
||||||
*
|
*
|
||||||
|
@ -226,4 +229,6 @@ private:
|
||||||
unsigned int _linenr;
|
unsigned int _linenr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
#endif // TokenH
|
#endif // TokenH
|
||||||
|
|
|
@ -30,10 +30,14 @@ class Token;
|
||||||
class ErrorLogger;
|
class ErrorLogger;
|
||||||
class Settings;
|
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
|
class Tokenizer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Deallocate lists..
|
/** Deallocate lists.. */
|
||||||
void deallocateTokens();
|
void deallocateTokens();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -280,5 +284,7 @@ private:
|
||||||
ErrorLogger * const _errorLogger;
|
ErrorLogger * const _errorLogger;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue