astyle: Update to astyle 1.24
This commit is contained in:
parent
3fa2137ee3
commit
c718a7c595
|
@ -93,9 +93,9 @@ void CppCheckExecutor::reportStatus(unsigned int index, unsigned int max)
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << index << "/" << max
|
oss << index << "/" << max
|
||||||
<< " files checked " <<
|
<< " files checked " <<
|
||||||
static_cast<int>(static_cast<double>(index) / max*100)
|
static_cast<int>(static_cast<double>(index) / max*100)
|
||||||
<< "% done";
|
<< "% done";
|
||||||
std::cout << oss.str() << std::endl;
|
std::cout << oss.str() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ThreadExecutor::ThreadExecutor(const std::vector<std::string> &filenames, const Settings &settings, ErrorLogger &errorLogger)
|
ThreadExecutor::ThreadExecutor(const std::vector<std::string> &filenames, const Settings &settings, ErrorLogger &errorLogger)
|
||||||
: _filenames(filenames), _settings(settings), _errorLogger(errorLogger), _fileCount(0)
|
: _filenames(filenames), _settings(settings), _errorLogger(errorLogger), _fileCount(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "aboutdialog.h"
|
#include "aboutdialog.h"
|
||||||
|
|
||||||
AboutDialog::AboutDialog(const QString &version, QWidget *parent)
|
AboutDialog::AboutDialog(const QString &version, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
mUI.setupUi(this);
|
mUI.setupUi(this);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ ApplicationDialog::ApplicationDialog(const QString &name,
|
||||||
const QString &path,
|
const QString &path,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
QWidget *parent) :
|
QWidget *parent) :
|
||||||
QDialog(parent)
|
QDialog(parent)
|
||||||
{
|
{
|
||||||
mUI.setupUi(this);
|
mUI.setupUi(this);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
ApplicationList::ApplicationList(QObject *parent) :
|
ApplicationList::ApplicationList(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
//ctor
|
//ctor
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
CheckThread::CheckThread(ThreadResult &result) :
|
CheckThread::CheckThread(ThreadResult &result) :
|
||||||
mState(Ready),
|
mState(Ready),
|
||||||
mResult(result),
|
mResult(result),
|
||||||
mCppcheck(result)
|
mCppcheck(result)
|
||||||
{
|
{
|
||||||
//ctor
|
//ctor
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "csvreport.h"
|
#include "csvreport.h"
|
||||||
|
|
||||||
CsvReport::CsvReport(const QString &filename, QObject * parent) :
|
CsvReport::CsvReport(const QString &filename, QObject * parent) :
|
||||||
Report(filename, parent)
|
Report(filename, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
FileViewDialog::FileViewDialog(const QString &file,
|
FileViewDialog::FileViewDialog(const QString &file,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
mUI.setupUi(this);
|
mUI.setupUi(this);
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MainWindow::MainWindow() :
|
MainWindow::MainWindow() :
|
||||||
mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)),
|
mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)),
|
||||||
mApplications(new ApplicationList(this)),
|
mApplications(new ApplicationList(this)),
|
||||||
mTranslation(new TranslationHandler(this)),
|
mTranslation(new TranslationHandler(this)),
|
||||||
mLanguages(new QActionGroup(this))
|
mLanguages(new QActionGroup(this))
|
||||||
{
|
{
|
||||||
mUI.setupUi(this);
|
mUI.setupUi(this);
|
||||||
mUI.mResults->Initialize(mSettings, mApplications);
|
mUI.mResults->Initialize(mSettings, mApplications);
|
||||||
|
|
|
@ -31,13 +31,13 @@ static const char DirElementName[] = "dir";
|
||||||
static const char DirNameAttrib[] = "name";
|
static const char DirNameAttrib[] = "name";
|
||||||
|
|
||||||
ProjectFile::ProjectFile(QObject *parent) :
|
ProjectFile::ProjectFile(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectFile::ProjectFile(const QString &filename, QObject *parent) :
|
ProjectFile::ProjectFile(const QString &filename, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
mFilename(filename)
|
mFilename(filename)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
|
|
||||||
Report::Report(const QString &filename, QObject * parent) :
|
Report::Report(const QString &filename, QObject * parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
mFilename(filename)
|
mFilename(filename)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
#include "xmlreport.h"
|
#include "xmlreport.h"
|
||||||
|
|
||||||
ResultsTree::ResultsTree(QWidget * parent) :
|
ResultsTree::ResultsTree(QWidget * parent) :
|
||||||
QTreeView(parent),
|
QTreeView(parent),
|
||||||
mContextItem(0),
|
mContextItem(0),
|
||||||
mCheckPath(""),
|
mCheckPath(""),
|
||||||
mVisibleErrors(false)
|
mVisibleErrors(false)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < SHOW_NONE; i++)
|
for (int i = 0; i < SHOW_NONE; i++)
|
||||||
mShowTypes[i] = false;
|
mShowTypes[i] = false;
|
||||||
|
|
|
@ -27,9 +27,9 @@
|
||||||
#include "csvreport.h"
|
#include "csvreport.h"
|
||||||
|
|
||||||
ResultsView::ResultsView(QWidget * parent) :
|
ResultsView::ResultsView(QWidget * parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
mErrorsFound(false),
|
mErrorsFound(false),
|
||||||
mShowNoErrorsMessage(true)
|
mShowNoErrorsMessage(true)
|
||||||
{
|
{
|
||||||
mUI.setupUi(this);
|
mUI.setupUi(this);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,8 @@ void ResultsView::Progress(int value, int max)
|
||||||
mUI.mProgress->setVisible(false);
|
mUI.mProgress->setVisible(false);
|
||||||
//Should we inform user of non visible/not found errors?
|
//Should we inform user of non visible/not found errors?
|
||||||
if (mShowNoErrorsMessage)
|
if (mShowNoErrorsMessage)
|
||||||
{ //Tell user that we found no errors
|
{
|
||||||
|
//Tell user that we found no errors
|
||||||
if (!mErrorsFound)
|
if (!mErrorsFound)
|
||||||
{
|
{
|
||||||
QMessageBox msg(QMessageBox::Information,
|
QMessageBox msg(QMessageBox::Information,
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
SettingsDialog::SettingsDialog(QSettings *programSettings,
|
SettingsDialog::SettingsDialog(QSettings *programSettings,
|
||||||
ApplicationList *list,
|
ApplicationList *list,
|
||||||
QWidget *parent) :
|
QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
mSettings(programSettings),
|
mSettings(programSettings),
|
||||||
mApplications(list),
|
mApplications(list),
|
||||||
mTempApplications(new ApplicationList(this))
|
mTempApplications(new ApplicationList(this))
|
||||||
{
|
{
|
||||||
mUI.setupUi(this);
|
mUI.setupUi(this);
|
||||||
mTempApplications->Copy(list);
|
mTempApplications->Copy(list);
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
ThreadHandler::ThreadHandler(QObject *parent) :
|
ThreadHandler::ThreadHandler(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
mRunningThreadCount(0)
|
mRunningThreadCount(0)
|
||||||
{
|
{
|
||||||
SetThreadCount(1);
|
SetThreadCount(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,26 +24,26 @@
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
|
||||||
TranslationHandler::TranslationHandler(QObject *parent) :
|
TranslationHandler::TranslationHandler(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
mCurrentLanguage(-1),
|
mCurrentLanguage(-1),
|
||||||
mTranslator(new QTranslator(this))
|
mTranslator(new QTranslator(this))
|
||||||
{
|
{
|
||||||
//Add our default languages
|
//Add our default languages
|
||||||
mNames << QT_TRANSLATE_NOOP("MainWindow", "English")
|
mNames << QT_TRANSLATE_NOOP("MainWindow", "English")
|
||||||
<< QT_TRANSLATE_NOOP("MainWindow", "Dutch")
|
<< QT_TRANSLATE_NOOP("MainWindow", "Dutch")
|
||||||
<< QT_TRANSLATE_NOOP("MainWindow", "Finnish")
|
<< QT_TRANSLATE_NOOP("MainWindow", "Finnish")
|
||||||
<< QT_TRANSLATE_NOOP("MainWindow", "Swedish")
|
<< QT_TRANSLATE_NOOP("MainWindow", "Swedish")
|
||||||
<< QT_TRANSLATE_NOOP("MainWindow", "German")
|
<< QT_TRANSLATE_NOOP("MainWindow", "German")
|
||||||
<< QT_TRANSLATE_NOOP("MainWindow", "Russian")
|
<< QT_TRANSLATE_NOOP("MainWindow", "Russian")
|
||||||
<< QT_TRANSLATE_NOOP("MainWindow", "Polish");
|
<< QT_TRANSLATE_NOOP("MainWindow", "Polish");
|
||||||
|
|
||||||
mFiles << "cppcheck_en"
|
mFiles << "cppcheck_en"
|
||||||
<< "cppcheck_nl"
|
<< "cppcheck_nl"
|
||||||
<< "cppcheck_fi"
|
<< "cppcheck_fi"
|
||||||
<< "cppcheck_se"
|
<< "cppcheck_se"
|
||||||
<< "cppcheck_de"
|
<< "cppcheck_de"
|
||||||
<< "cppcheck_ru"
|
<< "cppcheck_ru"
|
||||||
<< "cppcheck_pl";
|
<< "cppcheck_pl";
|
||||||
|
|
||||||
//Load english as a fallback language
|
//Load english as a fallback language
|
||||||
QTranslator *english = new QTranslator();
|
QTranslator *english = new QTranslator();
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "txtreport.h"
|
#include "txtreport.h"
|
||||||
|
|
||||||
TxtReport::TxtReport(const QString &filename, QObject * parent) :
|
TxtReport::TxtReport(const QString &filename, QObject * parent) :
|
||||||
Report(filename, parent)
|
Report(filename, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "xmlreport.h"
|
#include "xmlreport.h"
|
||||||
|
|
||||||
XmlReport::XmlReport(const QString &filename, QObject * parent) :
|
XmlReport::XmlReport(const QString &filename, QObject * parent) :
|
||||||
Report(filename, parent)
|
Report(filename, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Check
|
||||||
public:
|
public:
|
||||||
/** This constructor is used when registering the CheckClass */
|
/** This constructor is used when registering the CheckClass */
|
||||||
Check()
|
Check()
|
||||||
: _tokenizer(0), _settings(0), _errorLogger(0)
|
: _tokenizer(0), _settings(0), _errorLogger(0)
|
||||||
{
|
{
|
||||||
instances().push_back(this);
|
instances().push_back(this);
|
||||||
instances().sort();
|
instances().sort();
|
||||||
|
@ -47,7 +47,7 @@ public:
|
||||||
|
|
||||||
/** This constructor is used when running checks. */
|
/** This constructor is used when running checks. */
|
||||||
Check(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
Check(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
: _tokenizer(tokenizer), _settings(settings), _errorLogger(errorLogger)
|
: _tokenizer(tokenizer), _settings(settings), _errorLogger(errorLogger)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual ~Check()
|
virtual ~Check()
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
|
|
||||||
/** This constructor is used when running checks. */
|
/** This constructor is used when running checks. */
|
||||||
CheckAutoVariables(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
CheckAutoVariables(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
: Check(tokenizer, settings, errorLogger)
|
: Check(tokenizer, settings, errorLogger)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
|
|
|
@ -160,7 +160,7 @@ public:
|
||||||
* @param str Token::str() is compared against this.
|
* @param str Token::str() is compared against this.
|
||||||
*/
|
*/
|
||||||
TokenStrEquals(const std::string &str)
|
TokenStrEquals(const std::string &str)
|
||||||
: value(str)
|
: value(str)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1294,7 +1294,7 @@ class ExecutionPathBufferOverrun : public ExecutionPath
|
||||||
public:
|
public:
|
||||||
/** Startup constructor */
|
/** Startup constructor */
|
||||||
ExecutionPathBufferOverrun(Check *c, const std::map<unsigned int, ArrayInfo> &arrayinfo)
|
ExecutionPathBufferOverrun(Check *c, const std::map<unsigned int, ArrayInfo> &arrayinfo)
|
||||||
: ExecutionPath(c, 0), arrayInfo(arrayinfo)
|
: ExecutionPath(c, 0), arrayInfo(arrayinfo)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1313,8 +1313,8 @@ private:
|
||||||
|
|
||||||
/** internal constructor for creating extra checks */
|
/** internal constructor for creating extra checks */
|
||||||
ExecutionPathBufferOverrun(Check *c, const std::map<unsigned int, ArrayInfo> &arrayinfo, unsigned int varid_)
|
ExecutionPathBufferOverrun(Check *c, const std::map<unsigned int, ArrayInfo> &arrayinfo, unsigned int varid_)
|
||||||
: ExecutionPath(c, varid_),
|
: ExecutionPath(c, varid_),
|
||||||
arrayInfo(arrayinfo)
|
arrayInfo(arrayinfo)
|
||||||
{
|
{
|
||||||
// Pretend that variables are initialized to 0
|
// Pretend that variables are initialized to 0
|
||||||
// This checking is not about uninitialized variables
|
// This checking is not about uninitialized variables
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
|
|
||||||
/** This constructor is used when running checks. */
|
/** This constructor is used when running checks. */
|
||||||
CheckBufferOverrun(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
CheckBufferOverrun(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
: Check(tokenizer, settings, errorLogger)
|
: Check(tokenizer, settings, errorLogger)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
|
|
||||||
/** @brief This constructor is used when running checks. */
|
/** @brief This constructor is used when running checks. */
|
||||||
CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
: Check(tokenizer, settings, errorLogger)
|
: Check(tokenizer, settings, errorLogger)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/** @brief Run checks on the normal token list */
|
/** @brief Run checks on the normal token list */
|
||||||
|
@ -114,12 +114,12 @@ private:
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Var(const std::string &name_, bool init_ = false, bool priv_ = false, bool mutable_ = false, bool static_ = false, Var *next_ = 0)
|
Var(const std::string &name_, bool init_ = false, bool priv_ = false, bool mutable_ = false, bool static_ = false, Var *next_ = 0)
|
||||||
: name(name_),
|
: name(name_),
|
||||||
init(init_),
|
init(init_),
|
||||||
priv(priv_),
|
priv(priv_),
|
||||||
isMutable(mutable_),
|
isMutable(mutable_),
|
||||||
isStatic(static_),
|
isStatic(static_),
|
||||||
next(next_)
|
next(next_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
|
|
||||||
/** This constructor is used when running checks. */
|
/** This constructor is used when running checks. */
|
||||||
CheckDangerousFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
CheckDangerousFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
: Check(tokenizer, settings, errorLogger)
|
: Check(tokenizer, settings, errorLogger)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
|
|
||||||
/** This constructor is used when running checks. */
|
/** This constructor is used when running checks. */
|
||||||
CheckExceptionSafety(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
CheckExceptionSafety(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
: Check(tokenizer, settings, errorLogger)
|
: Check(tokenizer, settings, errorLogger)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
|
|
|
@ -84,7 +84,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CheckMemoryLeak(const Tokenizer *t, ErrorLogger *e)
|
CheckMemoryLeak(const Tokenizer *t, ErrorLogger *e)
|
||||||
: tokenizer(t), errorLogger(e)
|
: tokenizer(t), errorLogger(e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ public:
|
||||||
|
|
||||||
/** @brief This constructor is used when running checks */
|
/** @brief This constructor is used when running checks */
|
||||||
CheckMemoryLeakInFunction(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
CheckMemoryLeakInFunction(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
||||||
: Check(tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog)
|
: Check(tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/** @brief run all simplified checks */
|
/** @brief run all simplified checks */
|
||||||
|
@ -340,7 +340,7 @@ public:
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
CheckMemoryLeakInClass(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
CheckMemoryLeakInClass(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
||||||
: Check(tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog)
|
: Check(tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void runSimplifiedChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
void runSimplifiedChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
||||||
|
@ -380,7 +380,7 @@ public:
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
CheckMemoryLeakStructMember(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
CheckMemoryLeakStructMember(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
||||||
: Check(tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog)
|
: Check(tokenizr, settings, errLog), CheckMemoryLeak(tokenizr, errLog)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void runSimplifiedChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
void runSimplifiedChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
||||||
|
|
|
@ -1583,9 +1583,9 @@ public:
|
||||||
private:
|
private:
|
||||||
/** Create checking of specific variable: */
|
/** Create checking of specific variable: */
|
||||||
CheckNullpointer(Check *c, const unsigned int id, const std::string &name)
|
CheckNullpointer(Check *c, const unsigned int id, const std::string &name)
|
||||||
: ExecutionPath(c, id),
|
: ExecutionPath(c, id),
|
||||||
varname(name),
|
varname(name),
|
||||||
null(false)
|
null(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1751,7 +1751,7 @@ class CheckUninitVar : public ExecutionPath
|
||||||
public:
|
public:
|
||||||
/** Startup constructor */
|
/** Startup constructor */
|
||||||
CheckUninitVar(Check *c)
|
CheckUninitVar(Check *c)
|
||||||
: ExecutionPath(c, 0), pointer(false), array(false), alloc(false), strncpy_(false)
|
: ExecutionPath(c, 0), pointer(false), array(false), alloc(false), strncpy_(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1767,7 +1767,7 @@ private:
|
||||||
|
|
||||||
/** internal constructor for creating extra checks */
|
/** internal constructor for creating extra checks */
|
||||||
CheckUninitVar(Check *c, unsigned int v, const std::string &name, bool p, bool a)
|
CheckUninitVar(Check *c, unsigned int v, const std::string &name, bool p, bool a)
|
||||||
: ExecutionPath(c, v), varname(name), pointer(p), array(a), alloc(false), strncpy_(false)
|
: ExecutionPath(c, v), varname(name), pointer(p), array(a), alloc(false), strncpy_(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
|
|
||||||
/** @brief This constructor is used when running checks. */
|
/** @brief This constructor is used when running checks. */
|
||||||
CheckOther(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
CheckOther(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
: Check(tokenizer, settings, errorLogger)
|
: Check(tokenizer, settings, errorLogger)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/** @brief Run checks against the normal token list */
|
/** @brief Run checks against the normal token list */
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
|
|
||||||
/** This constructor is used when running checks. */
|
/** This constructor is used when running checks. */
|
||||||
CheckStl(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
CheckStl(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
: Check(tokenizer, settings, errorLogger)
|
: Check(tokenizer, settings, errorLogger)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
|
|
144
lib/cppcheck.cpp
144
lib/cppcheck.cpp
|
@ -66,8 +66,8 @@ struct TimerResultsData
|
||||||
unsigned int _numberOfResults;
|
unsigned int _numberOfResults;
|
||||||
|
|
||||||
TimerResultsData()
|
TimerResultsData()
|
||||||
: _clocks(0)
|
: _clocks(0)
|
||||||
, _numberOfResults(0)
|
, _numberOfResults(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -117,11 +117,11 @@ class Timer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Timer(const std::string& str, unsigned int showtimeMode, TimerResultsIntf* timerResults = NULL)
|
Timer(const std::string& str, unsigned int showtimeMode, TimerResultsIntf* timerResults = NULL)
|
||||||
: _str(str)
|
: _str(str)
|
||||||
, _showtimeMode(showtimeMode)
|
, _showtimeMode(showtimeMode)
|
||||||
, _start(0)
|
, _start(0)
|
||||||
, _stopped(false)
|
, _stopped(false)
|
||||||
, _timerResults(timerResults)
|
, _timerResults(timerResults)
|
||||||
{
|
{
|
||||||
if (showtimeMode != SHOWTIME_NONE)
|
if (showtimeMode != SHOWTIME_NONE)
|
||||||
_start = clock();
|
_start = clock();
|
||||||
|
@ -167,7 +167,7 @@ private:
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
CppCheck::CppCheck(ErrorLogger &errorLogger)
|
CppCheck::CppCheck(ErrorLogger &errorLogger)
|
||||||
: _errorLogger(errorLogger)
|
: _errorLogger(errorLogger)
|
||||||
{
|
{
|
||||||
exitcode = 0;
|
exitcode = 0;
|
||||||
}
|
}
|
||||||
|
@ -499,7 +499,7 @@ bool CppCheck::parseFromArgs(int argc, const char* const argv[])
|
||||||
for (std::list<Check *>::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it)
|
for (std::list<Check *>::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it)
|
||||||
{
|
{
|
||||||
doc << "===" << (*it)->name() << "===\n"
|
doc << "===" << (*it)->name() << "===\n"
|
||||||
<< (*it)->classInfo() << "\n\n";
|
<< (*it)->classInfo() << "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string doc2(doc.str());
|
std::string doc2(doc.str());
|
||||||
|
@ -536,69 +536,69 @@ bool CppCheck::parseFromArgs(int argc, const char* const argv[])
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Cppcheck - A tool for static C/C++ code analysis\n"
|
oss << "Cppcheck - A tool for static C/C++ code analysis\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Syntax:\n"
|
"Syntax:\n"
|
||||||
" cppcheck [--append=file] [--enable=<id>]\n"
|
" cppcheck [--append=file] [--enable=<id>]\n"
|
||||||
" [--error-exitcode=[n]] [--exitcode-suppressions file] [--force]\n"
|
" [--error-exitcode=[n]] [--exitcode-suppressions file] [--force]\n"
|
||||||
" [--help] [-Idir] [-j [jobs]] [--quiet] [--style]\n"
|
" [--help] [-Idir] [-j [jobs]] [--quiet] [--style]\n"
|
||||||
" [--suppressions file.txt] [--inline-suppr] [--file-list=file.txt]\n"
|
" [--suppressions file.txt] [--inline-suppr] [--file-list=file.txt]\n"
|
||||||
" [--verbose] [--version] [--xml] [file or path1] [file or path] ..\n"
|
" [--verbose] [--version] [--xml] [file or path1] [file or path] ..\n"
|
||||||
"\n"
|
"\n"
|
||||||
"If path is given instead of filename, *.cpp, *.cxx, *.cc, *.c++ and *.c files\n"
|
"If path is given instead of filename, *.cpp, *.cxx, *.cc, *.c++ and *.c files\n"
|
||||||
"are checked recursively from given directory.\n\n"
|
"are checked recursively from given directory.\n\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" --append=file This allows you to provide information about\n"
|
" --append=file This allows you to provide information about\n"
|
||||||
" functions by providing an implementation for these.\n"
|
" functions by providing an implementation for these.\n"
|
||||||
" --enable=id Enable specific checks. The available ids are:\n"
|
" --enable=id Enable specific checks. The available ids are:\n"
|
||||||
" * all - enable all checks\n"
|
" * all - enable all checks\n"
|
||||||
" * exceptNew - exception safety when using new\n"
|
" * exceptNew - exception safety when using new\n"
|
||||||
" * exceptRealloc - exception safety when reallocating\n"
|
" * exceptRealloc - exception safety when reallocating\n"
|
||||||
" * style - Check coding style\n"
|
" * style - Check coding style\n"
|
||||||
" * unusedFunctions - check for unused functions\n"
|
" * unusedFunctions - check for unused functions\n"
|
||||||
" Several ids can be given if you separate them with commas\n"
|
" Several ids can be given if you separate them with commas\n"
|
||||||
" --error-exitcode=[n] If errors are found, integer [n] is returned instead\n"
|
" --error-exitcode=[n] If errors are found, integer [n] is returned instead\n"
|
||||||
" of default 0. EXIT_FAILURE is returned\n"
|
" of default 0. EXIT_FAILURE is returned\n"
|
||||||
" if arguments are not valid or if no input files are\n"
|
" if arguments are not valid or if no input files are\n"
|
||||||
" provided. Note that your operating system can\n"
|
" provided. Note that your operating system can\n"
|
||||||
" modify this value, e.g. 256 can become 0.\n"
|
" modify this value, e.g. 256 can become 0.\n"
|
||||||
" --exitcode-suppressions file\n"
|
" --exitcode-suppressions file\n"
|
||||||
" Used when certain messages should be displayed but\n"
|
" Used when certain messages should be displayed but\n"
|
||||||
" should not cause a non-zero exitcode.\n"
|
" should not cause a non-zero exitcode.\n"
|
||||||
" -f, --force Force checking on files that have \"too many\"\n"
|
" -f, --force Force checking on files that have \"too many\"\n"
|
||||||
" configurations\n"
|
" configurations\n"
|
||||||
" -h, --help Print this help\n"
|
" -h, --help Print this help\n"
|
||||||
" -I [dir] Give include path. Give several -I parameters to give\n"
|
" -I [dir] Give include path. Give several -I parameters to give\n"
|
||||||
" several paths. First given path is checked first. If\n"
|
" several paths. First given path is checked first. If\n"
|
||||||
" paths are relative to source files, this is not needed\n"
|
" paths are relative to source files, this is not needed\n"
|
||||||
" -j [jobs] Start [jobs] threads to do the checking simultaneously.\n"
|
" -j [jobs] Start [jobs] threads to do the checking simultaneously.\n"
|
||||||
" -q, --quiet Only print error messages\n"
|
" -q, --quiet Only print error messages\n"
|
||||||
" -s, --style deprecated, use --enable=style\n"
|
" -s, --style deprecated, use --enable=style\n"
|
||||||
" --suppressions file Suppress warnings listed in the file. Filename and line\n"
|
" --suppressions file Suppress warnings listed in the file. Filename and line\n"
|
||||||
" are optional. The format of the single line in file is:\n"
|
" are optional. The format of the single line in file is:\n"
|
||||||
" [error id]:[filename]:[line]\n"
|
" [error id]:[filename]:[line]\n"
|
||||||
" --inline-suppr Enable inline suppressions. Use them by placing one or\n"
|
" --inline-suppr Enable inline suppressions. Use them by placing one or\n"
|
||||||
" more comments in the form: // cppcheck-suppress memleak\n"
|
" more comments in the form: // cppcheck-suppress memleak\n"
|
||||||
" on the lines before the warning to suppress.\n"
|
" on the lines before the warning to suppress.\n"
|
||||||
" --file-list=file Specify the files to check in a text file. One Filename per line.\n"
|
" --file-list=file Specify the files to check in a text file. One Filename per line.\n"
|
||||||
" --template '[text]' Format the error messages. E.g.\n"
|
" --template '[text]' Format the error messages. E.g.\n"
|
||||||
" '{file}:{line},{severity},{id},{message}' or\n"
|
" '{file}:{line},{severity},{id},{message}' or\n"
|
||||||
" '{file}({line}):({severity}) {message}'\n"
|
" '{file}({line}):({severity}) {message}'\n"
|
||||||
" Pre-defined templates: gcc, vs\n"
|
" Pre-defined templates: gcc, vs\n"
|
||||||
" --unused-functions deprecated, use --enable=unusedFunctions\n"
|
" --unused-functions deprecated, use --enable=unusedFunctions\n"
|
||||||
" -v, --verbose More detailed error reports\n"
|
" -v, --verbose More detailed error reports\n"
|
||||||
" --version Print out version number\n"
|
" --version Print out version number\n"
|
||||||
" --xml Write results in xml to error stream.\n"
|
" --xml Write results in xml to error stream.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Example usage:\n"
|
"Example usage:\n"
|
||||||
" # Recursively check the current folder. Print the progress on the screen and\n"
|
" # Recursively check the current folder. Print the progress on the screen and\n"
|
||||||
" write errors in a file:\n"
|
" write errors in a file:\n"
|
||||||
" cppcheck . 2> err.txt\n"
|
" cppcheck . 2> err.txt\n"
|
||||||
" # Recursively check ../myproject/ and don't print progress:\n"
|
" # Recursively check ../myproject/ and don't print progress:\n"
|
||||||
" cppcheck --quiet ../myproject/\n"
|
" cppcheck --quiet ../myproject/\n"
|
||||||
" # Check only files one.cpp and two.cpp and give all information there is:\n"
|
" # Check only files one.cpp and two.cpp and give all information there is:\n"
|
||||||
" cppcheck -v -s one.cpp two.cpp\n"
|
" cppcheck -v -s one.cpp two.cpp\n"
|
||||||
" # Check f.cpp and search include files from inc1/ and inc2/:\n"
|
" # Check f.cpp and search include files from inc1/ and inc2/:\n"
|
||||||
" cppcheck -I inc1/ -I inc2/ f.cpp\n";
|
" cppcheck -I inc1/ -I inc2/ f.cpp\n";
|
||||||
reportOut(oss.str());
|
reportOut(oss.str());
|
||||||
}
|
}
|
||||||
else if (_filenames.empty())
|
else if (_filenames.empty())
|
||||||
|
|
|
@ -213,8 +213,8 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
|
||||||
{
|
{
|
||||||
std::ostringstream errmsg;
|
std::ostringstream errmsg;
|
||||||
errmsg << "The code contains characters that are unhandled. "
|
errmsg << "The code contains characters that are unhandled. "
|
||||||
<< "Neither unicode nor extended ascii are supported. "
|
<< "Neither unicode nor extended ascii are supported. "
|
||||||
<< "(line=" << lineno << ", character code=" << std::hex << (int(ch) & 0xff) << ")";
|
<< "(line=" << lineno << ", character code=" << std::hex << (int(ch) & 0xff) << ")";
|
||||||
throw std::runtime_error(errmsg.str());
|
throw std::runtime_error(errmsg.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1477,7 +1477,7 @@ public:
|
||||||
* e.g. "A(x) foo(x);"
|
* e.g. "A(x) foo(x);"
|
||||||
*/
|
*/
|
||||||
PreprocessorMacro(const std::string ¯o)
|
PreprocessorMacro(const std::string ¯o)
|
||||||
: _macro(macro), _prefix("__cppcheck__")
|
: _macro(macro), _prefix("__cppcheck__")
|
||||||
{
|
{
|
||||||
// Tokenize the macro to make it easier to handle
|
// Tokenize the macro to make it easier to handle
|
||||||
std::istringstream istr(macro.c_str());
|
std::istringstream istr(macro.c_str());
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
Settings::Settings()
|
Settings::Settings()
|
||||||
: inconclusive(false)
|
: inconclusive(false)
|
||||||
{
|
{
|
||||||
_debug = false;
|
_debug = false;
|
||||||
_checkCodingStyle = false;
|
_checkCodingStyle = false;
|
||||||
|
@ -41,14 +41,14 @@ Settings::Settings()
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::Settings(const Settings &s)
|
Settings::Settings(const Settings &s)
|
||||||
: inconclusive(s.inconclusive)
|
: inconclusive(s.inconclusive)
|
||||||
{
|
{
|
||||||
*this = s;
|
*this = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructor used in unit testing..
|
// Constructor used in unit testing..
|
||||||
Settings::Settings(bool all)
|
Settings::Settings(bool all)
|
||||||
: inconclusive(all)
|
: inconclusive(all)
|
||||||
{
|
{
|
||||||
Settings s;
|
Settings s;
|
||||||
*this = s; // This assigns all members except "inconclusive"
|
*this = s; // This assigns all members except "inconclusive"
|
||||||
|
|
|
@ -27,20 +27,20 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
Token::Token(Token **t) :
|
Token::Token(Token **t) :
|
||||||
tokensBack(t),
|
tokensBack(t),
|
||||||
_str(""),
|
_str(""),
|
||||||
_isName(false),
|
_isName(false),
|
||||||
_isNumber(false),
|
_isNumber(false),
|
||||||
_isBoolean(false),
|
_isBoolean(false),
|
||||||
_isUnsigned(false),
|
_isUnsigned(false),
|
||||||
_isSigned(false),
|
_isSigned(false),
|
||||||
_isLong(false),
|
_isLong(false),
|
||||||
_varId(0),
|
_varId(0),
|
||||||
_next(0),
|
_next(0),
|
||||||
_previous(0),
|
_previous(0),
|
||||||
_link(0),
|
_link(0),
|
||||||
_fileIndex(0),
|
_fileIndex(0),
|
||||||
_linenr(0)
|
_linenr(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,14 +46,14 @@
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
Tokenizer::Tokenizer()
|
Tokenizer::Tokenizer()
|
||||||
: _settings(0), _errorLogger(0)
|
: _settings(0), _errorLogger(0)
|
||||||
{
|
{
|
||||||
_tokens = 0;
|
_tokens = 0;
|
||||||
_tokensBack = 0;
|
_tokensBack = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger)
|
Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger)
|
||||||
: _settings(settings), _errorLogger(errorLogger)
|
: _settings(settings), _errorLogger(errorLogger)
|
||||||
{
|
{
|
||||||
_tokens = 0;
|
_tokens = 0;
|
||||||
_tokensBack = 0;
|
_tokensBack = 0;
|
||||||
|
@ -409,7 +409,7 @@ void Tokenizer::duplicateTypedefError(const Token *tok1, const Token *tok2, cons
|
||||||
const ErrorLogger::ErrorMessage errmsg(locationList,
|
const ErrorLogger::ErrorMessage errmsg(locationList,
|
||||||
"style",
|
"style",
|
||||||
std::string(type + " '" + tok2->str() +
|
std::string(type + " '" + tok2->str() +
|
||||||
"' hides typedef with same name"),
|
"' hides typedef with same name"),
|
||||||
"variableHidingTypedef");
|
"variableHidingTypedef");
|
||||||
|
|
||||||
if (_errorLogger)
|
if (_errorLogger)
|
||||||
|
@ -435,7 +435,7 @@ void Tokenizer::duplicateDeclarationError(const Token *tok1, const Token *tok2,
|
||||||
const ErrorLogger::ErrorMessage errmsg(locationList,
|
const ErrorLogger::ErrorMessage errmsg(locationList,
|
||||||
"style",
|
"style",
|
||||||
std::string(type + " '" + tok2->str() +
|
std::string(type + " '" + tok2->str() +
|
||||||
"' forward declaration unnecessary, already declared"),
|
"' forward declaration unnecessary, already declared"),
|
||||||
"unnecessaryForwardDeclaration");
|
"unnecessaryForwardDeclaration");
|
||||||
|
|
||||||
if (_errorLogger)
|
if (_errorLogger)
|
||||||
|
@ -5626,7 +5626,7 @@ void Tokenizer::duplicateEnumError(const Token * tok1, const Token * tok2, const
|
||||||
const ErrorLogger::ErrorMessage errmsg(locationList,
|
const ErrorLogger::ErrorMessage errmsg(locationList,
|
||||||
"style",
|
"style",
|
||||||
std::string(type + " '" + tok2->str() +
|
std::string(type + " '" + tok2->str() +
|
||||||
"' hides enumerator with same name"),
|
"' hides enumerator with same name"),
|
||||||
"variableHidingEnum");
|
"variableHidingEnum");
|
||||||
|
|
||||||
if (_errorLogger)
|
if (_errorLogger)
|
||||||
|
|
18
runastyle
18
runastyle
|
@ -1,13 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren cli/*.cpp
|
astyle --style=ansi --min-conditional-indent=0 cli/*.cpp
|
||||||
astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren cli/*.h
|
astyle --style=ansi --min-conditional-indent=0 cli/*.h
|
||||||
astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren gui/*.cpp
|
astyle --style=ansi --min-conditional-indent=0 gui/*.cpp
|
||||||
astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren gui/*.h
|
astyle --style=ansi --min-conditional-indent=0 gui/*.h
|
||||||
astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren lib/*.cpp
|
astyle --style=ansi --min-conditional-indent=0 lib/*.cpp
|
||||||
astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren lib/*.h
|
astyle --style=ansi --min-conditional-indent=0 lib/*.h
|
||||||
astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren test/*.cpp
|
astyle --style=ansi --min-conditional-indent=0 test/*.cpp
|
||||||
astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren test/*.h
|
astyle --style=ansi --min-conditional-indent=0 test/*.h
|
||||||
|
|
||||||
astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren tools/*.cpp
|
astyle --style=ansi --min-conditional-indent=0 tools/*.cpp
|
||||||
|
|
||||||
|
|
|
@ -885,7 +885,7 @@ private:
|
||||||
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
||||||
std::ostringstream expected;
|
std::ostringstream expected;
|
||||||
expected << "void f ( char * a , char * b , char * c ) { g ( " <<
|
expected << "void f ( char * a , char * b , char * c ) { g ( " <<
|
||||||
sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " ) ; }";
|
sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " ) ; }";
|
||||||
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,7 +894,7 @@ private:
|
||||||
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
||||||
std::ostringstream expected;
|
std::ostringstream expected;
|
||||||
expected << "void f ( char a , char b , char c ) { g ( " <<
|
expected << "void f ( char a , char b , char c ) { g ( " <<
|
||||||
sizeofFromTokenizer("char") << " , " << sizeofFromTokenizer("char") << " , " << sizeofFromTokenizer("char") << " ) ; }";
|
sizeofFromTokenizer("char") << " , " << sizeofFromTokenizer("char") << " , " << sizeofFromTokenizer("char") << " ) ; }";
|
||||||
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,7 +903,7 @@ private:
|
||||||
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
||||||
std::ostringstream expected;
|
std::ostringstream expected;
|
||||||
expected << "void f ( const char * a , const char * b , const char * c ) { g ( " <<
|
expected << "void f ( const char * a , const char * b , const char * c ) { g ( " <<
|
||||||
sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " ) ; }";
|
sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " ) ; }";
|
||||||
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,7 +912,7 @@ private:
|
||||||
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
||||||
std::ostringstream expected;
|
std::ostringstream expected;
|
||||||
expected << "void f ( char a [ 10 ] , char b [ 10 ] , char c [ 10 ] ) { g ( " <<
|
expected << "void f ( char a [ 10 ] , char b [ 10 ] , char c [ 10 ] ) { g ( " <<
|
||||||
sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " ) ; }";
|
sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " ) ; }";
|
||||||
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -921,9 +921,9 @@ private:
|
||||||
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
||||||
std::ostringstream expected;
|
std::ostringstream expected;
|
||||||
expected << "void f ( const char a [ 10 ] , "
|
expected << "void f ( const char a [ 10 ] , "
|
||||||
"const char b [ 10 ] , "
|
"const char b [ 10 ] , "
|
||||||
"const char c [ 10 ] ) { g ( " <<
|
"const char c [ 10 ] ) { g ( " <<
|
||||||
sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " ) ; }";
|
sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " ) ; }";
|
||||||
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -932,9 +932,9 @@ private:
|
||||||
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
||||||
std::ostringstream expected;
|
std::ostringstream expected;
|
||||||
expected << "void f ( const char * a [ 10 ] , "
|
expected << "void f ( const char * a [ 10 ] , "
|
||||||
"const char * b [ 10 ] , "
|
"const char * b [ 10 ] , "
|
||||||
"const char * c [ 10 ] ) { g ( " <<
|
"const char * c [ 10 ] ) { g ( " <<
|
||||||
sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " ) ; }";
|
sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " ) ; }";
|
||||||
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,7 +943,7 @@ private:
|
||||||
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
"{g(sizeof(a),sizeof(b),sizeof(c));}";
|
||||||
std::ostringstream expected;
|
std::ostringstream expected;
|
||||||
expected << "void f ( char * a [ 10 ] , char * b [ 10 ] , char * c [ 10 ] ) { g ( " <<
|
expected << "void f ( char * a [ 10 ] , char * b [ 10 ] , char * c [ 10 ] ) { g ( " <<
|
||||||
sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " ) ; }";
|
sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " , " << sizeofFromTokenizer("*") << " ) ; }";
|
||||||
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -607,9 +607,10 @@ private:
|
||||||
{
|
{
|
||||||
const int STL_CONTAINER_LIST = 9;
|
const int STL_CONTAINER_LIST = 9;
|
||||||
const std::string stlCont[STL_CONTAINER_LIST] =
|
const std::string stlCont[STL_CONTAINER_LIST] =
|
||||||
{"deque", "list", "set", "multiset", "map",
|
{
|
||||||
"multimap", "hash_map", "hash_multimap", "hash_set"
|
"deque", "list", "set", "multiset", "map",
|
||||||
};
|
"multimap", "hash_map", "hash_multimap", "hash_set"
|
||||||
|
};
|
||||||
|
|
||||||
for (int i = 0; i < STL_CONTAINER_LIST; ++i)
|
for (int i = 0; i < STL_CONTAINER_LIST; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,10 +121,10 @@ void TestFixture::assertEquals(const char *filename, int linenr, const std::stri
|
||||||
++fails_counter;
|
++fails_counter;
|
||||||
|
|
||||||
errmsg << "Assertion failed in " << filename << " at line " << linenr << std::endl
|
errmsg << "Assertion failed in " << filename << " at line " << linenr << std::endl
|
||||||
<< "Expected:" << std::endl
|
<< "Expected:" << std::endl
|
||||||
<< writestr(expected) << std::endl
|
<< writestr(expected) << std::endl
|
||||||
<< "Actual:" << std::endl
|
<< "Actual:" << std::endl
|
||||||
<< writestr(actual) << std::endl;
|
<< writestr(actual) << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ void TestFixture::assertThrowFail(const char *filename, int linenr)
|
||||||
++fails_counter;
|
++fails_counter;
|
||||||
|
|
||||||
errmsg << "Assertion failed in " << filename << " at line " << linenr << std::endl
|
errmsg << "Assertion failed in " << filename << " at line " << linenr << std::endl
|
||||||
<< "The expected exception was not thrown" << std::endl;
|
<< "The expected exception was not thrown" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestFixture::printTests()
|
void TestFixture::printTests()
|
||||||
|
|
|
@ -60,82 +60,82 @@ int main(const int argc, const char * const * const argv)
|
||||||
if (subcount < 6)
|
if (subcount < 6)
|
||||||
{
|
{
|
||||||
fout << "class Token\n"
|
fout << "class Token\n"
|
||||||
<< "{\n"
|
<< "{\n"
|
||||||
<< "public:\n"
|
<< "public:\n"
|
||||||
<< " const char *str() const;\n"
|
<< " const char *str() const;\n"
|
||||||
<< " const Token *next() const;\n"
|
<< " const Token *next() const;\n"
|
||||||
<< " unsigned int size() const;\n"
|
<< " unsigned int size() const;\n"
|
||||||
<< " char read () const;\n"
|
<< " char read () const;\n"
|
||||||
<< " operator bool() const;\n"
|
<< " operator bool() const;\n"
|
||||||
<< "};\n"
|
<< "};\n"
|
||||||
<< "static Token *tokens;\n";
|
<< "static Token *tokens;\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fout << "struct A\n"
|
fout << "struct A\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" char b();\n"
|
" char b();\n"
|
||||||
" A *next;\n"
|
" A *next;\n"
|
||||||
"};\n";
|
"};\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testname == "nullpointer2")
|
if (testname == "nullpointer2")
|
||||||
{
|
{
|
||||||
fout << "class Fred\n"
|
fout << "class Fred\n"
|
||||||
<< "{\n"
|
<< "{\n"
|
||||||
<< "public:\n"
|
<< "public:\n"
|
||||||
<< " void hello() const;\n"
|
<< " void hello() const;\n"
|
||||||
<< " operator bool() const;\n"
|
<< " operator bool() const;\n"
|
||||||
<< "};\n";
|
<< "};\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testname == "nullpointer3")
|
if (testname == "nullpointer3")
|
||||||
{
|
{
|
||||||
fout << "struct DEF { };\n"
|
fout << "struct DEF { };\n"
|
||||||
<< "struct ABC : public DEF\n"
|
<< "struct ABC : public DEF\n"
|
||||||
<< "{\n"
|
<< "{\n"
|
||||||
<< " int a,b,c;\n"
|
<< " int a,b,c;\n"
|
||||||
<< " struct ABC *next;\n"
|
<< " struct ABC *next;\n"
|
||||||
<< "};\n"
|
<< "};\n"
|
||||||
<< "void bar(int); void f(struct ABC **);\n";
|
<< "void bar(int); void f(struct ABC **);\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testname == "nullpointer4")
|
if (testname == "nullpointer4")
|
||||||
{
|
{
|
||||||
fout << "void bar(int);\n"
|
fout << "void bar(int);\n"
|
||||||
<< "int** f(int **p = 0);\n"
|
<< "int** f(int **p = 0);\n"
|
||||||
<< "extern int x;\n"
|
<< "extern int x;\n"
|
||||||
<< "struct P {\n"
|
<< "struct P {\n"
|
||||||
<< " bool check() const;\n"
|
<< " bool check() const;\n"
|
||||||
<< " P* next() const;\n"
|
<< " P* next() const;\n"
|
||||||
<< "};\n";
|
<< "};\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testname == "nullpointer5")
|
if (testname == "nullpointer5")
|
||||||
{
|
{
|
||||||
fout << "struct A {\n"
|
fout << "struct A {\n"
|
||||||
<< " char c() const;\n"
|
<< " char c() const;\n"
|
||||||
<< " operator bool() const;\n"
|
<< " operator bool() const;\n"
|
||||||
<< "};\n";
|
<< "};\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testname == "nullpointer6")
|
if (testname == "nullpointer6")
|
||||||
{
|
{
|
||||||
fout << "struct Foo {\n"
|
fout << "struct Foo {\n"
|
||||||
<< " void abcd() const;\n"
|
<< " void abcd() const;\n"
|
||||||
<< "};\n"
|
<< "};\n"
|
||||||
<< "struct FooBar : public Foo { };\n"
|
<< "struct FooBar : public Foo { };\n"
|
||||||
<< "struct FooCar : public Foo { };\n"
|
<< "struct FooCar : public Foo { };\n"
|
||||||
<< "extern int a;\n";
|
<< "extern int a;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testname == "nullpointer7")
|
if (testname == "nullpointer7")
|
||||||
{
|
{
|
||||||
fout << "struct wxLongLong {\n"
|
fout << "struct wxLongLong {\n"
|
||||||
<< " wxLongLong(int) { }\n"
|
<< " wxLongLong(int) { }\n"
|
||||||
<< " long GetValue() const;\n"
|
<< " long GetValue() const;\n"
|
||||||
<< "};\n";
|
<< "};\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
Loading…
Reference in New Issue