Format with uncrustify (#3388)

This commit is contained in:
Paul Fultz II 2021-08-07 13:51:18 -05:00 committed by GitHub
parent f361106770
commit 7f358b2bed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
287 changed files with 27831 additions and 24185 deletions

3128
.uncrustify.cfg Normal file

File diff suppressed because it is too large Load Diff

View File

@ -102,8 +102,7 @@ CmdLineParser::CmdLineParser(Settings *settings)
, mShowVersion(false) , mShowVersion(false)
, mShowErrorMessages(false) , mShowErrorMessages(false)
, mExitAfterPrint(false) , mExitAfterPrint(false)
{ {}
}
void CmdLineParser::printMessage(const std::string &message) void CmdLineParser::printMessage(const std::string &message)
{ {

View File

@ -81,8 +81,7 @@
CppCheckExecutor::CppCheckExecutor() CppCheckExecutor::CppCheckExecutor()
: mSettings(nullptr), mLatestProgressOutputTime(0), mErrorOutput(nullptr), mBugHuntingReport(nullptr), mShowAllErrors(false) : mSettings(nullptr), mLatestProgressOutputTime(0), mErrorOutput(nullptr), mBugHuntingReport(nullptr), mShowAllErrors(false)
{ {}
}
CppCheckExecutor::~CppCheckExecutor() CppCheckExecutor::~CppCheckExecutor()
{ {
@ -250,7 +249,7 @@ void CppCheckExecutor::setSettings(const Settings &settings)
* \return size of array * \return size of array
* */ * */
template<typename T, int size> template<typename T, int size>
std::size_t getArrayLength(const T(&)[size]) std::size_t getArrayLength(const T (&)[size])
{ {
return size; return size;
} }
@ -589,15 +588,15 @@ namespace {
}; };
typedef BOOL (WINAPI *fpStackWalk64)(DWORD, HANDLE, HANDLE, LPSTACKFRAME64, PVOID, PREAD_PROCESS_MEMORY_ROUTINE64, PFUNCTION_TABLE_ACCESS_ROUTINE64, PGET_MODULE_BASE_ROUTINE64, PTRANSLATE_ADDRESS_ROUTINE64); typedef BOOL (WINAPI *fpStackWalk64)(DWORD, HANDLE, HANDLE, LPSTACKFRAME64, PVOID, PREAD_PROCESS_MEMORY_ROUTINE64, PFUNCTION_TABLE_ACCESS_ROUTINE64, PGET_MODULE_BASE_ROUTINE64, PTRANSLATE_ADDRESS_ROUTINE64);
fpStackWalk64 pStackWalk64; fpStackWalk64 pStackWalk64;
typedef DWORD64(WINAPI *fpSymGetModuleBase64)(HANDLE, DWORD64); typedef DWORD64 (WINAPI *fpSymGetModuleBase64)(HANDLE, DWORD64);
fpSymGetModuleBase64 pSymGetModuleBase64; fpSymGetModuleBase64 pSymGetModuleBase64;
typedef BOOL (WINAPI *fpSymGetSymFromAddr64)(HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64); typedef BOOL (WINAPI *fpSymGetSymFromAddr64)(HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64);
fpSymGetSymFromAddr64 pSymGetSymFromAddr64; fpSymGetSymFromAddr64 pSymGetSymFromAddr64;
typedef BOOL (WINAPI *fpSymGetLineFromAddr64)(HANDLE, DWORD64, PDWORD, PIMAGEHLP_LINE64); typedef BOOL (WINAPI *fpSymGetLineFromAddr64)(HANDLE, DWORD64, PDWORD, PIMAGEHLP_LINE64);
fpSymGetLineFromAddr64 pSymGetLineFromAddr64; fpSymGetLineFromAddr64 pSymGetLineFromAddr64;
typedef DWORD (WINAPI *fpUnDecorateSymbolName)(const TCHAR*, PTSTR, DWORD, DWORD) ; typedef DWORD (WINAPI *fpUnDecorateSymbolName)(const TCHAR*, PTSTR, DWORD, DWORD);
fpUnDecorateSymbolName pUnDecorateSymbolName; fpUnDecorateSymbolName pUnDecorateSymbolName;
typedef PVOID(WINAPI *fpSymFunctionTableAccess64)(HANDLE, DWORD64); typedef PVOID (WINAPI *fpSymFunctionTableAccess64)(HANDLE, DWORD64);
fpSymFunctionTableAccess64 pSymFunctionTableAccess64; fpSymFunctionTableAccess64 pSymFunctionTableAccess64;
typedef BOOL (WINAPI *fpSymInitialize)(HANDLE, PCSTR, BOOL); typedef BOOL (WINAPI *fpSymInitialize)(HANDLE, PCSTR, BOOL);
fpSymInitialize pSymInitialize; fpSymInitialize pSymInitialize;

View File

@ -88,7 +88,7 @@ int main(int argc, char* argv[])
GetModuleFileNameA(nullptr, exename, sizeof(exename)/sizeof(exename[0])-1); GetModuleFileNameA(nullptr, exename, sizeof(exename)/sizeof(exename[0])-1);
argv[0] = exename; argv[0] = exename;
#endif #endif
// *INDENT-OFF*
#ifdef NDEBUG #ifdef NDEBUG
try { try {
#endif #endif
@ -103,12 +103,13 @@ int main(int argc, char* argv[])
} }
return EXIT_FAILURE; return EXIT_FAILURE;
#endif #endif
// *INDENT-ON*
} }
// Warn about deprecated compilers // Warn about deprecated compilers
#ifdef __clang__ #ifdef __clang__
# if ( __clang_major__ < 2 || ( __clang_major__ == 2 && __clang_minor__ < 9)) # if (__clang_major__ < 2 || (__clang_major__ == 2 && __clang_minor__ < 9))
# warning "Using Clang 2.8 or earlier. Support for this version has been removed." # warning "Using Clang 2.8 or earlier. Support for this version has been removed."
# endif # endif
#elif defined(__GNUC__) #elif defined(__GNUC__)

View File

@ -81,7 +81,7 @@ ThreadExecutor::~ThreadExecutor()
void ThreadExecutor::addFileContent(const std::string &path, const std::string &content) void ThreadExecutor::addFileContent(const std::string &path, const std::string &content)
{ {
mFileContents[ path ] = content; mFileContents[path] = content;
} }
int ThreadExecutor::handleRead(int rpipe, unsigned int &result) int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
@ -139,11 +139,11 @@ int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
unsigned int fileResult = 0; unsigned int fileResult = 0;
iss >> fileResult; iss >> fileResult;
result += fileResult; result += fileResult;
delete [] buf; delete[] buf;
return -1; return -1;
} }
delete [] buf; delete[] buf;
return 1; return 1;
} }
@ -224,7 +224,7 @@ unsigned int ThreadExecutor::check()
resultOfCheck = fileChecker.check(*iFileSettings); resultOfCheck = fileChecker.check(*iFileSettings);
} else if (!mFileContents.empty() && mFileContents.find(iFile->first) != mFileContents.end()) { } else if (!mFileContents.empty() && mFileContents.find(iFile->first) != mFileContents.end()) {
// File content was given as a string // File content was given as a string
resultOfCheck = fileChecker.check(iFile->first, mFileContents[ iFile->first ]); resultOfCheck = fileChecker.check(iFile->first, mFileContents[iFile->first]);
} else { } else {
// Read file from a file // Read file from a file
resultOfCheck = fileChecker.check(iFile->first); resultOfCheck = fileChecker.check(iFile->first);
@ -327,18 +327,18 @@ unsigned int ThreadExecutor::check()
void ThreadExecutor::writeToPipe(PipeSignal type, const std::string &data) void ThreadExecutor::writeToPipe(PipeSignal type, const std::string &data)
{ {
unsigned int len = static_cast<unsigned int>(data.length() + 1); unsigned int len = static_cast<unsigned int>(data.length() + 1);
char *out = new char[ len + 1 + sizeof(len)]; char *out = new char[len + 1 + sizeof(len)];
out[0] = static_cast<char>(type); out[0] = static_cast<char>(type);
std::memcpy(&(out[1]), &len, sizeof(len)); std::memcpy(&(out[1]), &len, sizeof(len));
std::memcpy(&(out[1+sizeof(len)]), data.c_str(), len); std::memcpy(&(out[1+sizeof(len)]), data.c_str(), len);
if (write(mWpipe, out, len + 1 + sizeof(len)) <= 0) { if (write(mWpipe, out, len + 1 + sizeof(len)) <= 0) {
delete [] out; delete[] out;
out = nullptr; out = nullptr;
std::cerr << "#### ThreadExecutor::writeToPipe, Failed to write to pipe" << std::endl; std::cerr << "#### ThreadExecutor::writeToPipe, Failed to write to pipe" << std::endl;
std::exit(EXIT_FAILURE); std::exit(EXIT_FAILURE);
} }
delete [] out; delete[] out;
} }
void ThreadExecutor::reportOut(const std::string &outmsg, Color c) void ThreadExecutor::reportOut(const std::string &outmsg, Color c)
@ -523,7 +523,7 @@ void ThreadExecutor::reportInfo(const ErrorMessage &msg)
report(msg, MessageType::REPORT_INFO); report(msg, MessageType::REPORT_INFO);
} }
void ThreadExecutor::bughuntingReport(const std::string &/*str*/) void ThreadExecutor::bughuntingReport(const std::string & /*str*/)
{ {
// TODO // TODO
} }
@ -562,32 +562,23 @@ void ThreadExecutor::report(const ErrorMessage &msg, MessageType msgType)
#else #else
void ThreadExecutor::addFileContent(const std::string &/*path*/, const std::string &/*content*/) void ThreadExecutor::addFileContent(const std::string & /*path*/, const std::string & /*content*/)
{ {}
}
unsigned int ThreadExecutor::check() unsigned int ThreadExecutor::check()
{ {
return 0; return 0;
} }
void ThreadExecutor::reportOut(const std::string &/*outmsg*/, Color) void ThreadExecutor::reportOut(const std::string & /*outmsg*/, Color)
{ {}
void ThreadExecutor::reportErr(const ErrorMessage & /*msg*/)
{}
} void ThreadExecutor::reportInfo(const ErrorMessage & /*msg*/)
void ThreadExecutor::reportErr(const ErrorMessage &/*msg*/) {}
{
} void ThreadExecutor::bughuntingReport(const std::string & /*str*/)
{}
void ThreadExecutor::reportInfo(const ErrorMessage &/*msg*/)
{
}
void ThreadExecutor::bughuntingReport(const std::string &/*str*/)
{
}
#endif #endif

View File

@ -46,7 +46,7 @@ public:
void bughuntingReport(const std::string&) override {} void bughuntingReport(const std::string&) override {}
void reportOut(const std::string &outmsg) override { } void reportOut(const std::string &outmsg) override {}
void reportErr(const ErrorMessage &msg) override { void reportErr(const ErrorMessage &msg) override {
const std::string s = msg.toString(true); const std::string s = msg.toString(true);

View File

@ -29,9 +29,9 @@ class QWidget;
/// @{ /// @{
/** /**
* @brief About dialog * @brief About dialog
* *
*/ */
class AboutDialog : public QDialog { class AboutDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -23,5 +23,4 @@ Application::Application(const QString &name, const QString &path,
: mName(name) : mName(name)
, mPath(path) , mPath(path)
, mParameters(params) , mParameters(params)
{ {}
}

View File

@ -22,27 +22,27 @@
#include <QString> #include <QString>
/** /**
* @brief A class containing information of the application to execute. * @brief A class containing information of the application to execute.
* *
* Each application has a name and a path. Name is displayed to the user * Each application has a name and a path. Name is displayed to the user
* and has no other meaning. It isn't used to start the application. * and has no other meaning. It isn't used to start the application.
* Path contains the full path to the application containing the executable name. * Path contains the full path to the application containing the executable name.
* Parameters contains the command line arguments for the executable. * Parameters contains the command line arguments for the executable.
* *
* User can also specify certain predefined strings to parameters. These strings * User can also specify certain predefined strings to parameters. These strings
* will be replaced with appropriate values concerning the error. Strings are: * will be replaced with appropriate values concerning the error. Strings are:
* (file) - Filename containing the error * (file) - Filename containing the error
* (line) - Line number containing the error * (line) - Line number containing the error
* (message) - Error message * (message) - Error message
* (severity) - Error severity * (severity) - Error severity
* *
* Example opening a file with Kate and make Kate scroll to the correct line. * Example opening a file with Kate and make Kate scroll to the correct line.
* Executable: kate * Executable: kate
* Parameters: -l(line) (file) * Parameters: -l(line) (file)
*/ */
class Application { class Application {
public: public:
Application() { } Application() {}
Application(const QString &name, const QString &path, const QString &params); Application(const QString &name, const QString &path, const QString &params);
/** /**

View File

@ -30,11 +30,11 @@ class Application;
/// @{ /// @{
/** /**
* @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
* to modify/add an application to open errors with. * to modify/add an application to open errors with.
* *
*/ */
class ApplicationDialog : public QDialog { class ApplicationDialog : public QDialog {
Q_OBJECT Q_OBJECT

View File

@ -27,8 +27,8 @@
/** /**
* @brief List of applications user has specified to open errors with. * @brief List of applications user has specified to open errors with.
*/ */
class ApplicationList : public QObject { class ApplicationList : public QObject {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -31,9 +31,9 @@ class ThreadResult;
/// @{ /// @{
/** /**
* @brief Thread to run cppcheck * @brief Thread to run cppcheck
* *
*/ */
class CheckThread : public QThread { class CheckThread : public QThread {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -101,7 +101,7 @@ static const CodeEditorStyle defaultStyleLight(
/* quote FG/Weight */ Qt::darkGreen, QFont::Normal, /* quote FG/Weight */ Qt::darkGreen, QFont::Normal,
/* comment FG/Weight */ Qt::gray, QFont::Normal, /* comment FG/Weight */ Qt::gray, QFont::Normal,
/* Symbol FG/BG/Weight */ Qt::red, QColor(220, 220, 255), QFont::Normal /* Symbol FG/BG/Weight */ Qt::red, QColor(220, 220, 255), QFont::Normal
); );
// Styling derived from Eclipse Color Theme - 'RecognEyes' // Styling derived from Eclipse Color Theme - 'RecognEyes'
// http://www.eclipsecolorthemes.org/?view=theme&id=30 // http://www.eclipsecolorthemes.org/?view=theme&id=30
@ -114,6 +114,6 @@ static const CodeEditorStyle defaultStyleDark(
/* quote FG/Weight */ QColor(0, 204, 0), QFont::Normal, /* quote FG/Weight */ QColor(0, 204, 0), QFont::Normal,
/* comment FG/Weight */ QColor(180, 180, 180), QFont::Normal, /* comment FG/Weight */ QColor(180, 180, 180), QFont::Normal,
/* Symbol FG/BG/Weight */ QColor(218, 32, 32), QColor(32, 32, 108), QFont::Normal /* Symbol FG/BG/Weight */ QColor(218, 32, 32), QColor(32, 32, 108), QFont::Normal
); );
#endif /* CODEEDITORSTYLE_H */ #endif /* CODEEDITORSTYLE_H */

View File

@ -29,8 +29,8 @@
#define CLANG_TIDY "clang-tidy" #define CLANG_TIDY "clang-tidy"
/** /**
* QSetting value names * QSetting value names
*/ */
// Window/dialog sizes // Window/dialog sizes
#define SETTINGS_WINDOW_MAXIMIZED "Window maximized" #define SETTINGS_WINDOW_MAXIMIZED "Window maximized"

View File

@ -27,8 +27,7 @@ const unsigned int CppcheckLibraryData::Function::Arg::ANY = ~0U;
const unsigned int CppcheckLibraryData::Function::Arg::VARIADIC = ~1U; const unsigned int CppcheckLibraryData::Function::Arg::VARIADIC = ~1U;
CppcheckLibraryData::CppcheckLibraryData() CppcheckLibraryData::CppcheckLibraryData()
{ {}
}
static std::string unhandledElement(const QXmlStreamReader &xmlReader) static std::string unhandledElement(const QXmlStreamReader &xmlReader)
{ {

View File

@ -64,8 +64,7 @@ public:
struct Function { struct Function {
Function() : noreturn(Unknown), gccPure(false), gccConst(false), Function() : noreturn(Unknown), gccPure(false), gccConst(false),
leakignore(false), useretval(false) { leakignore(false), useretval(false) {}
}
QString comments; QString comments;
QString name; QString name;
@ -89,8 +88,7 @@ public:
} formatstr; } formatstr;
struct Arg { struct Arg {
Arg() : nr(0), notbool(false), notnull(false), notuninit(false), Arg() : nr(0), notbool(false), notnull(false), notuninit(false),
formatstr(false), strz(false) { formatstr(false), strz(false) {}
}
QString name; QString name;
unsigned int nr; unsigned int nr;

View File

@ -24,12 +24,10 @@
CsvReport::CsvReport(const QString &filename) : CsvReport::CsvReport(const QString &filename) :
Report(filename) Report(filename)
{ {}
}
CsvReport::~CsvReport() CsvReport::~CsvReport()
{ {}
}
bool CsvReport::create() bool CsvReport::create()
{ {

View File

@ -28,11 +28,11 @@
/** /**
* @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
* easy to import to many other programs. * easy to import to many other programs.
* @todo This class should be inherited from TxtReport? * @todo This class should be inherited from TxtReport?
*/ */
class CsvReport : public Report { class CsvReport : public Report {
public: public:
explicit CsvReport(const QString &filename); explicit CsvReport(const QString &filename);

View File

@ -24,8 +24,7 @@ QErrorPathItem::QErrorPathItem(const ErrorMessage::FileLocation &loc)
, line(loc.line) , line(loc.line)
, column(loc.column) , column(loc.column)
, info(QString::fromStdString(loc.getinfo())) , info(QString::fromStdString(loc.getinfo()))
{ {}
}
bool operator==(const QErrorPathItem &i1, const QErrorPathItem &i2) bool operator==(const QErrorPathItem &i1, const QErrorPathItem &i2)
{ {
@ -38,8 +37,7 @@ ErrorItem::ErrorItem()
, inconclusive(false) , inconclusive(false)
, cwe(-1) , cwe(-1)
, hash(0) , hash(0)
{ {}
}
ErrorItem::ErrorItem(const ErrorMessage &errmsg) ErrorItem::ErrorItem(const ErrorMessage &errmsg)
: file0(QString::fromStdString(errmsg.file0)) : file0(QString::fromStdString(errmsg.file0))

View File

@ -45,8 +45,8 @@ public:
}; };
/** /**
* @brief A class containing data for one error path item * @brief A class containing data for one error path item
*/ */
class QErrorPathItem { class QErrorPathItem {
public: public:
QErrorPathItem() : line(0), column(-1) {} QErrorPathItem() : line(0), column(-1) {}
@ -60,13 +60,13 @@ public:
bool operator==(const QErrorPathItem &i1, const QErrorPathItem &i2); bool operator==(const QErrorPathItem &i1, const QErrorPathItem &i2);
/** /**
* @brief A class containing error data for one error. * @brief A class containing error data for one error.
* *
* The paths are stored with internal ("/") separators. Only when we show the * The paths are stored with internal ("/") separators. Only when we show the
* path or copy if for user (to clipboard) we convert to native separators. * path or copy if for user (to clipboard) we convert to native separators.
* Full path is stored instead of relative path for flexibility. It is easy * Full path is stored instead of relative path for flexibility. It is easy
* to get the relative path from full path when needed. * to get the relative path from full path when needed.
*/ */
class ErrorItem { class ErrorItem {
public: public:
ErrorItem(); ErrorItem();
@ -105,8 +105,8 @@ public:
Q_DECLARE_METATYPE(ErrorItem) Q_DECLARE_METATYPE(ErrorItem)
/** /**
* @brief A class containing error data for one shown error line. * @brief A class containing error data for one shown error line.
*/ */
class ErrorLine { class ErrorLine {
public: public:
QString file; QString file;

View File

@ -31,11 +31,11 @@ class QTextEdit;
/** /**
* @brief File view -dialog. * @brief File view -dialog.
* This dialog shows text files. It is used for showing the license file and * This dialog shows text files. It is used for showing the license file and
* the authors list. * the authors list.
* *
*/ */
class FileViewDialog : public QDialog { class FileViewDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -82,7 +82,7 @@ HelpDialog::HelpDialog(QWidget *parent) :
SLOT(setSource(QUrl))); SLOT(setSource(QUrl)));
connect(mHelpEngine->indexWidget(), connect(mHelpEngine->indexWidget(),
SIGNAL(linkActivated(QUrl, QString)), SIGNAL(linkActivated(QUrl,QString)),
mUi->textBrowser, mUi->textBrowser,
SLOT(setSource(QUrl))); SLOT(setSource(QUrl)));
} }

View File

@ -528,14 +528,14 @@ void MainWindow::analyzeCode(const QString& code, const QString& filename)
// Initialize dummy ThreadResult as ErrorLogger // Initialize dummy ThreadResult as ErrorLogger
ThreadResult result; ThreadResult result;
result.setFiles(QStringList(filename)); result.setFiles(QStringList(filename));
connect(&result, SIGNAL(progress(int, const QString&)), connect(&result, SIGNAL(progress(int,const QString&)),
mUI.mResults, SLOT(progress(int, const QString&))); mUI.mResults, SLOT(progress(int,const QString&)));
connect(&result, SIGNAL(error(const ErrorItem &)), connect(&result, SIGNAL(error(const ErrorItem&)),
mUI.mResults, SLOT(error(const ErrorItem &))); mUI.mResults, SLOT(error(const ErrorItem&)));
connect(&result, SIGNAL(log(const QString &)), connect(&result, SIGNAL(log(const QString&)),
mUI.mResults, SLOT(log(const QString &))); mUI.mResults, SLOT(log(const QString&)));
connect(&result, SIGNAL(debugError(const ErrorItem &)), connect(&result, SIGNAL(debugError(const ErrorItem&)),
mUI.mResults, SLOT(debugError(const ErrorItem &))); mUI.mResults, SLOT(debugError(const ErrorItem&)));
// Create CppCheck instance // Create CppCheck instance
CppCheck cppcheck(result, true, nullptr); CppCheck cppcheck(result, true, nullptr);
@ -1415,8 +1415,7 @@ void MainWindow::save()
} }
void MainWindow::resultsAdded() void MainWindow::resultsAdded()
{ {}
}
void MainWindow::toggleMainToolBar() void MainWindow::toggleMainToolBar()
{ {

View File

@ -13,11 +13,11 @@ NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) :
class QErrorLogger : public ErrorLogger { class QErrorLogger : public ErrorLogger {
public: public:
void reportOut(const std::string &/*outmsg*/, Color) override {} void reportOut(const std::string & /*outmsg*/, Color) override {}
void reportErr(const ErrorMessage &msg) override { void reportErr(const ErrorMessage &msg) override {
errorIds << QString::fromStdString(msg.id); errorIds << QString::fromStdString(msg.id);
} }
void bughuntingReport(const std::string &/*str*/) override {} void bughuntingReport(const std::string & /*str*/) override {}
QStringList errorIds; QStringList errorIds;
}; };

View File

@ -23,12 +23,10 @@
PrintableReport::PrintableReport() : PrintableReport::PrintableReport() :
Report(QString()) Report(QString())
{ {}
}
PrintableReport::~PrintableReport() PrintableReport::~PrintableReport()
{ {}
}
bool PrintableReport::create() bool PrintableReport::create()
{ {

View File

@ -26,9 +26,9 @@
/** /**
* @brief Printable (in-memory) report. * @brief Printable (in-memory) report.
* This report formats results and exposes them for printing. * This report formats results and exposes them for printing.
*/ */
class PrintableReport : public Report { class PrintableReport : public Report {
public: public:
PrintableReport(); PrintableReport();

View File

@ -36,10 +36,10 @@ class QXmlStreamWriter;
/** /**
* @brief A class that reads and writes project files. * @brief A class that reads and writes project files.
* The project files contain project-specific settings for checking. For * The project files contain project-specific settings for checking. For
* example a list of include paths. * example a list of include paths.
*/ */
class ProjectFile : public QObject { class ProjectFile : public QObject {
Q_OBJECT Q_OBJECT

View File

@ -681,7 +681,7 @@ void ProjectFileDialog::addSingleSuppression(const Suppressions::Suppression &su
(suppression.fileName.find(sep) == std::string::npos)) { (suppression.fileName.find(sep) == std::string::npos)) {
QFileInfo inf(mProjectFile->getFilename()); QFileInfo inf(mProjectFile->getFilename());
QString rootpath = inf.absolutePath(); QString rootpath = inf.absolutePath();
if (QFile::exists(QString{"%1%2%3"} .arg(rootpath, if (QFile::exists(QString{"%1%2%3"}.arg(rootpath,
QDir::separator(), QDir::separator(),
QString::fromStdString(suppression.fileName)))) { QString::fromStdString(suppression.fileName)))) {
Suppressions::Suppression sup = suppression; Suppressions::Suppression sup = suppression;

View File

@ -37,8 +37,8 @@ class QCheckBox;
class ProjectFile; class ProjectFile;
/** /**
* @brief A dialog for editing project file data. * @brief A dialog for editing project file data.
*/ */
class ProjectFileDialog : public QDialog { class ProjectFileDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -21,8 +21,7 @@
Report::Report(const QString &filename) : Report::Report(const QString &filename) :
QObject(), QObject(),
mFilename(filename) mFilename(filename)
{ {}
}
Report::~Report() Report::~Report()
{ {

View File

@ -29,8 +29,8 @@ class ErrorItem;
/// @{ /// @{
/** /**
* @brief A base class for reports. * @brief A base class for reports.
*/ */
class Report : public QObject { class Report : public QObject {
public: public:
enum Type { enum Type {

View File

@ -98,8 +98,7 @@ ResultsTree::ResultsTree(QWidget * parent) :
} }
ResultsTree::~ResultsTree() ResultsTree::~ResultsTree()
{ {}
}
void ResultsTree::keyPressEvent(QKeyEvent *event) void ResultsTree::keyPressEvent(QKeyEvent *event)
{ {

View File

@ -41,9 +41,9 @@ class QSettings;
/** /**
* @brief Cppcheck's results are shown in this tree * @brief Cppcheck's results are shown in this tree
* *
*/ */
class ResultsTree : public QTreeView { class ResultsTree : public QTreeView {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -328,7 +328,7 @@ void ResultsView::checkingFinished()
msg.exec(); msg.exec();
} //If we have errors but they aren't visible, tell user about it } //If we have errors but they aren't visible, tell user about it
else if (!mUI.mTree->hasVisibleResults()) { else if (!mUI.mTree->hasVisibleResults()) {
QString text = tr("Errors were found, but they are configured to be hidden.\n"\ QString text = tr("Errors were found, but they are configured to be hidden.\n" \
"To toggle what kind of errors are shown, open view menu."); "To toggle what kind of errors are shown, open view menu.");
QMessageBox msg(QMessageBox::Information, QMessageBox msg(QMessageBox::Information,
tr("Cppcheck"), tr("Cppcheck"),

View File

@ -36,9 +36,9 @@ class CheckStatistics;
/// @{ /// @{
/** /**
* @brief Widget to show cppcheck progressbar and result * @brief Widget to show cppcheck progressbar and result
* *
*/ */
class ResultsView : public QWidget { class ResultsView : public QWidget {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -28,8 +28,8 @@ class MainWindow;
/// @{ /// @{
/** /**
* @brief A window with a text field that . * @brief A window with a text field that .
*/ */
class ScratchPad : public QDialog { class ScratchPad : public QDialog {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -70,7 +70,7 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
mCurrentStyle = new CodeEditorStyle(CodeEditorStyle::loadSettings(&settings)); mCurrentStyle = new CodeEditorStyle(CodeEditorStyle::loadSettings(&settings));
manageStyleControls(); manageStyleControls();
connect(mUI.mEditPythonPath, SIGNAL(textEdited(const QString &)), connect(mUI.mEditPythonPath, SIGNAL(textEdited(const QString&)),
this, SLOT(validateEditPythonPath())); this, SLOT(validateEditPythonPath()));
connect(mUI.mButtons, &QDialogButtonBox::accepted, this, &SettingsDialog::ok); connect(mUI.mButtons, &QDialogButtonBox::accepted, this, &SettingsDialog::ok);
@ -83,7 +83,7 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
this, SLOT(editApplication())); this, SLOT(editApplication()));
connect(mUI.mBtnDefaultApplication, SIGNAL(clicked()), connect(mUI.mBtnDefaultApplication, SIGNAL(clicked()),
this, SLOT(defaultApplication())); this, SLOT(defaultApplication()));
connect(mUI.mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), connect(mUI.mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this, SLOT(editApplication())); this, SLOT(editApplication()));
connect(mUI.mBtnBrowsePythonPath, &QPushButton::clicked, this, &SettingsDialog::browsePythonPath); connect(mUI.mBtnBrowsePythonPath, &QPushButton::clicked, this, &SettingsDialog::browsePythonPath);

View File

@ -33,9 +33,9 @@ class CodeEditorStyle;
/// @{ /// @{
/** /**
* @brief Settings dialog * @brief Settings dialog
* *
*/ */
class SettingsDialog : public QDialog { class SettingsDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -32,9 +32,9 @@ class CheckStatistics;
/// @{ /// @{
/** /**
* @brief A dialog that shows project and scan statistics. * @brief A dialog that shows project and scan statistics.
* *
*/ */
class StatsDialog : public QDialog { class StatsDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -20,7 +20,7 @@
#include <QObject> #include <QObject>
#include "errorlogger.h" #include "errorlogger.h"
class BenchmarkSimple: public QObject, public ErrorLogger { class BenchmarkSimple : public QObject, public ErrorLogger {
Q_OBJECT Q_OBJECT
private slots: private slots:
@ -31,8 +31,6 @@ private slots:
private: private:
// Empty implementations of ErrorLogger methods. // Empty implementations of ErrorLogger methods.
// We don't care about the output in the benchmark tests. // We don't care about the output in the benchmark tests.
void reportOut(const std::string & outmsg) override { void reportOut(const std::string & outmsg) override {}
} void reportErr(const ErrorMessage &msg) override {}
void reportErr(const ErrorMessage &msg) override {
}
}; };

View File

@ -19,7 +19,7 @@
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include "cppchecklibrarydata.h" #include "cppchecklibrarydata.h"
class TestCppcheckLibraryData: public QObject { class TestCppcheckLibraryData : public QObject {
Q_OBJECT Q_OBJECT
private slots: private slots:

View File

@ -292,9 +292,9 @@ void CheckOther::checkRedundantAssignmentInSwitch()
} }
tok2 = endOfConditional; tok2 = endOfConditional;
} else } else
++ indentLevel; ++indentLevel;
} else if (tok2->str() == "}") { } else if (tok2->str() == "}") {
-- indentLevel; --indentLevel;
// End of the switch block // End of the switch block
if (indentLevel < 0) if (indentLevel < 0)
@ -343,7 +343,7 @@ void CheckOther::checkSwitchCaseFallThrough()
while (tok) { while (tok) {
// Check the contents of the switch statement // Check the contents of the switch statement
std::stack<std::pair<Token *, bool> > ifnest; std::stack<std::pair<Token *, bool>> ifnest;
std::stack<Token *> loopnest; std::stack<Token *> loopnest;
std::stack<Token *> scopenest; std::stack<Token *> scopenest;
bool justbreak = true; bool justbreak = true;
@ -984,8 +984,8 @@ void CheckOther::checkMemsetZeroBytes()
*/ */
class ScopeInfo { class ScopeInfo {
public: public:
ScopeInfo() : _token(NULL), _parent(NULL) { } ScopeInfo() : _token(NULL), _parent(NULL) {}
ScopeInfo(const Token *token, ScopeInfo *parent_) : _token(token), _parent(parent_) { } ScopeInfo(const Token *token, ScopeInfo *parent_) : _token(token), _parent(parent_) {}
~ScopeInfo(); ~ScopeInfo();
ScopeInfo *parent() { ScopeInfo *parent() {
@ -1053,8 +1053,7 @@ public:
_read(read), _read(read),
_write(write), _write(write),
_modified(modified), _modified(modified),
_allocateMemory(allocateMemory) { _allocateMemory(allocateMemory) {}
}
/** variable is used.. set both read+write */ /** variable is used.. set both read+write */
void use() { void use() {
@ -1640,7 +1639,7 @@ void CheckOther::functionVariableUsage()
while (tok->str() != "{") while (tok->str() != "{")
tok = tok->next(); tok = tok->next();
tok = tok->link(); tok = tok->link();
if (! tok) if (!tok)
break; break;
} }
@ -2253,7 +2252,7 @@ void CheckOther::checkVariableScope()
break; break;
} }
} }
if (! tok) if (!tok)
break; break;
} }
@ -2268,7 +2267,7 @@ void CheckOther::checkVariableScope()
if (indentlevel > 0 && Token::Match(tok, "[{};]")) { if (indentlevel > 0 && Token::Match(tok, "[{};]")) {
// First token of statement.. // First token of statement..
const Token *tok1 = tok->next(); const Token *tok1 = tok->next();
if (! tok1) if (!tok1)
continue; continue;
if ((tok1->str() == "return") || if ((tok1->str() == "return") ||
@ -2531,7 +2530,7 @@ void CheckOther::checkStructMemberUsage()
} }
} }
if (! used) { if (!used) {
unusedStructMemberError(tok->next(), structname, varname); unusedStructMemberError(tok->next(), structname, varname);
} }
} }

View File

@ -1 +1 @@
Dummy test file. Dummy test file .

View File

@ -1 +1 @@
Dummy test file. Dummy test file .

View File

@ -1 +1 @@
Dummy test file. Dummy test file .

View File

@ -1 +1 @@
Dummy test file. Dummy test file .

View File

@ -1 +1 @@
Dummy test file. Dummy test file .

View File

@ -109,8 +109,8 @@ void TestFileList::filterFiles()
QCOMPARE(files.size(), 5); QCOMPARE(files.size(), 5);
QDir dir(QString(SRCDIR) + "/../data/files"); QDir dir(QString(SRCDIR) + "/../data/files");
QString base = dir.canonicalPath(); QString base = dir.canonicalPath();
QVERIFY(! files.contains(base + "/foo1.cpp")); QVERIFY(!files.contains(base + "/foo1.cpp"));
QVERIFY(! files.contains(base + "/foo3.cpp")); QVERIFY(!files.contains(base + "/foo3.cpp"));
} }
void TestFileList::filterFiles2() void TestFileList::filterFiles2()
@ -124,8 +124,8 @@ void TestFileList::filterFiles2()
QCOMPARE(files.size(), 5); QCOMPARE(files.size(), 5);
QDir dir(QString(SRCDIR) + "/../data/files"); QDir dir(QString(SRCDIR) + "/../data/files");
QString base = dir.canonicalPath(); QString base = dir.canonicalPath();
QVERIFY(! files.contains(base + "/foo1.cpp")); QVERIFY(!files.contains(base + "/foo1.cpp"));
QVERIFY(! files.contains(base + "/foo3.cpp")); QVERIFY(!files.contains(base + "/foo3.cpp"));
} }
void TestFileList::filterFiles3() void TestFileList::filterFiles3()
@ -139,10 +139,10 @@ void TestFileList::filterFiles3()
QCOMPARE(files.size(), 6); QCOMPARE(files.size(), 6);
QDir dir(QString(SRCDIR) + "/../data/files"); QDir dir(QString(SRCDIR) + "/../data/files");
QString base = dir.canonicalPath(); QString base = dir.canonicalPath();
QVERIFY(! files.contains(base + "/foo1.cpp")); QVERIFY(!files.contains(base + "/foo1.cpp"));
QVERIFY(! files.contains(base + "/foo3.cpp")); QVERIFY(!files.contains(base + "/foo3.cpp"));
QVERIFY(! files.contains(base + "/dir1/foo1.cpp")); QVERIFY(!files.contains(base + "/dir1/foo1.cpp"));
QVERIFY(! files.contains(base + "/dir2/foo1.cpp")); QVERIFY(!files.contains(base + "/dir2/foo1.cpp"));
} }
void TestFileList::filterFiles4() void TestFileList::filterFiles4()
@ -156,12 +156,12 @@ void TestFileList::filterFiles4()
QCOMPARE(files.size(), 8); QCOMPARE(files.size(), 8);
QDir dir(QString(SRCDIR) + "/../data/files"); QDir dir(QString(SRCDIR) + "/../data/files");
QString base = dir.canonicalPath(); QString base = dir.canonicalPath();
QVERIFY(! files.contains(base + "/dir1/foo1.cpp")); QVERIFY(!files.contains(base + "/dir1/foo1.cpp"));
QVERIFY(! files.contains(base + "/dir1/dir11/foo11.cpp")); QVERIFY(!files.contains(base + "/dir1/dir11/foo11.cpp"));
} }
/* /*
void TestFileList::filterFiles5() void TestFileList::filterFiles5()
{ {
FileList list; FileList list;
QStringList filters; QStringList filters;
filters << QDir(QString(SRCDIR) + "/../data/files/dir1/").absolutePath() + "/"; filters << QDir(QString(SRCDIR) + "/../data/files/dir1/").absolutePath() + "/";
@ -173,6 +173,6 @@ void TestFileList::filterFiles5()
QString base = dir.canonicalPath(); QString base = dir.canonicalPath();
QVERIFY(! files.contains(base + "/dir1/foo1.cpp")); QVERIFY(! files.contains(base + "/dir1/foo1.cpp"));
QVERIFY(! files.contains(base + "/dir1/dir11/foo11.cpp")); QVERIFY(! files.contains(base + "/dir1/dir11/foo11.cpp"));
} }
*/ */
QTEST_MAIN(TestFileList) QTEST_MAIN(TestFileList)

View File

@ -19,7 +19,7 @@
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include <QObject> #include <QObject>
class TestFileList: public QObject { class TestFileList : public QObject {
Q_OBJECT Q_OBJECT
private slots: private slots:

View File

@ -19,7 +19,7 @@
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include <QObject> #include <QObject>
class TestProjectFile: public QObject { class TestProjectFile : public QObject {
Q_OBJECT Q_OBJECT
private slots: private slots:

View File

@ -19,7 +19,7 @@
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include <QObject> #include <QObject>
class TestTranslationHandler: public QObject { class TestTranslationHandler : public QObject {
Q_OBJECT Q_OBJECT
private slots: private slots:

View File

@ -19,7 +19,7 @@
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include <QObject> #include <QObject>
class TestXmlReportV2: public QObject { class TestXmlReportV2 : public QObject {
Q_OBJECT Q_OBJECT
private slots: private slots:

View File

@ -38,9 +38,9 @@ class ImportProject;
/** /**
* @brief This class handles creating threadresult and starting threads * @brief This class handles creating threadresult and starting threads
* *
*/ */
class ThreadHandler : public QObject { class ThreadHandler : public QObject {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -43,7 +43,7 @@ void ThreadResult::fileChecked(const QString &file)
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);
mProgress += QFile(file).size(); mProgress += QFile(file).size();
mFilesChecked ++; mFilesChecked++;
if (mMaxProgress > 0) { if (mMaxProgress > 0) {
const int value = static_cast<int>(PROGRESS_MAX * mProgress / mMaxProgress); const int value = static_cast<int>(PROGRESS_MAX * mProgress / mMaxProgress);

View File

@ -33,9 +33,9 @@ class ErrorItem;
/// @{ /// @{
/** /**
* @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
* *
*/ */
class ThreadResult : public QObject, public ErrorLogger { class ThreadResult : public QObject, public ErrorLogger {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -31,12 +31,12 @@
static void unused() static void unused()
{ {
// NOTE: Keeping semi-colons at end of macro for style preference // NOTE: Keeping semi-colons at end of macro for style preference
#if ((QT_VERSION >= 0x040000)&&(QT_VERSION < 0x050000)) #if ((QT_VERSION >= 0x040000) && (QT_VERSION < 0x050000))
Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "OK")); Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "OK"));
Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "Cancel")); Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "Cancel"));
Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "Close")); Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "Close"));
Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "Save")); Q_UNUSED(QT_TRANSLATE_NOOP("QDialogButtonBox", "Save"));
#elif ((QT_VERSION >= 0x050000)&&(QT_VERSION < 0x060000)) #elif ((QT_VERSION >= 0x050000) && (QT_VERSION < 0x060000))
Q_UNUSED(QT_TRANSLATE_NOOP("QPlatformTheme", "OK")); Q_UNUSED(QT_TRANSLATE_NOOP("QPlatformTheme", "OK"));
Q_UNUSED(QT_TRANSLATE_NOOP("QPlatformTheme", "Cancel")); Q_UNUSED(QT_TRANSLATE_NOOP("QPlatformTheme", "Cancel"));
Q_UNUSED(QT_TRANSLATE_NOOP("QPlatformTheme", "Close")); Q_UNUSED(QT_TRANSLATE_NOOP("QPlatformTheme", "Close"));
@ -69,8 +69,7 @@ TranslationHandler::TranslationHandler(QObject *parent) :
} }
TranslationHandler::~TranslationHandler() TranslationHandler::~TranslationHandler()
{ {}
}
const QStringList TranslationHandler::getNames() const const QStringList TranslationHandler::getNames() const
{ {

View File

@ -29,9 +29,9 @@ class QTranslator;
/// @{ /// @{
/** /**
* @brief Information for one translation. * @brief Information for one translation.
* *
*/ */
struct TranslationInfo { struct TranslationInfo {
/** /**
* @brief Readable name for the translation (e.g. "English"). * @brief Readable name for the translation (e.g. "English").
@ -53,12 +53,12 @@ struct TranslationInfo {
}; };
/** /**
* @brief A class handling the available translations. * @brief A class handling the available translations.
* *
* This class contains a list of available translations. The class also keeps * This class contains a list of available translations. The class also keeps
* track which translation is the currently active translation. * track which translation is the currently active translation.
* *
*/ */
class TranslationHandler : QObject { class TranslationHandler : QObject {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -23,12 +23,10 @@
TxtReport::TxtReport(const QString &filename) : TxtReport::TxtReport(const QString &filename) :
Report(filename) Report(filename)
{ {}
}
TxtReport::~TxtReport() TxtReport::~TxtReport()
{ {}
}
bool TxtReport::create() bool TxtReport::create()
{ {

View File

@ -28,9 +28,9 @@
/** /**
* @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.
*/ */
class TxtReport : public Report { class TxtReport : public Report {
Q_OBJECT Q_OBJECT

View File

@ -27,8 +27,7 @@ static const char VersionAttribute[] = "version";
XmlReport::XmlReport(const QString &filename) : XmlReport::XmlReport(const QString &filename) :
Report(filename) Report(filename)
{ {}
}
QString XmlReport::quoteMessage(const QString &message) QString XmlReport::quoteMessage(const QString &message)
{ {

View File

@ -30,8 +30,8 @@ class ErrorItem;
/** /**
* @brief Base class for XML report classes. * @brief Base class for XML report classes.
*/ */
class XmlReport : public Report { class XmlReport : public Report {
public: public:
explicit XmlReport(const QString &filename); explicit XmlReport(const QString &filename);

View File

@ -51,8 +51,7 @@ XmlReportV2::XmlReportV2(const QString &filename) :
XmlReport(filename), XmlReport(filename),
mXmlReader(nullptr), mXmlReader(nullptr),
mXmlWriter(nullptr) mXmlWriter(nullptr)
{ {}
}
XmlReportV2::~XmlReportV2() XmlReportV2::~XmlReportV2()
{ {

View File

@ -30,10 +30,10 @@ class QXmlStreamWriter;
/** /**
* @brief XML file report version 2. * @brief XML file report version 2.
* This report outputs XML-formatted report. The XML format must match command * This report outputs XML-formatted report. The XML format must match command
* line version's XML output. * line version's XML output.
*/ */
class XmlReportV2 : public XmlReport { class XmlReportV2 : public XmlReport {
public: public:
explicit XmlReportV2(const QString &filename); explicit XmlReportV2(const QString &filename);

View File

@ -23,7 +23,7 @@
#include <vector> #include <vector>
class Token; class Token;
template <class T> template<class T>
class ValuePtr; class ValuePtr;
struct Analyzer { struct Analyzer {
@ -86,7 +86,9 @@ struct Analyzer {
return get(Incremental); return get(Incremental);
} }
bool isSymbolicMatch() const { return get(SymbolicMatch); } bool isSymbolicMatch() const {
return get(SymbolicMatch);
}
bool matches() const { bool matches() const {
return get(Match); return get(Match);

View File

@ -1,20 +1,20 @@
/* /*
* Cppcheck - A tool for static C/C++ code analysis * Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2021 Cppcheck team. * Copyright (C) 2007-2021 Cppcheck team.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "analyzerinfo.h" #include "analyzerinfo.h"

View File

@ -1,20 +1,20 @@
/* /*
* Cppcheck - A tool for static C/C++ code analysis * Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2021 Cppcheck team. * Copyright (C) 2007-2021 Cppcheck team.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#ifndef analyzerinfoH #ifndef analyzerinfoH
@ -34,18 +34,18 @@ class ErrorMessage;
/// @{ /// @{
/** /**
* @brief Analyzer information * @brief Analyzer information
* *
* Store various analysis information: * Store various analysis information:
* - checksum * - checksum
* - error messages * - error messages
* - whole program analysis data * - whole program analysis data
* *
* The information can be used for various purposes. It allows: * The information can be used for various purposes. It allows:
* - 'make' - only analyze TUs that are changed and generate full report * - 'make' - only analyze TUs that are changed and generate full report
* - should be possible to add distributed analysis later * - should be possible to add distributed analysis later
* - multi-threaded whole program analysis * - multi-threaded whole program analysis
*/ */
class CPPCHECKLIB AnalyzerInformation { class CPPCHECKLIB AnalyzerInformation {
public: public:
~AnalyzerInformation(); ~AnalyzerInformation();

View File

@ -37,7 +37,7 @@
#include <stack> #include <stack>
#include <utility> #include <utility>
template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*>)> template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
void visitAstNodesGeneric(T *ast, std::function<ChildrenToVisit(T *)> visitor) void visitAstNodesGeneric(T *ast, std::function<ChildrenToVisit(T *)> visitor)
{ {
std::stack<T *> tokens; std::stack<T *> tokens;
@ -344,7 +344,7 @@ static bool hasToken(const Token * startTok, const Token * stopTok, const Token
return false; return false;
} }
template <class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*>)> template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
static T* previousBeforeAstLeftmostLeafGeneric(T* tok) static T* previousBeforeAstLeftmostLeafGeneric(T* tok)
{ {
if (!tok) if (!tok)
@ -364,7 +364,7 @@ Token* previousBeforeAstLeftmostLeaf(Token* tok)
return previousBeforeAstLeftmostLeafGeneric(tok); return previousBeforeAstLeftmostLeafGeneric(tok);
} }
template <class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*>)> template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
static T* nextAfterAstRightmostLeafGeneric(T* tok) static T* nextAfterAstRightmostLeafGeneric(T* tok)
{ {
const Token * rightmostLeaf = tok; const Token * rightmostLeaf = tok;
@ -474,7 +474,7 @@ bool astIsRHS(const Token* tok)
return parent->astOperand2() == tok; return parent->astOperand2() == tok;
} }
template <class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*>)> template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
static T* getCondTokImpl(T* tok) static T* getCondTokImpl(T* tok)
{ {
if (!tok) if (!tok)
@ -489,7 +489,7 @@ static T* getCondTokImpl(T* tok)
return tok->next()->astOperand2(); return tok->next()->astOperand2();
} }
template <class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*>)> template<class T, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
static T* getCondTokFromEndImpl(T* endBlock) static T* getCondTokFromEndImpl(T* endBlock)
{ {
if (!Token::simpleMatch(endBlock, "}")) if (!Token::simpleMatch(endBlock, "}"))
@ -2102,7 +2102,9 @@ Token* findVariableChanged(Token *start, const Token *end, int indirect, const n
return nullptr; return nullptr;
if (depth < 0) if (depth < 0)
return start; return start;
auto getExprTok = memoize([&] { return findExpression(start, exprid); }); auto getExprTok = memoize([&] {
return findExpression(start, exprid);
});
for (Token *tok = start; tok != end; tok = tok->next()) { for (Token *tok = start; tok != end; tok = tok->next()) {
if (tok->exprId() != exprid) { if (tok->exprId() != exprid) {
if (globalvar && Token::Match(tok, "%name% (")) if (globalvar && Token::Match(tok, "%name% ("))
@ -2279,7 +2281,7 @@ const Token *findLambdaStartToken(const Token *last)
return nullptr; return nullptr;
} }
template <class T> template<class T>
T* findLambdaEndTokenGeneric(T* first) T* findLambdaEndTokenGeneric(T* first)
{ {
if (!first || first->str() != "[") if (!first || first->str() != "[")

View File

@ -62,8 +62,7 @@ public:
/** This constructor is used when running checks. */ /** This constructor is used when running checks. */
Check(const std::string &aname, const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) Check(const std::string &aname, const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: mTokenizer(tokenizer), mSettings(settings), mErrorLogger(errorLogger), mName(aname) { : mTokenizer(tokenizer), mSettings(settings), mErrorLogger(errorLogger), mName(aname) {}
}
virtual ~Check() { virtual ~Check() {
if (!mTokenizer) if (!mTokenizer)
@ -116,7 +115,7 @@ public:
} }
// Return true if an error is reported. // Return true if an error is reported.
virtual bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<FileInfo*> &fileInfo, const Settings& /*settings*/, ErrorLogger &/*errorLogger*/) { virtual bool analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<FileInfo*> &fileInfo, const Settings& /*settings*/, ErrorLogger & /*errorLogger*/) {
(void)ctu; (void)ctu;
(void)fileInfo; (void)fileInfo;
//(void)settings; //(void)settings;

View File

@ -43,13 +43,11 @@ class Tokenizer;
class CPPCHECKLIB Check64BitPortability : public Check { class CPPCHECKLIB Check64BitPortability : public Check {
public: public:
/** This constructor is used when registering the Check64BitPortability */ /** This constructor is used when registering the Check64BitPortability */
Check64BitPortability() : Check(myName()) { Check64BitPortability() : Check(myName()) {}
}
/** This constructor is used when running checks. */ /** This constructor is used when running checks. */
Check64BitPortability(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) Check64BitPortability(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -42,12 +42,10 @@ class Tokenizer;
class CPPCHECKLIB CheckAssert : public Check { class CPPCHECKLIB CheckAssert : public Check {
public: public:
CheckAssert() : Check(myName()) { CheckAssert() : Check(myName()) {}
}
CheckAssert(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckAssert(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** run checks, the token list is not simplified */ /** run checks, the token list is not simplified */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -42,13 +42,11 @@ class Variable;
class CPPCHECKLIB CheckAutoVariables : public Check { class CPPCHECKLIB CheckAutoVariables : public Check {
public: public:
/** This constructor is used when registering the CheckClass */ /** This constructor is used when registering the CheckClass */
CheckAutoVariables() : Check(myName()) { CheckAutoVariables() : Check(myName()) {}
}
/** 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(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -41,13 +41,11 @@ class Tokenizer;
class CPPCHECKLIB CheckBool : public Check { class CPPCHECKLIB CheckBool : public Check {
public: public:
/** @brief This constructor is used when registering the CheckClass */ /** @brief This constructor is used when registering the CheckClass */
CheckBool() : Check(myName()) { CheckBool() : Check(myName()) {}
}
/** @brief This constructor is used when running checks. */ /** @brief This constructor is used when running checks. */
CheckBool(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckBool(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -40,13 +40,11 @@ class Token;
class CPPCHECKLIB CheckBoost : public Check { class CPPCHECKLIB CheckBoost : public Check {
public: public:
/** This constructor is used when registering the CheckClass */ /** This constructor is used when registering the CheckClass */
CheckBoost() : Check(myName()) { CheckBoost() : Check(myName()) {}
}
/** This constructor is used when running checks. */ /** This constructor is used when running checks. */
CheckBoost(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckBoost(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -60,13 +60,11 @@ class CPPCHECKLIB CheckBufferOverrun : public Check {
public: public:
/** This constructor is used when registering the CheckClass */ /** This constructor is used when registering the CheckClass */
CheckBufferOverrun() : Check(myName()) { CheckBufferOverrun() : Check(myName()) {}
}
/** 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(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckBufferOverrun checkBufferOverrun(tokenizer, settings, errorLogger); CheckBufferOverrun checkBufferOverrun(tokenizer, settings, errorLogger);

View File

@ -106,9 +106,7 @@ static bool isVclTypeInit(const Type *type)
CheckClass::CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckClass::CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger), : Check(myName(), tokenizer, settings, errorLogger),
mSymbolDatabase(tokenizer?tokenizer->getSymbolDatabase():nullptr) mSymbolDatabase(tokenizer?tokenizer->getSymbolDatabase():nullptr)
{ {}
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// ClassCheck: Check that all class constructors are ok. // ClassCheck: Check that all class constructors are ok.
@ -467,14 +465,14 @@ void CheckClass::copyconstructors()
} }
/* This doesn't work. See #4154 /* This doesn't work. See #4154
void CheckClass::copyConstructorMallocError(const Token *cctor, const Token *alloc, const std::string& varname) void CheckClass::copyConstructorMallocError(const Token *cctor, const Token *alloc, const std::string& varname)
{ {
std::list<const Token*> callstack; std::list<const Token*> callstack;
callstack.push_back(cctor); callstack.push_back(cctor);
callstack.push_back(alloc); callstack.push_back(alloc);
reportError(callstack, Severity::warning, "copyCtorNoAllocation", "Copy constructor does not allocate memory for member '" + varname + "' although memory has been allocated in other constructors."); reportError(callstack, Severity::warning, "copyCtorNoAllocation", "Copy constructor does not allocate memory for member '" + varname + "' although memory has been allocated in other constructors.");
} }
*/ */
void CheckClass::copyConstructorShallowCopyError(const Token *tok, const std::string& varname) void CheckClass::copyConstructorShallowCopyError(const Token *tok, const std::string& varname)
{ {
@ -1111,7 +1109,7 @@ static bool checkFunctionUsage(const Function *privfunc, const Scope* scope)
} }
const std::map<std::string, Type*>::const_iterator end = scope->definedTypesMap.end(); const std::map<std::string, Type*>::const_iterator end = scope->definedTypesMap.end();
for (std::map<std::string, Type*>::const_iterator iter = scope->definedTypesMap.begin(); iter != end; ++ iter) { for (std::map<std::string, Type*>::const_iterator iter = scope->definedTypesMap.begin(); iter != end; ++iter) {
const Type *type = (*iter).second; const Type *type = (*iter).second;
if (type->enclosingScope == scope && checkFunctionUsage(privfunc, type->classScope)) if (type->enclosingScope == scope && checkFunctionUsage(privfunc, type->classScope))
return true; return true;
@ -2296,7 +2294,7 @@ void CheckClass::checkConstError2(const Token *tok1, const Token *tok2, const st
namespace { // avoid one-definition-rule violation namespace { // avoid one-definition-rule violation
struct VarInfo { struct VarInfo {
VarInfo(const Variable *_var, const Token *_tok) VarInfo(const Variable *_var, const Token *_tok)
: var(_var), tok(_tok) { } : var(_var), tok(_tok) {}
const Variable *var; const Variable *var;
const Token *tok; const Token *tok;
@ -2406,9 +2404,9 @@ void CheckClass::selfInitializationError(const Token* tok, const std::string& va
void CheckClass::checkVirtualFunctionCallInConstructor() void CheckClass::checkVirtualFunctionCallInConstructor()
{ {
if (! mSettings->severity.isEnabled(Severity::warning)) if (!mSettings->severity.isEnabled(Severity::warning))
return; return;
std::map<const Function *, std::list<const Token *> > virtualFunctionCallsMap; std::map<const Function *, std::list<const Token *>> virtualFunctionCallsMap;
for (const Scope *scope : mSymbolDatabase->functionScopes) { for (const Scope *scope : mSymbolDatabase->functionScopes) {
if (scope->function == nullptr || !scope->function->hasBody() || if (scope->function == nullptr || !scope->function->hasBody() ||
!(scope->function->isConstructor() || !(scope->function->isConstructor() ||
@ -2432,9 +2430,9 @@ void CheckClass::checkVirtualFunctionCallInConstructor()
} }
const std::list<const Token *> & CheckClass::getVirtualFunctionCalls(const Function & function, const std::list<const Token *> & CheckClass::getVirtualFunctionCalls(const Function & function,
std::map<const Function *, std::list<const Token *> > & virtualFunctionCallsMap) std::map<const Function *, std::list<const Token *>> & virtualFunctionCallsMap)
{ {
const std::map<const Function *, std::list<const Token *> >::const_iterator found = virtualFunctionCallsMap.find(&function); const std::map<const Function *, std::list<const Token *>>::const_iterator found = virtualFunctionCallsMap.find(&function);
if (found != virtualFunctionCallsMap.end()) if (found != virtualFunctionCallsMap.end())
return found->second; return found->second;
@ -2489,7 +2487,7 @@ const std::list<const Token *> & CheckClass::getVirtualFunctionCalls(const Funct
} }
void CheckClass::getFirstVirtualFunctionCallStack( void CheckClass::getFirstVirtualFunctionCallStack(
std::map<const Function *, std::list<const Token *> > & virtualFunctionCallsMap, std::map<const Function *, std::list<const Token *>> & virtualFunctionCallsMap,
const Token * callToken, const Token * callToken,
std::list<const Token *> & pureFuncStack) std::list<const Token *> & pureFuncStack)
{ {
@ -2498,7 +2496,7 @@ void CheckClass::getFirstVirtualFunctionCallStack(
pureFuncStack.push_back(callFunction->tokenDef); pureFuncStack.push_back(callFunction->tokenDef);
return; return;
} }
std::map<const Function *, std::list<const Token *> >::const_iterator found = virtualFunctionCallsMap.find(callFunction); std::map<const Function *, std::list<const Token *>>::const_iterator found = virtualFunctionCallsMap.find(callFunction);
if (found == virtualFunctionCallsMap.end() || found->second.empty()) { if (found == virtualFunctionCallsMap.end() || found->second.empty()) {
pureFuncStack.clear(); pureFuncStack.clear();
return; return;

View File

@ -44,8 +44,7 @@ class Token;
class CPPCHECKLIB CheckClass : public Check { class CPPCHECKLIB CheckClass : public Check {
public: public:
/** @brief This constructor is used when registering the CheckClass */ /** @brief This constructor is used when registering the CheckClass */
CheckClass() : Check(myName()), mSymbolDatabase(nullptr) { CheckClass() : Check(myName()), mSymbolDatabase(nullptr) {}
}
/** @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);
@ -310,7 +309,7 @@ private:
// constructors helper function // constructors helper function
/** @brief Information about a member variable. Used when checking for uninitialized variables */ /** @brief Information about a member variable. Used when checking for uninitialized variables */
struct Usage { struct Usage {
explicit Usage(const Variable *var) : var(var), assign(false), init(false) { } explicit Usage(const Variable *var) : var(var), assign(false), init(false) {}
/** Variable that this usage is for */ /** Variable that this usage is for */
const Variable *var; const Variable *var;
@ -374,7 +373,7 @@ private:
*/ */
const std::list<const Token *> & getVirtualFunctionCalls( const std::list<const Token *> & getVirtualFunctionCalls(
const Function & function, const Function & function,
std::map<const Function *, std::list<const Token *> > & virtualFunctionCallsMap); std::map<const Function *, std::list<const Token *>> & virtualFunctionCallsMap);
/** /**
* @brief looks for the first virtual function call stack * @brief looks for the first virtual function call stack
@ -383,7 +382,7 @@ private:
* @param[in,out] pureFuncStack list to append the stack * @param[in,out] pureFuncStack list to append the stack
*/ */
void getFirstVirtualFunctionCallStack( void getFirstVirtualFunctionCallStack(
std::map<const Function *, std::list<const Token *> > & virtualFunctionCallsMap, std::map<const Function *, std::list<const Token *>> & virtualFunctionCallsMap,
const Token *callToken, const Token *callToken,
std::list<const Token *> & pureFuncStack); std::list<const Token *> & pureFuncStack);

View File

@ -885,7 +885,7 @@ static std::string invertOperatorForOperandSwap(std::string s)
return s; return s;
} }
template <typename T> template<typename T>
static bool checkIntRelation(const std::string &op, const T value1, const T value2) static bool checkIntRelation(const std::string &op, const T value1, const T value2)
{ {
return (op == "==" && value1 == value2) || return (op == "==" && value1 == value2) ||
@ -1172,7 +1172,7 @@ void CheckCondition::checkIncorrectLogicOperator()
const double d2 = (isfloat) ? MathLib::toDoubleNumber(value2) : 0; const double d2 = (isfloat) ? MathLib::toDoubleNumber(value2) : 0;
const MathLib::bigint i1 = (isfloat) ? 0 : MathLib::toLongNumber(value1); const MathLib::bigint i1 = (isfloat) ? 0 : MathLib::toLongNumber(value1);
const MathLib::bigint i2 = (isfloat) ? 0 : MathLib::toLongNumber(value2); const MathLib::bigint i2 = (isfloat) ? 0 : MathLib::toLongNumber(value2);
const bool useUnsignedInt = (std::numeric_limits<MathLib::bigint>::max()==i1)||(std::numeric_limits<MathLib::bigint>::max()==i2); const bool useUnsignedInt = (std::numeric_limits<MathLib::bigint>::max()==i1) || (std::numeric_limits<MathLib::bigint>::max()==i2);
const MathLib::biguint u1 = (useUnsignedInt) ? MathLib::toLongNumber(value1) : 0; const MathLib::biguint u1 = (useUnsignedInt) ? MathLib::toLongNumber(value1) : 0;
const MathLib::biguint u2 = (useUnsignedInt) ? MathLib::toLongNumber(value2) : 0; const MathLib::biguint u2 = (useUnsignedInt) ? MathLib::toLongNumber(value2) : 0;
// evaluate if expression is always true/false // evaluate if expression is always true/false

View File

@ -47,13 +47,11 @@ class ValueType;
class CPPCHECKLIB CheckCondition : public Check { class CPPCHECKLIB CheckCondition : public Check {
public: public:
/** This constructor is used when registering the CheckAssignIf */ /** This constructor is used when registering the CheckAssignIf */
CheckCondition() : Check(myName()) { CheckCondition() : Check(myName()) {}
}
/** This constructor is used when running checks. */ /** This constructor is used when running checks. */
CheckCondition(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckCondition(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckCondition checkCondition(tokenizer, settings, errorLogger); CheckCondition checkCondition(tokenizer, settings, errorLogger);

View File

@ -54,13 +54,11 @@ static const struct CWE CWE480(480U); // Use of Incorrect Operator
class CPPCHECKLIB CheckExceptionSafety : public Check { class CPPCHECKLIB CheckExceptionSafety : public Check {
public: public:
/** This constructor is used when registering the CheckClass */ /** This constructor is used when registering the CheckClass */
CheckExceptionSafety() : Check(myName()) { CheckExceptionSafety() : Check(myName()) {}
}
/** 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(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
if (tokenizer->isC()) if (tokenizer->isC())

View File

@ -51,13 +51,11 @@ namespace ValueFlow {
class CPPCHECKLIB CheckFunctions : public Check { class CPPCHECKLIB CheckFunctions : public Check {
public: public:
/** This constructor is used when registering the CheckFunctions */ /** This constructor is used when registering the CheckFunctions */
CheckFunctions() : Check(myName()) { CheckFunctions() : Check(myName()) {}
}
/** This constructor is used when running checks. */ /** This constructor is used when running checks. */
CheckFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -36,13 +36,11 @@
class CPPCHECKLIB CheckInternal : public Check { class CPPCHECKLIB CheckInternal : public Check {
public: public:
/** This constructor is used when registering the CheckClass */ /** This constructor is used when registering the CheckClass */
CheckInternal() : Check(myName()) { CheckInternal() : Check(myName()) {}
}
/** This constructor is used when running checks. */ /** This constructor is used when running checks. */
CheckInternal(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckInternal(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
if (!settings->checks.isEnabled(Checks::internalCheck)) if (!settings->checks.isEnabled(Checks::internalCheck))

View File

@ -108,8 +108,7 @@ struct Filepointer {
AppendMode append_mode; AppendMode append_mode;
std::string filename; std::string filename;
explicit Filepointer(OpenMode mode_ = OpenMode::UNKNOWN_OM) explicit Filepointer(OpenMode mode_ = OpenMode::UNKNOWN_OM)
: mode(mode_), mode_indent(0), lastOperation(Operation::NONE), op_indent(0), append_mode(AppendMode::UNKNOWN_AM) { : mode(mode_), mode_indent(0), lastOperation(Operation::NONE), op_indent(0), append_mode(AppendMode::UNKNOWN_AM) {}
}
}; };
namespace { namespace {
@ -1214,7 +1213,7 @@ void CheckIO::checkFormatString(const Token * const tok,
break; break;
case 'p': case 'p':
if (argInfo.typeToken->tokType() == Token::eString) if (argInfo.typeToken->tokType() == Token::eString)
;// string literals are passed as pointers to literal start, okay ; // string literals are passed as pointers to literal start, okay
else if (argInfo.isKnownType() && !argInfo.isArrayOrPointer()) else if (argInfo.isKnownType() && !argInfo.isArrayOrPointer())
invalidPrintfArgTypeError_p(tok, numFormat, &argInfo); invalidPrintfArgTypeError_p(tok, numFormat, &argInfo);
done = true; done = true;

View File

@ -43,13 +43,11 @@ class ErrorLogger;
class CPPCHECKLIB CheckIO : public Check { class CPPCHECKLIB CheckIO : public Check {
public: public:
/** @brief This constructor is used when registering CheckIO */ /** @brief This constructor is used when registering CheckIO */
CheckIO() : Check(myName()) { CheckIO() : Check(myName()) {}
}
/** @brief This constructor is used when running checks. */ /** @brief This constructor is used when running checks. */
CheckIO(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckIO(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** @brief Run checks on the normal token list */ /** @brief Run checks on the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -257,12 +257,12 @@ static bool isLocalVarNoAutoDealloc(const Token *varTok, const bool isCpp)
} }
/** checks if nameToken is a name of a function in a function call: /** checks if nameToken is a name of a function in a function call:
* func(arg) * func(arg)
* or * or
* func<temp1_arg>(arg) * func<temp1_arg>(arg)
* @param nameToken Function name token * @param nameToken Function name token
* @return opening parenthesis token or NULL if not a function call * @return opening parenthesis token or NULL if not a function call
*/ */
static const Token * isFunctionCall(const Token * nameToken) static const Token * isFunctionCall(const Token * nameToken)
{ {

View File

@ -108,13 +108,11 @@ public:
class CPPCHECKLIB CheckLeakAutoVar : public Check { class CPPCHECKLIB CheckLeakAutoVar : public Check {
public: public:
/** This constructor is used when registering the CheckLeakAutoVar */ /** This constructor is used when registering the CheckLeakAutoVar */
CheckLeakAutoVar() : Check(myName()) { CheckLeakAutoVar() : Check(myName()) {}
}
/** This constructor is used when running checks. */ /** This constructor is used when running checks. */
CheckLeakAutoVar(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckLeakAutoVar(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckLeakAutoVar checkLeakAutoVar(tokenizer, settings, errorLogger); CheckLeakAutoVar checkLeakAutoVar(tokenizer, settings, errorLogger);

View File

@ -82,11 +82,11 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getAllocationType(const Token *tok2,
tok2 = tok2->link(); tok2 = tok2->link();
tok2 = tok2 ? tok2->next() : nullptr; tok2 = tok2 ? tok2->next() : nullptr;
} }
if (! tok2) if (!tok2)
return No; return No;
if (tok2->str() == "::") if (tok2->str() == "::")
tok2 = tok2->next(); tok2 = tok2->next();
if (! tok2->isName()) if (!tok2->isName())
return No; return No;
if (!Token::Match(tok2, "%name% ::|. %type%")) { if (!Token::Match(tok2, "%name% ::|. %type%")) {
@ -169,7 +169,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getReallocationType(const Token *tok
tok2 = tok2->link(); tok2 = tok2->link();
tok2 = tok2 ? tok2->next() : nullptr; tok2 = tok2 ? tok2->next() : nullptr;
} }
if (! tok2) if (!tok2)
return No; return No;
if (!Token::Match(tok2, "%name% (")) if (!Token::Match(tok2, "%name% ("))

View File

@ -88,8 +88,7 @@ public:
void operator=(const CheckMemoryLeak &) = delete; void operator=(const CheckMemoryLeak &) = delete;
CheckMemoryLeak(const Tokenizer *t, ErrorLogger *e, const Settings *s) CheckMemoryLeak(const Tokenizer *t, ErrorLogger *e, const Settings *s)
: mTokenizer_(t), mErrorLogger_(e), mSettings_(s) { : mTokenizer_(t), mErrorLogger_(e), mSettings_(s) {}
}
/** @brief What type of allocation are used.. the "Many" means that several types of allocation and deallocation are used */ /** @brief What type of allocation are used.. the "Many" means that several types of allocation and deallocation are used */
enum AllocType { No, Malloc, New, NewArray, File, Fd, Pipe, OtherMem, OtherRes, Many }; enum AllocType { No, Malloc, New, NewArray, File, Fd, Pipe, OtherMem, OtherRes, Many };
@ -172,13 +171,11 @@ public:
class CPPCHECKLIB CheckMemoryLeakInFunction : private Check, public CheckMemoryLeak { class CPPCHECKLIB CheckMemoryLeakInFunction : private Check, public CheckMemoryLeak {
public: public:
/** @brief This constructor is used when registering this class */ /** @brief This constructor is used when registering this class */
CheckMemoryLeakInFunction() : Check(myName()), CheckMemoryLeak(nullptr, nullptr, nullptr) { CheckMemoryLeakInFunction() : Check(myName()), CheckMemoryLeak(nullptr, nullptr, nullptr) {}
}
/** @brief This constructor is used when running checks */ /** @brief 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(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) { : Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {}
}
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckMemoryLeakInFunction checkMemoryLeak(tokenizer, settings, errorLogger); CheckMemoryLeakInFunction checkMemoryLeak(tokenizer, settings, errorLogger);
@ -234,12 +231,10 @@ private:
class CPPCHECKLIB CheckMemoryLeakInClass : private Check, private CheckMemoryLeak { class CPPCHECKLIB CheckMemoryLeakInClass : private Check, private CheckMemoryLeak {
public: public:
CheckMemoryLeakInClass() : Check(myName()), CheckMemoryLeak(nullptr, nullptr, nullptr) { CheckMemoryLeakInClass() : Check(myName()), CheckMemoryLeak(nullptr, nullptr, nullptr) {}
}
CheckMemoryLeakInClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckMemoryLeakInClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) { : Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {}
}
void runChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) OVERRIDE { void runChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) OVERRIDE {
if (!tokenizr->isCPP()) if (!tokenizr->isCPP())
@ -281,12 +276,10 @@ private:
class CPPCHECKLIB CheckMemoryLeakStructMember : private Check, private CheckMemoryLeak { class CPPCHECKLIB CheckMemoryLeakStructMember : private Check, private CheckMemoryLeak {
public: public:
CheckMemoryLeakStructMember() : Check(myName()), CheckMemoryLeak(nullptr, nullptr, nullptr) { CheckMemoryLeakStructMember() : Check(myName()), CheckMemoryLeak(nullptr, nullptr, nullptr) {}
}
CheckMemoryLeakStructMember(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckMemoryLeakStructMember(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) { : Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {}
}
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckMemoryLeakStructMember checkMemoryLeak(tokenizer, settings, errorLogger); CheckMemoryLeakStructMember checkMemoryLeak(tokenizer, settings, errorLogger);
@ -302,8 +295,7 @@ private:
void checkStructVariable(const Variable * const variable); void checkStructVariable(const Variable * const variable);
void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const OVERRIDE { void getErrorMessages(ErrorLogger * /*errorLogger*/, const Settings * /*settings*/) const OVERRIDE {}
}
static std::string myName() { static std::string myName() {
return "Memory leaks (struct members)"; return "Memory leaks (struct members)";
@ -320,12 +312,10 @@ private:
class CPPCHECKLIB CheckMemoryLeakNoVar : private Check, private CheckMemoryLeak { class CPPCHECKLIB CheckMemoryLeakNoVar : private Check, private CheckMemoryLeak {
public: public:
CheckMemoryLeakNoVar() : Check(myName()), CheckMemoryLeak(nullptr, nullptr, nullptr) { CheckMemoryLeakNoVar() : Check(myName()), CheckMemoryLeak(nullptr, nullptr, nullptr) {}
}
CheckMemoryLeakNoVar(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckMemoryLeakNoVar(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) { : Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {}
}
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckMemoryLeakNoVar checkMemoryLeak(tokenizer, settings, errorLogger); CheckMemoryLeakNoVar checkMemoryLeak(tokenizer, settings, errorLogger);

View File

@ -46,13 +46,11 @@ class Tokenizer;
class CPPCHECKLIB CheckNullPointer : public Check { class CPPCHECKLIB CheckNullPointer : public Check {
public: public:
/** @brief This constructor is used when registering the CheckNullPointer */ /** @brief This constructor is used when registering the CheckNullPointer */
CheckNullPointer() : Check(myName()) { CheckNullPointer() : Check(myName()) {}
}
/** @brief This constructor is used when running checks. */ /** @brief This constructor is used when running checks. */
CheckNullPointer(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckNullPointer(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -1218,7 +1218,7 @@ static bool canBeConst(const Variable *var)
return false; return false;
else { else {
const Variable* argVar = tok3->astOperand1()->function()->getArgumentVar(argNr); const Variable* argVar = tok3->astOperand1()->function()->getArgumentVar(argNr);
if (!argVar|| (!argVar->isConst() && argVar->isReference())) if (!argVar || (!argVar->isConst() && argVar->isReference()))
return false; return false;
} }
} else if (parent->isUnaryOp("&")) { } else if (parent->isUnaryOp("&")) {
@ -1268,8 +1268,7 @@ void CheckOther::checkPassByReference()
bool inconclusive = false; bool inconclusive = false;
if (var->valueType() && var->valueType()->type == ValueType::Type::CONTAINER) { if (var->valueType() && var->valueType()->type == ValueType::Type::CONTAINER) {} else if (var->type() && !var->type()->isEnumType()) { // Check if type is a struct or class.
} else if (var->type() && !var->type()->isEnumType()) { // Check if type is a struct or class.
// Ensure that it is a large object. // Ensure that it is a large object.
if (!var->type()->classScope) if (!var->type()->classScope)
inconclusive = true; inconclusive = true;
@ -2076,7 +2075,7 @@ namespace {
for (const Scope &scope : symbolDatabase->scopeList) { for (const Scope &scope : symbolDatabase->scopeList) {
// only add const functions that do not have a non-const overloaded version // only add const functions that do not have a non-const overloaded version
// since it is pretty much impossible to tell which is being called. // since it is pretty much impossible to tell which is being called.
using StringFunctionMap = std::map<std::string, std::list<const Function*> >; using StringFunctionMap = std::map<std::string, std::list<const Function*>>;
StringFunctionMap functionsByName; StringFunctionMap functionsByName;
for (const Function &func : scope.functionList) { for (const Function &func : scope.functionList) {
functionsByName[func.tokenDef->str()].push_back(&func); functionsByName[func.tokenDef->str()].push_back(&func);

View File

@ -50,13 +50,11 @@ class ErrorLogger;
class CPPCHECKLIB CheckOther : public Check { class CPPCHECKLIB CheckOther : public Check {
public: public:
/** @brief This constructor is used when registering the CheckClass */ /** @brief This constructor is used when registering the CheckClass */
CheckOther() : Check(myName()) { CheckOther() : Check(myName()) {}
}
/** @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(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -42,13 +42,11 @@ class Token;
class CPPCHECKLIB CheckPostfixOperator : public Check { class CPPCHECKLIB CheckPostfixOperator : public Check {
public: public:
/** This constructor is used when registering the CheckPostfixOperator */ /** This constructor is used when registering the CheckPostfixOperator */
CheckPostfixOperator() : Check(myName()) { CheckPostfixOperator() : Check(myName()) {}
}
/** This constructor is used when running checks. */ /** This constructor is used when running checks. */
CheckPostfixOperator(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckPostfixOperator(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
if (tokenizer->isC()) if (tokenizer->isC())

View File

@ -41,13 +41,11 @@ class Tokenizer;
class CPPCHECKLIB CheckSizeof : public Check { class CPPCHECKLIB CheckSizeof : public Check {
public: public:
/** @brief This constructor is used when registering the CheckClass */ /** @brief This constructor is used when registering the CheckClass */
CheckSizeof() : Check(myName()) { CheckSizeof() : Check(myName()) {}
}
/** @brief This constructor is used when running checks. */ /** @brief This constructor is used when running checks. */
CheckSizeof(const Tokenizer* tokenizer, const Settings* settings, ErrorLogger* errorLogger) CheckSizeof(const Tokenizer* tokenizer, const Settings* settings, ErrorLogger* errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer* tokenizer, const Settings* settings, ErrorLogger* errorLogger) OVERRIDE { void runChecks(const Tokenizer* tokenizer, const Settings* settings, ErrorLogger* errorLogger) OVERRIDE {

View File

@ -988,7 +988,7 @@ void CheckStl::invalidContainer()
const ValueFlow::Value* v = nullptr; const ValueFlow::Value* v = nullptr;
ErrorPath errorPath; ErrorPath errorPath;
PathAnalysis::Info info = PathAnalysis::Info info =
PathAnalysis{endToken, library} .forwardFind([&](const PathAnalysis::Info& info) { PathAnalysis{endToken, library}.forwardFind([&](const PathAnalysis::Info& info) {
if (!info.tok->variable()) if (!info.tok->variable())
return false; return false;
if (info.tok->varId() == 0) if (info.tok->varId() == 0)

View File

@ -46,13 +46,11 @@ class ErrorLogger;
class CPPCHECKLIB CheckStl : public Check { class CPPCHECKLIB CheckStl : public Check {
public: public:
/** This constructor is used when registering the CheckClass */ /** This constructor is used when registering the CheckClass */
CheckStl() : Check(myName()) { CheckStl() : Check(myName()) {}
}
/** 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(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** run checks, the token list is not simplified */ /** run checks, the token list is not simplified */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -41,13 +41,11 @@ class Tokenizer;
class CPPCHECKLIB CheckString : public Check { class CPPCHECKLIB CheckString : public Check {
public: public:
/** @brief This constructor is used when registering the CheckClass */ /** @brief This constructor is used when registering the CheckClass */
CheckString() : Check(myName()) { CheckString() : Check(myName()) {}
}
/** @brief This constructor is used when running checks. */ /** @brief This constructor is used when running checks. */
CheckString(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckString(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -40,13 +40,11 @@ class Tokenizer;
class CPPCHECKLIB CheckType : public Check { class CPPCHECKLIB CheckType : public Check {
public: public:
/** @brief This constructor is used when registering the CheckClass */ /** @brief This constructor is used when registering the CheckClass */
CheckType() : Check(myName()) { CheckType() : Check(myName()) {}
}
/** @brief This constructor is used when running checks. */ /** @brief This constructor is used when running checks. */
CheckType(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckType(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -306,7 +306,7 @@ static void conditionAlwaysTrueOrFalse(const Token *tok, const std::map<nonneg i
else if (tok->str() == "!") { else if (tok->str() == "!") {
bool t=false,f=false; bool t=false,f=false;
conditionAlwaysTrueOrFalse(tok->astOperand1(), variableValue, &t, &f); conditionAlwaysTrueOrFalse(tok->astOperand1(), variableValue, &t, &f);
if (t||f) { if (t || f) {
*alwaysTrue = !t; *alwaysTrue = !t;
*alwaysFalse = !f; *alwaysFalse = !f;
} }

View File

@ -55,13 +55,11 @@ struct VariableValue {
class CPPCHECKLIB CheckUninitVar : public Check { class CPPCHECKLIB CheckUninitVar : public Check {
public: public:
/** @brief This constructor is used when registering the CheckUninitVar */ /** @brief This constructor is used when registering the CheckUninitVar */
CheckUninitVar() : Check(myName()) { CheckUninitVar() : Check(myName()) {}
}
/** @brief This constructor is used when running checks. */ /** @brief This constructor is used when running checks. */
CheckUninitVar(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckUninitVar(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE { void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {

View File

@ -223,7 +223,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
} }
if (funcname) { if (funcname) {
FunctionUsage &func = mFunctions[ funcname->str()]; FunctionUsage &func = mFunctions[funcname->str()];
const std::string& called_from_file = tokenizer.list.getSourceFilePath(); const std::string& called_from_file = tokenizer.list.getSourceFilePath();
if (func.filename.empty() || func.filename == "+" || func.filename != called_from_file) if (func.filename.empty() || func.filename == "+" || func.filename != called_from_file)
@ -305,7 +305,7 @@ bool CheckUnusedFunctions::check(ErrorLogger * const errorLogger, const Settings
filename = func.filename; filename = func.filename;
unusedFunctionError(errorLogger, filename, func.lineNumber, it->first); unusedFunctionError(errorLogger, filename, func.lineNumber, it->first);
errors = true; errors = true;
} else if (! func.usedOtherFile) { } else if (!func.usedOtherFile) {
/** @todo add error message "function is only used in <file> it can be static" */ /** @todo add error message "function is only used in <file> it can be static" */
/* /*
std::ostringstream errmsg; std::ostringstream errmsg;
@ -355,8 +355,7 @@ bool CheckUnusedFunctions::analyseWholeProgram(const CTU::FileInfo *ctu, const s
CheckUnusedFunctions::FunctionDecl::FunctionDecl(const Function *f) CheckUnusedFunctions::FunctionDecl::FunctionDecl(const Function *f)
: functionName(f->name()), lineNumber(f->token->linenr()) : functionName(f->name()), lineNumber(f->token->linenr())
{ {}
}
std::string CheckUnusedFunctions::analyzerInfo() const std::string CheckUnusedFunctions::analyzerInfo() const
{ {

View File

@ -42,13 +42,11 @@ class Tokenizer;
class CPPCHECKLIB CheckUnusedFunctions : public Check { class CPPCHECKLIB CheckUnusedFunctions : public Check {
public: public:
/** @brief This constructor is used when registering the CheckUnusedFunctions */ /** @brief This constructor is used when registering the CheckUnusedFunctions */
CheckUnusedFunctions() : Check(myName()) { CheckUnusedFunctions() : Check(myName()) {}
}
/** @brief This constructor is used when running checks. */ /** @brief This constructor is used when running checks. */
CheckUnusedFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) CheckUnusedFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {}
}
static void clear() { static void clear() {
instance.mFunctions.clear(); instance.mFunctions.clear();
@ -101,8 +99,7 @@ private:
class CPPCHECKLIB FunctionUsage { class CPPCHECKLIB FunctionUsage {
public: public:
FunctionUsage() : lineNumber(0), usedSameFile(false), usedOtherFile(false) { FunctionUsage() : lineNumber(0), usedSameFile(false), usedOtherFile(false) {}
}
std::string filename; std::string filename;
unsigned int lineNumber; unsigned int lineNumber;

Some files were not shown because too many files have changed in this diff Show More