Merge branch 'master' of git@github.com:danmar/cppcheck
This commit is contained in:
commit
de0bea3479
|
@ -8,6 +8,8 @@ tools/errmsg
|
|||
*.ncb
|
||||
*.suo
|
||||
*.user
|
||||
*.idb
|
||||
*.pdb
|
||||
# VS build folders
|
||||
Build/
|
||||
BuildTmp/
|
||||
|
@ -17,6 +19,9 @@ gui/release/
|
|||
gui/temp/
|
||||
# Other (generated) GUI files
|
||||
gui/Makefile
|
||||
gui/Makefile.debug
|
||||
gui/Makefile.release
|
||||
gui/gui.sln
|
||||
gui/gui.vcproj
|
||||
gui/gui
|
||||
gui/qrc_gui.cpp
|
||||
|
||||
|
|
36
Makefile
36
Makefile
|
@ -9,12 +9,12 @@ OBJECTS = src/checkautovariables.o \
|
|||
src/checkbufferoverrun.o \
|
||||
src/checkclass.o \
|
||||
src/checkdangerousfunctions.o \
|
||||
src/checkfunctionusage.o \
|
||||
src/checkheaders.o \
|
||||
src/checkmemoryleak.o \
|
||||
src/checkother.o \
|
||||
src/checksecurity.o \
|
||||
src/checkstl.o \
|
||||
src/checkunusedfunctions.o \
|
||||
src/cppcheck.o \
|
||||
src/cppcheckexecutor.o \
|
||||
src/errorlogger.o \
|
||||
|
@ -36,11 +36,9 @@ TESTOBJ = test/testautovariables.o \
|
|||
test/testdangerousfunctions.o \
|
||||
test/testdivision.o \
|
||||
test/testfilelister.o \
|
||||
test/testfunctionusage.o \
|
||||
test/testincompletestatement.o \
|
||||
test/testmathlib.o \
|
||||
test/testmemleak.o \
|
||||
test/testmemleakmp.o \
|
||||
test/testother.o \
|
||||
test/testpreprocessor.o \
|
||||
test/testredundantif.o \
|
||||
|
@ -51,18 +49,19 @@ TESTOBJ = test/testautovariables.o \
|
|||
test/testsuite.o \
|
||||
test/testtoken.o \
|
||||
test/testtokenize.o \
|
||||
test/testunusedfunctions.o \
|
||||
test/testunusedprivfunc.o \
|
||||
test/testunusedvar.o \
|
||||
src/checkautovariables.o \
|
||||
src/checkbufferoverrun.o \
|
||||
src/checkclass.o \
|
||||
src/checkdangerousfunctions.o \
|
||||
src/checkfunctionusage.o \
|
||||
src/checkheaders.o \
|
||||
src/checkmemoryleak.o \
|
||||
src/checkother.o \
|
||||
src/checksecurity.o \
|
||||
src/checkstl.o \
|
||||
src/checkunusedfunctions.o \
|
||||
src/cppcheck.o \
|
||||
src/cppcheckexecutor.o \
|
||||
src/errorlogger.o \
|
||||
|
@ -118,16 +117,13 @@ src/checkclass.o: src/checkclass.cpp src/checkclass.h src/check.h src/tokenize.h
|
|||
src/checkdangerousfunctions.o: src/checkdangerousfunctions.cpp src/checkdangerousfunctions.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/checkdangerousfunctions.o src/checkdangerousfunctions.cpp
|
||||
|
||||
src/checkfunctionusage.o: src/checkfunctionusage.cpp src/checkfunctionusage.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/checkfunctionusage.o src/checkfunctionusage.cpp
|
||||
|
||||
src/checkheaders.o: src/checkheaders.cpp src/checkheaders.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/filelister.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/checkheaders.o src/checkheaders.cpp
|
||||
|
||||
src/checkmemoryleak.o: src/checkmemoryleak.cpp src/checkmemoryleak.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
|
||||
src/checkmemoryleak.o: src/checkmemoryleak.cpp src/checkmemoryleak.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/mathlib.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/checkmemoryleak.o src/checkmemoryleak.cpp
|
||||
|
||||
src/checkother.o: src/checkother.cpp src/checkother.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
|
||||
src/checkother.o: src/checkother.cpp src/checkother.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/mathlib.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/checkother.o src/checkother.cpp
|
||||
|
||||
src/checksecurity.o: src/checksecurity.cpp src/checksecurity.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
|
||||
|
@ -136,10 +132,13 @@ src/checksecurity.o: src/checksecurity.cpp src/checksecurity.h src/check.h src/t
|
|||
src/checkstl.o: src/checkstl.cpp src/checkstl.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/checkstl.o src/checkstl.cpp
|
||||
|
||||
src/cppcheck.o: src/cppcheck.cpp src/cppcheck.h src/settings.h src/errorlogger.h src/checkfunctionusage.h src/tokenize.h src/token.h src/preprocessor.h src/filelister.h src/check.h
|
||||
src/checkunusedfunctions.o: src/checkunusedfunctions.cpp src/checkunusedfunctions.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/checkunusedfunctions.o src/checkunusedfunctions.cpp
|
||||
|
||||
src/cppcheck.o: src/cppcheck.cpp src/cppcheck.h src/settings.h src/errorlogger.h src/checkunusedfunctions.h src/tokenize.h src/token.h src/preprocessor.h src/filelister.h src/check.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/cppcheck.o src/cppcheck.cpp
|
||||
|
||||
src/cppcheckexecutor.o: src/cppcheckexecutor.cpp src/cppcheckexecutor.h src/errorlogger.h src/settings.h src/cppcheck.h src/checkfunctionusage.h src/tokenize.h src/token.h src/threadexecutor.h
|
||||
src/cppcheckexecutor.o: src/cppcheckexecutor.cpp src/cppcheckexecutor.h src/errorlogger.h src/settings.h src/cppcheck.h src/checkunusedfunctions.h src/tokenize.h src/token.h src/threadexecutor.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/cppcheckexecutor.o src/cppcheckexecutor.cpp
|
||||
|
||||
src/errorlogger.o: src/errorlogger.cpp src/errorlogger.h src/settings.h src/tokenize.h src/token.h
|
||||
|
@ -154,13 +153,13 @@ src/main.o: src/main.cpp src/cppcheckexecutor.h src/errorlogger.h src/settings.h
|
|||
src/mathlib.o: src/mathlib.cpp src/mathlib.h src/token.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/mathlib.o src/mathlib.cpp
|
||||
|
||||
src/preprocessor.o: src/preprocessor.cpp src/preprocessor.h src/errorlogger.h src/settings.h src/tokenize.h src/token.h
|
||||
src/preprocessor.o: src/preprocessor.cpp src/preprocessor.h src/errorlogger.h src/settings.h src/tokenize.h src/token.h src/filelister.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/preprocessor.o src/preprocessor.cpp
|
||||
|
||||
src/settings.o: src/settings.cpp src/settings.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/settings.o src/settings.cpp
|
||||
|
||||
src/threadexecutor.o: src/threadexecutor.cpp src/threadexecutor.h src/settings.h src/errorlogger.h src/cppcheck.h src/checkfunctionusage.h src/tokenize.h src/token.h
|
||||
src/threadexecutor.o: src/threadexecutor.cpp src/threadexecutor.h src/settings.h src/errorlogger.h src/cppcheck.h src/checkunusedfunctions.h src/tokenize.h src/token.h
|
||||
$(CXX) $(CXXFLAGS) -c -o src/threadexecutor.o src/threadexecutor.cpp
|
||||
|
||||
src/token.o: src/token.cpp src/token.h
|
||||
|
@ -184,7 +183,7 @@ test/testclass.o: test/testclass.cpp src/tokenize.h src/settings.h src/errorlogg
|
|||
test/testconstructors.o: test/testconstructors.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/checkclass.h src/check.h test/testsuite.h
|
||||
$(CXX) $(CXXFLAGS) -c -o test/testconstructors.o test/testconstructors.cpp
|
||||
|
||||
test/testcppcheck.o: test/testcppcheck.cpp test/testsuite.h src/errorlogger.h src/settings.h src/cppcheck.h src/checkfunctionusage.h src/tokenize.h src/token.h
|
||||
test/testcppcheck.o: test/testcppcheck.cpp test/testsuite.h src/errorlogger.h src/settings.h src/cppcheck.h src/checkunusedfunctions.h src/tokenize.h src/token.h
|
||||
$(CXX) $(CXXFLAGS) -c -o test/testcppcheck.o test/testcppcheck.cpp
|
||||
|
||||
test/testdangerousfunctions.o: test/testdangerousfunctions.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/checkdangerousfunctions.h src/check.h test/testsuite.h
|
||||
|
@ -196,9 +195,6 @@ test/testdivision.o: test/testdivision.cpp src/tokenize.h src/settings.h src/err
|
|||
test/testfilelister.o: test/testfilelister.cpp test/testsuite.h src/errorlogger.h src/settings.h src/filelister.h
|
||||
$(CXX) $(CXXFLAGS) -c -o test/testfilelister.o test/testfilelister.cpp
|
||||
|
||||
test/testfunctionusage.o: test/testfunctionusage.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h test/testsuite.h src/checkfunctionusage.h
|
||||
$(CXX) $(CXXFLAGS) -c -o test/testfunctionusage.o test/testfunctionusage.cpp
|
||||
|
||||
test/testincompletestatement.o: test/testincompletestatement.cpp test/testsuite.h src/errorlogger.h src/settings.h src/tokenize.h src/token.h src/checkother.h src/check.h
|
||||
$(CXX) $(CXXFLAGS) -c -o test/testincompletestatement.o test/testincompletestatement.cpp
|
||||
|
||||
|
@ -208,9 +204,6 @@ test/testmathlib.o: test/testmathlib.cpp src/mathlib.h src/token.h test/testsuit
|
|||
test/testmemleak.o: test/testmemleak.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/checkmemoryleak.h src/check.h test/testsuite.h
|
||||
$(CXX) $(CXXFLAGS) -c -o test/testmemleak.o test/testmemleak.cpp
|
||||
|
||||
test/testmemleakmp.o: test/testmemleakmp.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/checkmemoryleak.h src/check.h test/testsuite.h
|
||||
$(CXX) $(CXXFLAGS) -c -o test/testmemleakmp.o test/testmemleakmp.cpp
|
||||
|
||||
test/testother.o: test/testother.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/checkother.h src/check.h test/testsuite.h
|
||||
$(CXX) $(CXXFLAGS) -c -o test/testother.o test/testother.cpp
|
||||
|
||||
|
@ -241,6 +234,9 @@ test/testtoken.o: test/testtoken.cpp test/testsuite.h src/errorlogger.h src/sett
|
|||
test/testtokenize.o: test/testtokenize.cpp test/testsuite.h src/errorlogger.h src/settings.h src/tokenize.h src/token.h
|
||||
$(CXX) $(CXXFLAGS) -c -o test/testtokenize.o test/testtokenize.cpp
|
||||
|
||||
test/testunusedfunctions.o: test/testunusedfunctions.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h test/testsuite.h src/checkunusedfunctions.h
|
||||
$(CXX) $(CXXFLAGS) -c -o test/testunusedfunctions.o test/testunusedfunctions.cpp
|
||||
|
||||
test/testunusedprivfunc.o: test/testunusedprivfunc.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/checkclass.h src/check.h test/testsuite.h
|
||||
$(CXX) $(CXXFLAGS) -c -o test/testunusedprivfunc.o test/testunusedprivfunc.cpp
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
<Add option="-Wall" />
|
||||
<Add option="-fexceptions" />
|
||||
</Compiler>
|
||||
<Unit filename="gui/aboutdialog.cpp" />
|
||||
<Unit filename="gui/aboutdialog.h" />
|
||||
<Unit filename="gui/applicationdialog.cpp" />
|
||||
<Unit filename="gui/applicationdialog.h" />
|
||||
<Unit filename="gui/applicationlist.cpp" />
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="shlwapi.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
|
@ -127,6 +128,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="shlwapi.lib"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="1"
|
||||
|
@ -185,10 +187,6 @@
|
|||
RelativePath=".\src\checkdangerousfunctions.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\checkfunctionusage.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\checkheaders.h"
|
||||
>
|
||||
|
@ -209,6 +207,10 @@
|
|||
RelativePath=".\src\checkstl.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\checkunusedfunctions.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\cppcheck.h"
|
||||
>
|
||||
|
@ -289,10 +291,6 @@
|
|||
RelativePath=".\src\checkdangerousfunctions.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\checkfunctionusage.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\checkheaders.cpp"
|
||||
>
|
||||
|
@ -313,6 +311,10 @@
|
|||
RelativePath=".\src\checkstl.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\checkunusedfunctions.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\cppcheck.cpp"
|
||||
>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# Archive files are created in user's home directory.
|
||||
|
||||
# Tag to use
|
||||
tag=1.32
|
||||
tag=1.33
|
||||
|
||||
# Name of release
|
||||
releasename=cppcheck-$tag
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Cppcheck - A tool for static C/C++ code analysis
|
||||
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
|
||||
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
|
||||
*
|
||||
* 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
|
||||
|
@ -28,20 +28,20 @@ AboutDialog::AboutDialog(const QString &version, QWidget *parent)
|
|||
{
|
||||
setWindowTitle(tr("About cppcheck"));
|
||||
// Left icon area and right text area
|
||||
QHBoxLayout *iconLayout = new QHBoxLayout(this);
|
||||
QHBoxLayout *iconLayout = new QHBoxLayout();
|
||||
// Keep icon at the top of the dialog
|
||||
QVBoxLayout *iconVLayout = new QVBoxLayout(this);
|
||||
QVBoxLayout *iconVLayout = new QVBoxLayout();
|
||||
// Texts
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
// Keep close button in right
|
||||
QHBoxLayout *btnLayout = new QHBoxLayout(this);
|
||||
QHBoxLayout *btnLayout = new QHBoxLayout();
|
||||
|
||||
QIcon *icon = new QIcon(":icon.png");
|
||||
QLabel *iconLabel = new QLabel();
|
||||
iconLabel->setPixmap(icon->pixmap(QSize(48, 48)));
|
||||
QLabel *name = new QLabel(tr("Cppcheck - A tool for static C/C++ code analysis."));
|
||||
QLabel *ver = new QLabel(QString(tr("Version %1")).arg(mVersion));
|
||||
QLabel *copy = new QLabel(("Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team."));
|
||||
QLabel *copy = new QLabel(("Copyright (C) 2007-2009 Daniel Marjamäki and cppcheck team."));
|
||||
copy->setWordWrap(true);
|
||||
QLabel *gpl = new QLabel(tr("This program is licensed under the terms " \
|
||||
"of the GNU General Public License version 3"));
|
||||
|
@ -63,6 +63,7 @@ AboutDialog::AboutDialog(const QString &version, QWidget *parent)
|
|||
|
||||
btnLayout->addStretch();
|
||||
btnLayout->addWidget(quit);
|
||||
setLayout(iconLayout);
|
||||
|
||||
connect(quit, SIGNAL(clicked()), this, SLOT(close()));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Cppcheck - A tool for static C/C++ code analysis
|
||||
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
|
||||
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -28,11 +28,14 @@
|
|||
|
||||
ApplicationDialog::ApplicationDialog(const QString &name,
|
||||
const QString &path,
|
||||
const QString &title)
|
||||
const QString &title,
|
||||
QWidget *parent) :
|
||||
QDialog(parent)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
mName = new QLineEdit(name);
|
||||
mPath = new QLineEdit(path);
|
||||
mName->setMaxLength(100); // Should be plenty for app name
|
||||
mPath = new QLineEdit(QDir::toNativeSeparators(path));
|
||||
|
||||
QString guide = tr("Here you can add applications that can open error files.\n" \
|
||||
"Specify a name for the application and the application to execute.\n\n" \
|
||||
|
@ -79,7 +82,6 @@ ApplicationDialog::~ApplicationDialog()
|
|||
//dtor
|
||||
}
|
||||
|
||||
|
||||
void ApplicationDialog::Browse()
|
||||
{
|
||||
QFileDialog dialog(this);
|
||||
|
@ -90,7 +92,18 @@ void ApplicationDialog::Browse()
|
|||
QStringList list = dialog.selectedFiles();
|
||||
if (list.size() > 0)
|
||||
{
|
||||
mPath->setText(list[0]);
|
||||
QString path(QDir::toNativeSeparators(list[0]));
|
||||
|
||||
// In Windows we must surround paths including spaces with quotation marks.
|
||||
#ifdef Q_WS_WIN
|
||||
if (path.indexOf(" ") > -1)
|
||||
{
|
||||
path.insert(0, "\"");
|
||||
path.append("\"");
|
||||
}
|
||||
#endif // Q_WS_WIN
|
||||
|
||||
mPath->setText(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +129,8 @@ void ApplicationDialog::Ok()
|
|||
}
|
||||
else
|
||||
{
|
||||
// Convert possible native (Windows) path to internal presentation format
|
||||
mPath->setText(QDir::fromNativeSeparators(mPath->text()));
|
||||
accept();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,10 +38,12 @@ public:
|
|||
* @param name Default name for the application to start
|
||||
* @param path Path for the application
|
||||
* @param title Title for the dialog
|
||||
* @param parent Parent widget
|
||||
*/
|
||||
ApplicationDialog(const QString &name,
|
||||
const QString &path,
|
||||
const QString &title);
|
||||
const QString &title,
|
||||
QWidget *parent = 0);
|
||||
virtual ~ApplicationDialog();
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,9 +36,9 @@ HEADERS += mainwindow.h \
|
|||
../src/settings.h \
|
||||
../src/tokenize.h \
|
||||
../src/checkbufferoverrun.h \
|
||||
../src/checkfunctionusage.h \
|
||||
../src/checkmemoryleak.h \
|
||||
../src/checkstl.h \
|
||||
../src/checkunusedfunctions.h \
|
||||
../src/errorlogger.h \
|
||||
../src/preprocessor.h \
|
||||
../src/threadexecutor.h \
|
||||
|
@ -70,7 +70,6 @@ SOURCES += main.cpp \
|
|||
../src/mathlib.cpp \
|
||||
../src/threadexecutor.cpp \
|
||||
../src/checkbufferoverrun.cpp \
|
||||
../src/checkfunctionusage.cpp \
|
||||
../src/checkother.cpp \
|
||||
../src/cppcheck.cpp \
|
||||
../src/filelister.cpp \
|
||||
|
@ -80,5 +79,6 @@ SOURCES += main.cpp \
|
|||
../src/checkheaders.cpp \
|
||||
../src/checksecurity.cpp \
|
||||
../src/cppcheckexecutor.cpp \
|
||||
../src/checkunusedfunctions.cpp \
|
||||
../src/settings.cpp \
|
||||
../src/tokenize.cpp
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QTextCodec>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -25,6 +26,10 @@ int main(int argc, char *argv[])
|
|||
QApplication app(argc, argv);
|
||||
app.setWindowIcon(QIcon(":icon.png"));
|
||||
|
||||
// Set codecs so that UTF-8 strings in sources are handled correctly.
|
||||
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
|
||||
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
MainWindow window;
|
||||
window.show();
|
||||
return app.exec();
|
||||
|
|
|
@ -300,7 +300,7 @@ void MainWindow::CheckDone()
|
|||
|
||||
void MainWindow::ProgramSettings()
|
||||
{
|
||||
SettingsDialog dialog(mSettings, mApplications);
|
||||
SettingsDialog dialog(mSettings, mApplications, this);
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
dialog.SaveCheckboxValues();
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
cppcheck GUI
|
||||
============
|
||||
This is a GUI for cppcheck. It allows selecting folder or set of files to check
|
||||
with cppcheck and shows list of found errors.
|
||||
|
||||
Running
|
||||
-------
|
||||
You need QT4 libraries installed in your system. Packages/files to install
|
||||
depends on your operating system:
|
||||
- Windows download QT4 from http://www.qtsoftware.com
|
||||
- Linux install QT4 using your package manager, look for packages having QT4
|
||||
in their name, e.g. for Ubuntu install libqt4-core and libqt4-gui
|
||||
|
||||
Compiling
|
||||
---------
|
||||
Windows:
|
||||
- The easy way is to download Qt SDK from http://www.qtsoftware.com and use
|
||||
Qt Creator and/or command line tools to build the GUI.
|
||||
- The harder way is to download QT sources and build QT with Visual Studio
|
||||
(Express Edition works). Compiling QT alone may take over 4 hours!
|
||||
|
||||
Linux:
|
||||
- Install QT development packages (make sure qmake -tool gets installed!). The
|
||||
names depend on distribution, but e.g. for Ubuntu the needed packages are:
|
||||
* libqt4-core
|
||||
* libqt4-gui
|
||||
* libqt4-dev
|
||||
* qt4-dev-tools
|
||||
* qt4-qmake
|
||||
|
||||
After you have needed libraries and tools installed, open command
|
||||
prompt/console, go to gui directory and run command:
|
||||
- qmake (in Linux and in Windows if build with MinGW/gcc)
|
||||
- qmake -tp vc (In Windows if build with Visual Studio)
|
||||
|
||||
These commands generate makefiles to actually build the software. After that
|
||||
the actual building is done in IDE or command line as usual. Note that you
|
||||
don't need to run qmake again unless you add/remove files from the project.
|
|
@ -36,10 +36,10 @@ ResultsTree::ResultsTree(QSettings &settings, ApplicationList &list) :
|
|||
labels << tr("File") << tr("Severity") << tr("Line") << tr("Message");
|
||||
mModel.setHorizontalHeaderLabels(labels);
|
||||
setExpandsOnDoubleClick(false);
|
||||
setSortingEnabled(true);
|
||||
LoadSettings();
|
||||
connect(this, SIGNAL(doubleClicked(const QModelIndex &)),
|
||||
this, SLOT(QuickStartApplication(const QModelIndex &)));
|
||||
|
||||
}
|
||||
|
||||
ResultsTree::~ResultsTree()
|
||||
|
@ -47,8 +47,6 @@ ResultsTree::~ResultsTree()
|
|||
SaveSettings();
|
||||
}
|
||||
|
||||
|
||||
|
||||
QStandardItem *ResultsTree::CreateItem(const QString &name)
|
||||
{
|
||||
QStandardItem *item = new QStandardItem(name);
|
||||
|
@ -56,7 +54,6 @@ QStandardItem *ResultsTree::CreateItem(const QString &name)
|
|||
return item;
|
||||
}
|
||||
|
||||
|
||||
void ResultsTree::AddErrorItem(const QString &file,
|
||||
const QString &severity,
|
||||
const QString &message,
|
||||
|
@ -66,7 +63,6 @@ void ResultsTree::AddErrorItem(const QString &file,
|
|||
{
|
||||
Q_UNUSED(file);
|
||||
|
||||
|
||||
if (files.isEmpty())
|
||||
{
|
||||
return;
|
||||
|
@ -100,7 +96,6 @@ void ResultsTree::AddErrorItem(const QString &file,
|
|||
data["id"] = id;
|
||||
item->setData(QVariant(data));
|
||||
|
||||
|
||||
//Add backtrace files as children
|
||||
for (int i = 1;i < files.size() && i < lines.size();i++)
|
||||
{
|
||||
|
@ -141,14 +136,12 @@ QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent,
|
|||
list << CreateItem(QString("%1").arg(line));
|
||||
list << CreateItem(message);
|
||||
|
||||
|
||||
QModelIndex index = QModelIndex();
|
||||
|
||||
parent->appendRow(list);
|
||||
|
||||
setRowHidden(parent->rowCount() - 1, parent->index(), hide);
|
||||
|
||||
|
||||
if (!icon.isEmpty())
|
||||
{
|
||||
list[0]->setIcon(QIcon(icon));
|
||||
|
@ -417,7 +410,19 @@ void ResultsTree::StartApplication(QStandardItem *target, int application)
|
|||
program.replace("(message)", data["message"].toString(), Qt::CaseInsensitive);
|
||||
program.replace("(severity)", data["severity"].toString(), Qt::CaseInsensitive);
|
||||
|
||||
QProcess::startDetached(program);
|
||||
bool success = QProcess::startDetached(program);
|
||||
if (!success)
|
||||
{
|
||||
QString app = mApplications.GetApplicationName(application);
|
||||
QString text = tr("Could not start ") + app + "\n\n";
|
||||
text += tr("Please check the application path and parameters are correct.");
|
||||
|
||||
QMessageBox msgbox(this);
|
||||
msgbox.setWindowTitle("Cppcheck");
|
||||
msgbox.setText(text);
|
||||
msgbox.setIcon(QMessageBox::Critical);
|
||||
msgbox.exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -544,7 +549,6 @@ void ResultsTree::SaveErrors(QTextStream &out, QStandardItem *item, bool xml)
|
|||
}
|
||||
|
||||
out << line << endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -623,7 +627,6 @@ void ResultsTree::RefreshFilePaths(QStandardItem *item)
|
|||
//Loop through all errors within this file
|
||||
for (int i = 0;i < item->rowCount();i++)
|
||||
{
|
||||
|
||||
//Get error i
|
||||
QStandardItem *error = item->child(i, 0);
|
||||
|
||||
|
@ -632,7 +635,6 @@ void ResultsTree::RefreshFilePaths(QStandardItem *item)
|
|||
continue;
|
||||
}
|
||||
|
||||
|
||||
//Get error's user data
|
||||
QVariant userdata = error->data();
|
||||
//Convert it to QVariantMap
|
||||
|
@ -650,7 +652,6 @@ void ResultsTree::RefreshFilePaths(QStandardItem *item)
|
|||
//Update this error's text
|
||||
error->setText(StripPath(files[0], false));
|
||||
|
||||
|
||||
//If this error has backtraces make sure the files list has enough filenames
|
||||
if (error->rowCount() <= files.size() - 1)
|
||||
{
|
||||
|
@ -678,7 +679,6 @@ void ResultsTree::RefreshFilePaths(QStandardItem *item)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void ResultsTree::RefreshFilePaths()
|
||||
{
|
||||
qDebug("Refreshing file paths");
|
||||
|
@ -688,6 +688,4 @@ void ResultsTree::RefreshFilePaths()
|
|||
{
|
||||
RefreshFilePaths(mModel.item(i, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,12 +18,16 @@
|
|||
|
||||
|
||||
#include "settingsdialog.h"
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QDebug>
|
||||
#include <QTabWidget>
|
||||
#include "applicationdialog.h"
|
||||
|
||||
SettingsDialog::SettingsDialog(QSettings &programSettings, ApplicationList &list) :
|
||||
SettingsDialog::SettingsDialog(QSettings &programSettings, ApplicationList &list,
|
||||
QWidget *parent) :
|
||||
QDialog(parent),
|
||||
mSettings(programSettings),
|
||||
mApplications(list)
|
||||
{
|
||||
|
@ -210,7 +214,7 @@ void SettingsDialog::SaveCheckboxValue(QCheckBox *box, const QString &name)
|
|||
|
||||
void SettingsDialog::AddApplication()
|
||||
{
|
||||
ApplicationDialog dialog("", "", tr("Add a new application"));
|
||||
ApplicationDialog dialog("", "", tr("Add a new application"), this);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
|
@ -267,10 +271,16 @@ void SettingsDialog::DefaultApplication()
|
|||
|
||||
void SettingsDialog::PopulateListWidget()
|
||||
{
|
||||
for (int i = 0;i < mTempApplications.GetApplicationCount();i++)
|
||||
for (int i = 0; i < mTempApplications.GetApplicationCount(); i++)
|
||||
{
|
||||
mListWidget->addItem(mTempApplications.GetApplicationName(i));
|
||||
}
|
||||
|
||||
// If list contains items select first item
|
||||
if (mTempApplications.GetApplicationCount())
|
||||
{
|
||||
mListWidget->setCurrentRow(0);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::Ok()
|
||||
|
|
|
@ -41,7 +41,7 @@ class SettingsDialog : public QDialog
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SettingsDialog(QSettings &programSettings, ApplicationList &list);
|
||||
SettingsDialog(QSettings &programSettings, ApplicationList &list, QWidget *parent = 0);
|
||||
virtual ~SettingsDialog();
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "errorlogger.h"
|
||||
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
|
||||
class Check
|
||||
{
|
||||
|
@ -78,6 +79,13 @@ protected:
|
|||
/** report an error */
|
||||
void reportError(const std::list<const Token *> &callstack, const std::string &severity, const std::string &id, const std::string &msg)
|
||||
{
|
||||
// No errorLogger => just report the message to stdout
|
||||
if (_errorLogger == NULL)
|
||||
{
|
||||
std::cout << "(" << severity << ") " << msg << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
|
||||
for (std::list<const Token *>::const_iterator it = callstack.begin(); it != callstack.end(); ++it)
|
||||
{
|
||||
|
|
|
@ -191,17 +191,17 @@ void CheckAutoVariables::autoVariables()
|
|||
continue;
|
||||
addVD(tok->tokAt(2));
|
||||
}
|
||||
else if (bindent > 0 && Token::Match(tok, "%var% = & %var%")) //Critical assignement
|
||||
else if (bindent > 0 && Token::Match(tok, "[;{}] %var% = & %var%")) //Critical assignement
|
||||
{
|
||||
if (errorAv(tok->tokAt(0), tok->tokAt(3)))
|
||||
if (errorAv(tok->tokAt(1), tok->tokAt(4)))
|
||||
reportError(tok,
|
||||
"error",
|
||||
"autoVariables",
|
||||
"Wrong assignement of an auto-variable to an effective parameter of a function");
|
||||
}
|
||||
else if (bindent > 0 && Token::Match(tok, "%var% [ %any% ] = & %var%")) //Critical assignement
|
||||
else if (bindent > 0 && Token::Match(tok, "[;{}] %var% [ %any% ] = & %var%")) //Critical assignement
|
||||
{
|
||||
if (errorAv(tok->tokAt(0), tok->tokAt(6)))
|
||||
if (errorAv(tok->tokAt(1), tok->tokAt(7)))
|
||||
reportError(tok,
|
||||
"error",
|
||||
"autoVariables",
|
||||
|
|
|
@ -56,6 +56,7 @@ private:
|
|||
|
||||
void getErrorMessages()
|
||||
{
|
||||
std::cout << "===auto variables===" << "\n";
|
||||
reportError(0, "error", "autoVariables", "Wrong assignement of an auto-variable to an effective parameter of a function");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
|
||||
void getErrorMessages()
|
||||
{
|
||||
std::cout << "===buffer overruns===" << "\n";
|
||||
arrayIndexOutOfBounds(0);
|
||||
bufferOverrun(0);
|
||||
strncatUsage(0);
|
||||
|
|
|
@ -82,6 +82,10 @@ struct CheckClass::VAR *CheckClass::ClassChecking_GetVarList(const Token *tok1,
|
|||
if (next->str() == "static")
|
||||
continue;
|
||||
|
||||
// Type definitions shall be ignored..
|
||||
if (next->str() == "typedef")
|
||||
continue;
|
||||
|
||||
// Is it a variable declaration?
|
||||
if (Token::Match(next, "%type% %var% ;"))
|
||||
{
|
||||
|
|
|
@ -109,6 +109,7 @@ private:
|
|||
|
||||
void getErrorMessages()
|
||||
{
|
||||
std::cout << "===classes===" << "\n";
|
||||
noConstructorError(0, "classname");
|
||||
uninitVarError(0, "classname", "varname");
|
||||
operatorEqVarError(0, "classname", "");
|
||||
|
|
|
@ -56,6 +56,7 @@ private:
|
|||
|
||||
void getErrorMessages()
|
||||
{
|
||||
std::cout << "===dangerous functions===" << "\n";
|
||||
dangerousFunctionmktemp(0);
|
||||
dangerousFunctiongets(0);
|
||||
dangerousFunctionscanf(0);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,11 +19,17 @@
|
|||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#ifndef CheckMemoryLeakH
|
||||
#define CheckMemoryLeakH
|
||||
#ifndef checkmemoryleakH
|
||||
#define checkmemoryleakH
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/** \brief Check for memory leaks */
|
||||
/**
|
||||
* Check for memory leaks
|
||||
*
|
||||
* The checking is split up into two specialized classes.
|
||||
* CheckMemoryLeakInFunction can detect when a function variable is allocated but not deallocated properly.
|
||||
* CheckMemoryLeakInClass can detect when a class variable is allocated but not deallocated properly.
|
||||
*/
|
||||
|
||||
#include "check.h"
|
||||
|
||||
|
@ -33,62 +39,85 @@
|
|||
|
||||
class Token;
|
||||
|
||||
class CheckMemoryLeakClass : public Check
|
||||
/** Base class for memory leaks checking */
|
||||
|
||||
class CheckMemoryLeak
|
||||
{
|
||||
protected:
|
||||
CheckMemoryLeak() { }
|
||||
|
||||
/** What type of allocation are used.. the "Many" means that several types of allocation and deallocation are used */
|
||||
enum AllocType { No, Malloc, gMalloc, New, NewArray, File, Pipe, Dir, Many };
|
||||
|
||||
void MemoryLeak(const Token *tok, const char varname[], AllocType alloctype, bool all);
|
||||
void MismatchError(const Token *Tok1, const std::list<const Token *> &callstack, const char varname[]);
|
||||
AllocType GetDeallocationType(const Token *tok, const char *varnames[]);
|
||||
AllocType GetAllocationType(const Token *tok2);
|
||||
AllocType GetReallocationType(const Token *tok2);
|
||||
bool isclass(const Tokenizer *_tokenizer, const Token *typestr) const;
|
||||
|
||||
void memleakError(const Token *tok, const std::string &varname);
|
||||
void memleakallError(const Token *tok, const std::string &varname);
|
||||
void resourceLeakError(const Token *tok, const std::string &varname);
|
||||
|
||||
void deallocDeallocError(const Token *tok, const std::string &varname);
|
||||
void deallocuseError(const Token *tok, const std::string &varname);
|
||||
void mismatchSizeError(const Token *tok, const std::string &sz);
|
||||
void mismatchAllocDealloc(const std::list<const Token *> &callstack, const std::string &varname);
|
||||
|
||||
// error message
|
||||
virtual void error(const Token *tok, const std::string &severity, const std::string &id, const std::string &msg) = 0;
|
||||
virtual void error(const std::list<const Token *> &callstack, const std::string &severity, const std::string &id, const std::string &msg) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check function variables.
|
||||
*
|
||||
* The checking is done by looking at each function variable separately. By repeating these 4 steps over and over:
|
||||
* 1. locate a function variable
|
||||
* 2. create a simple token list that describes the usage of the function variable.
|
||||
* 3. simplify the token list.
|
||||
* 4. finally, check if the simplified token list contain any leaks.
|
||||
*/
|
||||
|
||||
class CheckMemoryLeakInFunction : public CheckMemoryLeak, public Check
|
||||
{
|
||||
public:
|
||||
CheckMemoryLeakClass() : Check()
|
||||
CheckMemoryLeakInFunction() : Check()
|
||||
{ }
|
||||
|
||||
CheckMemoryLeakClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||
CheckMemoryLeakInFunction(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||
: Check(tokenizer, settings, errorLogger)
|
||||
{ }
|
||||
|
||||
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||
{
|
||||
CheckMemoryLeakClass checkMemoryLeakClass(tokenizer, settings, errorLogger);
|
||||
checkMemoryLeakClass.CheckMemoryLeak();
|
||||
CheckMemoryLeakInFunction checkMemoryLeak(tokenizer, settings, errorLogger);
|
||||
checkMemoryLeak.check();
|
||||
}
|
||||
|
||||
|
||||
void CheckMemoryLeak();
|
||||
#ifndef UNIT_TESTING
|
||||
private:
|
||||
#endif
|
||||
void check();
|
||||
|
||||
private:
|
||||
|
||||
/** What type of allocation are used.. the "Many" means that several types of allocation and deallocation are used */
|
||||
enum AllocType { No, Malloc, gMalloc, New, NewArray, File, Pipe, Dir, Many };
|
||||
|
||||
// Extra allocation..
|
||||
class AllocFunc
|
||||
{
|
||||
public:
|
||||
const char *funcname;
|
||||
AllocType alloctype;
|
||||
|
||||
AllocFunc(const char f[], AllocType a)
|
||||
: funcname(f), alloctype(a)
|
||||
{ }
|
||||
};
|
||||
|
||||
void CheckMemoryLeak_ClassMembers_Variable(const char classname[], const Token *tokVarname);
|
||||
void CheckMemoryLeak_ClassMembers_ParseClass(const Token *tok1, std::vector<const char *> &classname);
|
||||
void CheckMemoryLeak_ClassMembers();
|
||||
void CheckMemoryLeak_InFunction();
|
||||
void CheckMemoryLeak_CheckScope(const Token *Tok1, const char varname[], bool classmember, unsigned int sz);
|
||||
bool MatchFunctionsThatReturnArg(const Token *tok, const std::string &varname);
|
||||
|
||||
/**
|
||||
* Simplify code e.g. by replacing empty "{ }" with ";"
|
||||
* @param tok first token. The tokens list can be modified.
|
||||
* Check if there is a "!var" match inside a condition
|
||||
* @param tok first token to match
|
||||
* @param varnames the varname
|
||||
* @param endpar if this is true the "!var" must be followed by ")"
|
||||
* @return true if match
|
||||
*/
|
||||
void simplifycode(Token *tok, bool &all);
|
||||
bool notvar(const Token *tok, const char *varnames[], bool endpar = false);
|
||||
|
||||
/**
|
||||
* Delete tokens between begin and end. E.g. if begin = 1
|
||||
* and end = 5, tokens 2,3 and 4 would be erased.
|
||||
*
|
||||
* @param begin Tokens after this will be erased.
|
||||
* @param end Tokens before this will be erased.
|
||||
*/
|
||||
void erase(Token *begin, const Token *end);
|
||||
|
||||
const char * call_func(const Token *tok, std::list<const Token *> callstack, const char *varnames[], AllocType &alloctype, AllocType &dealloctype, bool &all, unsigned int sz);
|
||||
|
||||
/**
|
||||
* Extract a new tokens list that is easier to parse than the "tokens"
|
||||
|
@ -103,52 +132,75 @@ private:
|
|||
Token *getcode(const Token *tok, std::list<const Token *> callstack, const char varname[], AllocType &alloctype, AllocType &dealloctype, bool classmember, bool &all, unsigned int sz);
|
||||
|
||||
/**
|
||||
* Check if there is a "!var" match inside a condition
|
||||
* @param tok first token to match
|
||||
* @param varnames the varname
|
||||
* @param endpar if this is true the "!var" must be followed by ")"
|
||||
* @return true if match
|
||||
* Simplify code e.g. by replacing empty "{ }" with ";"
|
||||
* @param tok first token. The tokens list can be modified.
|
||||
*/
|
||||
bool notvar(const Token *tok, const char *varnames[], bool endpar = false);
|
||||
void simplifycode(Token *tok, bool &all);
|
||||
|
||||
bool MatchFunctionsThatReturnArg(const Token *tok, const std::string &varname);
|
||||
void MemoryLeak(const Token *tok, const char varname[], AllocType alloctype, bool all);
|
||||
void MismatchError(const Token *Tok1, const std::list<const Token *> &callstack, const char varname[]);
|
||||
const char * call_func(const Token *tok, std::list<const Token *> callstack, const char *varnames[], AllocType &alloctype, AllocType &dealloctype, bool &all, unsigned int sz);
|
||||
AllocType GetDeallocationType(const Token *tok, const char *varnames[]);
|
||||
AllocType GetAllocationType(const Token *tok2);
|
||||
AllocType GetReallocationType(const Token *tok2);
|
||||
bool isclass(const Token *typestr);
|
||||
void checkScope(const Token *Tok1, const char varname[], bool classmember, unsigned int sz);
|
||||
|
||||
std::list<AllocFunc> _listAllocFunc;
|
||||
|
||||
void memleakError(const Token *tok, const std::string &varname);
|
||||
void memleakallError(const Token *tok, const std::string &varname);
|
||||
void resourceLeakError(const Token *tok, const std::string &varname);
|
||||
void deallocDeallocError(const Token *tok, const std::string &varname);
|
||||
void deallocuseError(const Token *tok, const std::string &varname);
|
||||
void mismatchSizeError(const Token *tok, const std::string &sz);
|
||||
void mismatchAllocDealloc(const std::list<const Token *> &callstack, const std::string &varname);
|
||||
|
||||
|
||||
void getErrorMessages()
|
||||
void error(const Token *tok, const std::string &severity, const std::string &id, const std::string &msg)
|
||||
{
|
||||
memleakError(0, "varname");
|
||||
memleakallError(0, "varname");
|
||||
resourceLeakError(0, "varname");
|
||||
deallocDeallocError(0, "varname");
|
||||
deallocuseError(0, "varname");
|
||||
mismatchSizeError(0, "sz");
|
||||
|
||||
std::list<const Token *> callstack;
|
||||
mismatchAllocDealloc(callstack, "varname");
|
||||
reportError(tok, severity, id, msg);
|
||||
}
|
||||
|
||||
void error(const std::list<const Token *> &callstack, const std::string &severity, const std::string &id, const std::string &msg)
|
||||
{
|
||||
reportError(callstack, severity, id, msg);
|
||||
}
|
||||
|
||||
void getErrorMessages()
|
||||
{ }
|
||||
|
||||
// Experimental functionality..
|
||||
protected:
|
||||
Token *functionParameterCode(const Token *ftok, int parameter);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check class variables
|
||||
* variables that are allocated in the constructor should be deallocated in the destructor
|
||||
*/
|
||||
|
||||
class CheckMemoryLeakInClass : public CheckMemoryLeak, public Check
|
||||
{
|
||||
public:
|
||||
CheckMemoryLeakInClass() : Check()
|
||||
{ }
|
||||
|
||||
CheckMemoryLeakInClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||
: Check(tokenizer, settings, errorLogger)
|
||||
{ }
|
||||
|
||||
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||
{
|
||||
CheckMemoryLeakInClass checkMemoryLeak(tokenizer, settings, errorLogger);
|
||||
checkMemoryLeak.check();
|
||||
}
|
||||
|
||||
#ifndef UNIT_TESTING
|
||||
private:
|
||||
#endif
|
||||
void check();
|
||||
|
||||
private:
|
||||
void parseClass(const Token *tok1, std::vector<const char *> &classname);
|
||||
void variable(const char classname[], const Token *tokVarname);
|
||||
|
||||
void error(const Token *tok, const std::string &severity, const std::string &id, const std::string &msg)
|
||||
{
|
||||
reportError(tok, severity, id, msg);
|
||||
}
|
||||
|
||||
void error(const std::list<const Token *> &callstack, const std::string &severity, const std::string &id, const std::string &msg)
|
||||
{
|
||||
reportError(callstack, severity, id, msg);
|
||||
}
|
||||
|
||||
void getErrorMessages()
|
||||
{ }
|
||||
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
|
|
|
@ -147,6 +147,7 @@ private:
|
|||
|
||||
void getErrorMessages()
|
||||
{
|
||||
std::cout << "===other===" << "\n";
|
||||
cstyleCastError(0);
|
||||
redundantIfDelete0Error(0);
|
||||
redundantIfRemoveError(0);
|
||||
|
|
|
@ -54,6 +54,7 @@ private:
|
|||
|
||||
void getErrorMessages()
|
||||
{
|
||||
std::cout << "===security===" << "\n";
|
||||
unvalidatedInput(0);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -98,6 +98,7 @@ private:
|
|||
|
||||
void getErrorMessages()
|
||||
{
|
||||
std::cout << "===stl===" << "\n";
|
||||
iteratorsError(0, "container1", "container2");
|
||||
dereferenceErasedError(0, "iter");
|
||||
stlOutOfBoundsError(0, "i", "foo");
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#include "checkfunctionusage.h"
|
||||
#include "checkunusedfunctions.h"
|
||||
#include "tokenize.h"
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
@ -29,22 +29,22 @@
|
|||
// FUNCTION USAGE - Check for unused functions etc
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
CheckFunctionUsage::CheckFunctionUsage(ErrorLogger *errorLogger)
|
||||
CheckUnusedFunctions::CheckUnusedFunctions(ErrorLogger *errorLogger)
|
||||
{
|
||||
_errorLogger = errorLogger;
|
||||
}
|
||||
|
||||
CheckFunctionUsage::~CheckFunctionUsage()
|
||||
CheckUnusedFunctions::~CheckUnusedFunctions()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CheckFunctionUsage::setErrorLogger(ErrorLogger *errorLogger)
|
||||
void CheckUnusedFunctions::setErrorLogger(ErrorLogger *errorLogger)
|
||||
{
|
||||
_errorLogger = errorLogger;
|
||||
}
|
||||
|
||||
void CheckFunctionUsage::parseTokens(const Tokenizer &tokenizer)
|
||||
void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer)
|
||||
{
|
||||
// Function declarations..
|
||||
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
|
||||
|
@ -99,17 +99,18 @@ void CheckFunctionUsage::parseTokens(const Tokenizer &tokenizer)
|
|||
|
||||
if (Token::Match(tok->next(), "%var% ("))
|
||||
{
|
||||
if (tok->str() == "*" || (tok->isName() && !Token::Match(tok, "else|return")))
|
||||
continue;
|
||||
funcname = tok->next();
|
||||
}
|
||||
|
||||
if (Token::Match(tok, "[;{}.,()[=+-/&|!?:] %var% [(),;:}]"))
|
||||
else if (Token::Match(tok, "[;{}.,()[=+-/&|!?:] %var% [(),;:}]"))
|
||||
funcname = tok->next();
|
||||
|
||||
if (Token::Match(tok, "[(,] & %var% :: %var% [,)]"))
|
||||
else if (Token::Match(tok, "[(,] & %var% :: %var% [,)]"))
|
||||
funcname = tok->tokAt(4);
|
||||
|
||||
else
|
||||
continue;
|
||||
|
||||
// funcname ( => Assert that the end paranthesis isn't followed by {
|
||||
if (Token::Match(funcname, "%var% ("))
|
||||
{
|
||||
|
@ -146,7 +147,7 @@ void CheckFunctionUsage::parseTokens(const Tokenizer &tokenizer)
|
|||
|
||||
|
||||
|
||||
void CheckFunctionUsage::check()
|
||||
void CheckUnusedFunctions::check()
|
||||
{
|
||||
for (std::map<std::string, FunctionUsage>::const_iterator it = _functions.begin(); it != _functions.end(); ++it)
|
||||
{
|
|
@ -18,18 +18,18 @@
|
|||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#ifndef CheckFunctionUsageH
|
||||
#define CheckFunctionUsageH
|
||||
#ifndef checkunusedfunctionsH
|
||||
#define checkunusedfunctionsH
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "tokenize.h"
|
||||
#include "errorlogger.h"
|
||||
|
||||
class CheckFunctionUsage
|
||||
class CheckUnusedFunctions
|
||||
{
|
||||
public:
|
||||
CheckFunctionUsage(ErrorLogger *errorLogger = 0);
|
||||
~CheckFunctionUsage();
|
||||
CheckUnusedFunctions(ErrorLogger *errorLogger = 0);
|
||||
~CheckUnusedFunctions();
|
||||
|
||||
/**
|
||||
* Errors found by this class are forwarded to the given
|
|
@ -20,7 +20,6 @@
|
|||
#include "preprocessor.h" // preprocessor.
|
||||
#include "tokenize.h" // <- Tokenizer
|
||||
|
||||
#include "checkfunctionusage.h"
|
||||
#include "filelister.h"
|
||||
|
||||
#include "check.h"
|
||||
|
@ -74,7 +73,7 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
|
|||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "--version") == 0)
|
||||
return "Cppcheck 1.32\n";
|
||||
return "Cppcheck 1.33\n";
|
||||
|
||||
// Flag used for various purposes during debugging
|
||||
if (strcmp(argv[i], "--debug") == 0)
|
||||
|
@ -207,6 +206,16 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
|
|||
_settings.autoDealloc(f);
|
||||
}
|
||||
|
||||
// print all possible error messages..
|
||||
else if (strcmp(argv[i], "--errorlist") == 0)
|
||||
{
|
||||
// call all "getErrorMessages" in all registered Check classes
|
||||
for (std::list<Check *>::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it)
|
||||
{
|
||||
(*it)->getErrorMessages();
|
||||
}
|
||||
}
|
||||
|
||||
else if (strncmp(argv[i], "-", 1) == 0 || strncmp(argv[i], "--", 2) == 0)
|
||||
{
|
||||
return "cppcheck: error: unrecognized command line option \"" + std::string(argv[i]) + "\"\n";
|
||||
|
@ -287,7 +296,7 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
unsigned int CppCheck::check()
|
||||
{
|
||||
_checkFunctionUsage.setErrorLogger(this);
|
||||
_checkUnusedFunctions.setErrorLogger(this);
|
||||
std::sort(_filenames.begin(), _filenames.end());
|
||||
for (unsigned int c = 0; c < _filenames.size(); c++)
|
||||
{
|
||||
|
@ -357,7 +366,7 @@ unsigned int CppCheck::check()
|
|||
if (_settings._errorsOnly == false)
|
||||
_errorLogger->reportOut("Checking usage of global functions..");
|
||||
|
||||
_checkFunctionUsage.check();
|
||||
_checkUnusedFunctions.check();
|
||||
}
|
||||
|
||||
|
||||
|
@ -400,7 +409,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
|||
_tokenizer.simplifyTokenList();
|
||||
|
||||
if (_settings._unusedFunctions)
|
||||
_checkFunctionUsage.parseTokens(_tokenizer);
|
||||
_checkUnusedFunctions.parseTokens(_tokenizer);
|
||||
|
||||
// call all "runSimplifiedChecks" in all registered Check classes
|
||||
for (std::list<Check *>::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it)
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <map>
|
||||
#include "settings.h"
|
||||
#include "errorlogger.h"
|
||||
#include "checkfunctionusage.h"
|
||||
#include "checkunusedfunctions.h"
|
||||
|
||||
/**
|
||||
* This is the base class which will use other classes to do
|
||||
|
@ -135,7 +135,7 @@ private:
|
|||
std::vector<std::string> _filenames;
|
||||
/** Key is file name, and value is the content of the file */
|
||||
std::map<std::string, std::string> _fileContents;
|
||||
CheckFunctionUsage _checkFunctionUsage;
|
||||
CheckUnusedFunctions _checkUnusedFunctions;
|
||||
ErrorLogger *_errorLogger;
|
||||
|
||||
/** Current configuration */
|
||||
|
|
|
@ -1150,6 +1150,12 @@ std::string Preprocessor::expandMacros(std::string code, const std::string &file
|
|||
++pos2;
|
||||
while (pos2 < code.length() && code[pos2] != ch)
|
||||
{
|
||||
if (code[pos2] == '\\')
|
||||
{
|
||||
par += code[pos2];
|
||||
++pos2;
|
||||
}
|
||||
|
||||
par += code[pos2];
|
||||
++pos2;
|
||||
}
|
||||
|
|
|
@ -473,6 +473,9 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[])
|
|||
}
|
||||
}
|
||||
|
||||
// replace "unsigned i" with "unsigned int i"
|
||||
unsignedint();
|
||||
|
||||
simplifyVarDecl();
|
||||
|
||||
// Handle templates..
|
||||
|
@ -1250,6 +1253,12 @@ void Tokenizer::simplifyTokenList()
|
|||
}
|
||||
}
|
||||
|
||||
else if (Token::Match(tok, "sizeof ( %var% )") && tok->tokAt(2)->varId() > 0)
|
||||
{
|
||||
// don't try to replace size of variable if variable has
|
||||
// similar name with type (#329)
|
||||
}
|
||||
|
||||
else if (Token::Match(tok, "sizeof ( %type% )"))
|
||||
{
|
||||
const char *type = tok->strAt(2);
|
||||
|
@ -1459,6 +1468,7 @@ void Tokenizer::simplifyTokenList()
|
|||
modified |= removeReduntantConditions();
|
||||
modified |= simplifyRedundantParanthesis();
|
||||
modified |= simplifyCalculations();
|
||||
modified |= simplifyQuestionMark();
|
||||
}
|
||||
|
||||
createLinks();
|
||||
|
@ -1834,6 +1844,51 @@ bool Tokenizer::simplifyConditions()
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Tokenizer::simplifyQuestionMark()
|
||||
{
|
||||
bool ret = false;
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (tok->str() != "?")
|
||||
continue;
|
||||
|
||||
if (!tok->previous() || !tok->previous()->previous())
|
||||
continue;
|
||||
|
||||
if (!Token::Match(tok->previous()->previous(), "[=,(]"))
|
||||
continue;
|
||||
|
||||
if (!Token::Match(tok->previous(), "%bool%") &&
|
||||
!Token::Match(tok->previous(), "%num%"))
|
||||
continue;
|
||||
|
||||
if (tok->previous()->str() == "false" ||
|
||||
tok->previous()->str() == "0")
|
||||
{
|
||||
// Use code after semicolon, remove code before it.
|
||||
const Token *end = Token::findmatch(tok, ":");
|
||||
if (!end || !end->next())
|
||||
continue;
|
||||
|
||||
end = end->next();
|
||||
tok = tok->previous();
|
||||
while (tok->next() != end)
|
||||
{
|
||||
tok->deleteNext();
|
||||
}
|
||||
|
||||
Token *temp = tok;
|
||||
tok = tok->next();
|
||||
temp->deleteThis();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use code before semicolon
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Tokenizer::simplifyCasts()
|
||||
{
|
||||
|
@ -2162,6 +2217,30 @@ bool Tokenizer::simplifyVarDecl()
|
|||
}
|
||||
|
||||
|
||||
void Tokenizer::unsignedint()
|
||||
{
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
// A variable declaration where the "int" is left out?
|
||||
if (!Token::Match(tok, "unsigned %var% [;,=]"))
|
||||
continue;
|
||||
|
||||
// Previous token should either be a symbol or one of "{};"
|
||||
if (tok->previous() &&
|
||||
!tok->previous()->isName() &&
|
||||
!Token::Match(tok->previous(), "[{};]"))
|
||||
continue;
|
||||
|
||||
// next token should not be a standard type?
|
||||
if (tok->next()->isStandardType())
|
||||
continue;
|
||||
|
||||
// The "int" is missing.. add it
|
||||
tok->insertToken("int");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Tokenizer::simplifyIfAssign()
|
||||
{
|
||||
bool ret = false;
|
||||
|
|
|
@ -100,6 +100,17 @@ public:
|
|||
*/
|
||||
bool simplifyVarDecl();
|
||||
|
||||
/**
|
||||
* insert an "int" after "unsigned" if needed:
|
||||
* "unsigned i" => "unsigned int i"
|
||||
*/
|
||||
void unsignedint();
|
||||
|
||||
/**
|
||||
* Simplify question mark - colon operator
|
||||
* Example: 0 ? (2/0) : 0 => 0
|
||||
*/
|
||||
bool simplifyQuestionMark();
|
||||
|
||||
/**
|
||||
* simplify if-assignments..
|
||||
|
|
|
@ -75,6 +75,13 @@ private:
|
|||
" int num=2;"
|
||||
"res=#}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Wrong assignement of an auto-variable to an effective parameter of a function\n", errout.str());
|
||||
|
||||
check("void func1(int **res)\n"
|
||||
"{\n"
|
||||
" int num = 2;\n"
|
||||
" foo.res = #\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
void testautovararray()
|
||||
{
|
||||
|
|
|
@ -68,6 +68,7 @@ private:
|
|||
|
||||
TEST_CASE(sizeof1);
|
||||
TEST_CASE(sizeof2);
|
||||
TEST_CASE(sizeof3);
|
||||
|
||||
TEST_CASE(array_index_1);
|
||||
TEST_CASE(array_index_2);
|
||||
|
@ -123,7 +124,7 @@ private:
|
|||
" char str[50];\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,7 +146,7 @@ private:
|
|||
"{\n"
|
||||
" strcpy(buf, str);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -156,7 +157,7 @@ private:
|
|||
" char data[1];\n"
|
||||
" return abc.data[1];\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -168,7 +169,7 @@ private:
|
|||
" char data[100];\n"
|
||||
" const char *p = &data[100];\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -181,7 +182,7 @@ private:
|
|||
" char data[10];\n"
|
||||
" data[ sizeof(*data) ] = 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void sizeof2()
|
||||
|
@ -191,7 +192,7 @@ private:
|
|||
" char data[10];\n"
|
||||
" data[ sizeof(data[0]) ] = 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("static void f()\n"
|
||||
"{\n"
|
||||
|
@ -201,8 +202,17 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:4]: (all) Array index out of bounds\n", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void sizeof3()
|
||||
{
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" char group[32];\n"
|
||||
" snprintf(group, sizeof(group), \"%u\", 0);\n"
|
||||
" struct group *gr;\n"
|
||||
" snprintf(group, sizeof(group), \"%u\", gr->gr_gid);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void array_index_1()
|
||||
{
|
||||
|
@ -500,7 +510,7 @@ private:
|
|||
" char str[5];\n"
|
||||
" snprintf(str, 5, \"%s\", \"abc\");\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void snprintf3()
|
||||
|
@ -510,7 +520,7 @@ private:
|
|||
" char str[5];\n"
|
||||
" snprintf(str, sizeof str, \"%s\", \"abc\");\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void snprintf4()
|
||||
|
@ -520,7 +530,7 @@ private:
|
|||
" char str[5];\n"
|
||||
" snprintf(str, 8 - x, \"abcdefghijkl\");\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -572,7 +582,7 @@ private:
|
|||
" str[30] = 0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -587,7 +597,7 @@ private:
|
|||
" memset(str,0,50);\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void assign1()
|
||||
|
|
|
@ -65,7 +65,7 @@ private:
|
|||
" unsigned char ch = 0x80;\n"
|
||||
" buf[ch] = 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
"{\n"
|
||||
|
@ -106,7 +106,7 @@ private:
|
|||
" char ch;\n"
|
||||
" func(&ch);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void return1()
|
||||
|
@ -116,7 +116,7 @@ private:
|
|||
" char c;\n"
|
||||
" return &c;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ private:
|
|||
TEST_CASE(uninitVar1);
|
||||
TEST_CASE(uninitVarEnum);
|
||||
TEST_CASE(uninitVarStream);
|
||||
TEST_CASE(uninitVarTypedef);
|
||||
TEST_CASE(privateCtor1); // If constructor is private..
|
||||
TEST_CASE(privateCtor2); // If constructor is private..
|
||||
TEST_CASE(function); // Function is not variable
|
||||
|
@ -80,10 +81,10 @@ private:
|
|||
// Base class not found
|
||||
|
||||
checkVirtualDestructor("class Derived : public Base { };");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkVirtualDestructor("class Derived : Base { };");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void virtualDestructor2()
|
||||
|
@ -96,7 +97,7 @@ private:
|
|||
|
||||
checkVirtualDestructor("class Base { };\n"
|
||||
"class Derived : Base { public: ~Derived() { (void)11; } };");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void virtualDestructor3()
|
||||
|
@ -118,11 +119,11 @@ private:
|
|||
|
||||
checkVirtualDestructor("class Base { public: ~Base(); };\n"
|
||||
"class Derived : public Base { };");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkVirtualDestructor("class Base { public: ~Base(); };\n"
|
||||
"class Derived : private Fred, public Base { };");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void virtualDestructor5()
|
||||
|
@ -131,11 +132,11 @@ private:
|
|||
|
||||
checkVirtualDestructor("class Base { public: ~Base(); };\n"
|
||||
"class Derived : public Base { public: ~Derived() {} };");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkVirtualDestructor("class Base { public: ~Base(); };\n"
|
||||
"class Derived : public Base { public: ~Derived(); }; Derived::~Derived() {}");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void virtualDestructorProtected()
|
||||
|
@ -153,7 +154,7 @@ private:
|
|||
"public:\n"
|
||||
" ~B() { int a; }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void checkUninitVar(const char code[])
|
||||
|
@ -222,9 +223,21 @@ private:
|
|||
" }\n"
|
||||
"};\n");
|
||||
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitVarTypedef()
|
||||
{
|
||||
checkUninitVar("class Foo\n"
|
||||
"{\n"
|
||||
"public:\n"
|
||||
" typedef int * pointer;\n"
|
||||
" Foo() : a(0) {}\n"
|
||||
" pointer a;\n"
|
||||
"};\n");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void privateCtor1()
|
||||
{
|
||||
|
@ -233,7 +246,7 @@ private:
|
|||
" Foo() { }\n"
|
||||
"};\n");
|
||||
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void privateCtor2()
|
||||
|
@ -269,7 +282,7 @@ private:
|
|||
" return p;\n"
|
||||
"}\n");
|
||||
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ private:
|
|||
" { this->i = 0; }\n"
|
||||
" int i;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void initvar_if()
|
||||
|
@ -163,7 +163,7 @@ private:
|
|||
" }\n"
|
||||
" int i;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void initvar_operator_eq1()
|
||||
|
@ -187,7 +187,7 @@ private:
|
|||
"};\n");
|
||||
|
||||
std::string err(errout.str());
|
||||
ASSERT_EQUALS(std::string(""), err);
|
||||
ASSERT_EQUALS("", err);
|
||||
}
|
||||
|
||||
|
||||
|
@ -214,7 +214,7 @@ private:
|
|||
" Init() { i = 0; }\n"
|
||||
" int i;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void initvar_same_classname()
|
||||
|
@ -240,7 +240,7 @@ private:
|
|||
"}\n");
|
||||
|
||||
std::string err(errout.str());
|
||||
ASSERT_EQUALS(std::string(""), err);
|
||||
ASSERT_EQUALS("", err);
|
||||
}
|
||||
|
||||
void initvar_chained_assign()
|
||||
|
@ -261,7 +261,7 @@ private:
|
|||
"}\n");
|
||||
|
||||
std::string err(errout.str());
|
||||
ASSERT_EQUALS(std::string(""), err);
|
||||
ASSERT_EQUALS("", err);
|
||||
}
|
||||
|
||||
|
||||
|
@ -296,7 +296,7 @@ private:
|
|||
"}\n");
|
||||
|
||||
std::string err(errout.str());
|
||||
ASSERT_EQUALS(std::string(""), err);
|
||||
ASSERT_EQUALS("", err);
|
||||
}
|
||||
|
||||
|
||||
|
@ -337,7 +337,7 @@ private:
|
|||
"};\n"
|
||||
"Fred::Fred()\n"
|
||||
"{ }");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void initvar_destructor()
|
||||
|
@ -350,7 +350,7 @@ private:
|
|||
" Fred() : var(0) {}\n"
|
||||
" ~Fred() {}\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void operatorEqSTL()
|
||||
|
|
|
@ -113,7 +113,7 @@ private:
|
|||
" unsigned int i2;\n"
|
||||
" result = i2 / i1;}\n"
|
||||
);
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void division5()
|
||||
|
@ -124,7 +124,7 @@ private:
|
|||
" unsigned int val = 32;\n"
|
||||
" val = val / USER_HASH;}\n"
|
||||
);
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void division6()
|
||||
|
|
|
@ -80,7 +80,7 @@ private:
|
|||
"#endif\n"
|
||||
"}\n");
|
||||
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void test2()
|
||||
|
@ -100,7 +100,7 @@ private:
|
|||
" const char *str[] = { \"abc\" };\n"
|
||||
"}\n");
|
||||
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void test4()
|
||||
|
@ -115,7 +115,7 @@ private:
|
|||
"};\n"
|
||||
"}\n");
|
||||
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void test5()
|
||||
|
@ -143,13 +143,13 @@ private:
|
|||
"};\n"
|
||||
"}\n");
|
||||
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void intarray()
|
||||
{
|
||||
check("int arr[] = { 100/2, 1*100 };\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void structarraynull()
|
||||
|
@ -158,7 +158,7 @@ private:
|
|||
" { 100/2, 1*100 }\n"
|
||||
" { 90, 70 }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void structarray()
|
||||
|
@ -167,7 +167,7 @@ private:
|
|||
" { 100/2, 1*100 }\n"
|
||||
" { 90, 70 }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
};
|
||||
|
|
1799
test/testmemleak.cpp
1799
test/testmemleak.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Cppcheck - A tool for static C/C++ code analysis
|
||||
* Copyright (C) 2007-2009 Daniel Marjamäki and Cppcheck team.
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/
|
||||
*/
|
||||
|
||||
|
||||
#include "../src/tokenize.h"
|
||||
#include "../src/checkmemoryleak.h"
|
||||
#include "testsuite.h"
|
||||
#include <sstream>
|
||||
|
||||
extern std::ostringstream errout;
|
||||
|
||||
class TestMemleakMultiPass : public TestFixture
|
||||
{
|
||||
public:
|
||||
TestMemleakMultiPass() : TestFixture("TestMemleakMultiPass")
|
||||
{ }
|
||||
|
||||
class OurCheckMemoryLeakClass : public CheckMemoryLeakClass
|
||||
{
|
||||
public:
|
||||
OurCheckMemoryLeakClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||
: CheckMemoryLeakClass(tokenizer, settings, errorLogger)
|
||||
{
|
||||
}
|
||||
|
||||
Token *functionParameterCode(const Token *ftok, int parameter)
|
||||
{
|
||||
return CheckMemoryLeakClass::functionParameterCode(ftok, parameter);
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
void run()
|
||||
{
|
||||
TEST_CASE(param1);
|
||||
}
|
||||
|
||||
void param1()
|
||||
{
|
||||
const char code[] = "void f(char *s)\n"
|
||||
"{\n"
|
||||
" ;\n"
|
||||
"}\n";
|
||||
|
||||
// Tokenize..
|
||||
Tokenizer tokenizer;
|
||||
std::istringstream istr(code);
|
||||
tokenizer.tokenize(istr, "test.cpp");
|
||||
tokenizer.simplifyTokenList();
|
||||
|
||||
// Clear the error log
|
||||
errout.str("");
|
||||
|
||||
// Check..
|
||||
Settings settings;
|
||||
OurCheckMemoryLeakClass checkMemoryLeak(&tokenizer, &settings, this);
|
||||
Token *tok = checkMemoryLeak.functionParameterCode(tokenizer.tokens(), 1);
|
||||
|
||||
// Compare tokens..
|
||||
std::string s;
|
||||
for (const Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||
s += tok2->str() + " ";
|
||||
ASSERT_EQUALS("; } ", s);
|
||||
Tokenizer::deleteTokens(tok);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestMemleakMultiPass)
|
|
@ -110,11 +110,15 @@ private:
|
|||
" }\n"
|
||||
" cout<<b/sum;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
"{\n"
|
||||
" int a = 0 ? (2/0) : 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void delete1()
|
||||
{
|
||||
check("void foo()\n"
|
||||
|
@ -125,7 +129,7 @@ private:
|
|||
" p = 0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void delete2()
|
||||
|
@ -172,7 +176,7 @@ private:
|
|||
" break;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -213,7 +217,7 @@ private:
|
|||
" char buf[100];\n"
|
||||
" sprintf(buf,\"%i\",sizeof(buf));\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void sprintf3()
|
||||
|
@ -224,7 +228,7 @@ private:
|
|||
" sprintf(buf,\"%i\",sizeof(buf));\n"
|
||||
" if (buf[0]);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void sprintf4()
|
||||
|
@ -240,7 +244,7 @@ private:
|
|||
" struct A a;\n"
|
||||
" snprintf(a.filename, 128, \"%s\", filename);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -293,7 +297,7 @@ private:
|
|||
" std::string temp = \"/tmp\";\n"
|
||||
" std::string path = temp + '/' + \"sub\" + '/';\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -332,7 +336,7 @@ private:
|
|||
" char str[100] = {0};\n"
|
||||
" return str;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void varScope(const char code[])
|
||||
|
@ -381,7 +385,7 @@ private:
|
|||
"\n"
|
||||
" return 1;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void varScope2()
|
||||
|
@ -392,7 +396,7 @@ private:
|
|||
" e.SetValue(12);\n"
|
||||
" throw e;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void varScope3()
|
||||
|
@ -407,7 +411,7 @@ private:
|
|||
" }\n"
|
||||
" *p = 1;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -451,7 +455,7 @@ private:
|
|||
" while (fred);\n"
|
||||
" fred.hello();\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -103,6 +103,7 @@ private:
|
|||
TEST_CASE(macro_simple6);
|
||||
TEST_CASE(macro_simple7);
|
||||
TEST_CASE(macro_simple8);
|
||||
TEST_CASE(macro_simple9);
|
||||
TEST_CASE(macro_mismatch);
|
||||
TEST_CASE(macro_linenumbers);
|
||||
TEST_CASE(string1);
|
||||
|
@ -665,6 +666,14 @@ private:
|
|||
ASSERT_EQUALS("\n\n123 1234", OurPreprocessor::expandMacros(filedata));
|
||||
}
|
||||
|
||||
void macro_simple9()
|
||||
{
|
||||
const char filedata[] = "#define ABC(a) f(a)\n"
|
||||
"ABC( \"\\\"\" );\n"
|
||||
"ABC( \"g\" );";
|
||||
ASSERT_EQUALS("\nf(\"\\\"\");\nf(\"g\");", OurPreprocessor::expandMacros(filedata));
|
||||
}
|
||||
|
||||
void macro_mismatch()
|
||||
{
|
||||
const char filedata[] = "#define AAA(aa,bb) f(aa)\n"
|
||||
|
|
|
@ -158,7 +158,7 @@ private:
|
|||
" foo[ii] = 0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -169,7 +169,7 @@ private:
|
|||
" {\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -187,7 +187,7 @@ private:
|
|||
" }\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,6 +145,9 @@ private:
|
|||
TEST_CASE(syntax_error);
|
||||
|
||||
TEST_CASE(removeKeywords);
|
||||
|
||||
// unsigned i; => unsigned int i;
|
||||
TEST_CASE(unsigned1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1987,7 +1990,7 @@ private:
|
|||
Tokenizer tokenizer(s, this);
|
||||
std::istringstream istr(code);
|
||||
ASSERT_EQUALS(true, tokenizer.tokenize(istr, "test.cpp"));
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -2015,7 +2018,7 @@ private:
|
|||
std::istringstream istr(code);
|
||||
ASSERT_EQUALS(true, tokenizer.tokenize(istr, "test.cpp"));
|
||||
tokenizer.simplifyTokenList();
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2028,6 +2031,28 @@ private:
|
|||
ASSERT_EQUALS("if ( ! ! x ) { ; }", actual);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* tokenize "unsigned i" => "unsigned int i"
|
||||
* tokenize "unsigned int" => "unsigned int"
|
||||
*/
|
||||
void unsigned1()
|
||||
{
|
||||
// No changes..
|
||||
{
|
||||
const char code[] = "void foo ( unsigned int , unsigned float ) ;";
|
||||
ASSERT_EQUALS(code, tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
// insert "int" after "unsigned"..
|
||||
{
|
||||
const char code1[] = "unsigned i ;";
|
||||
const char code2[] = "unsigned int i ;";
|
||||
ASSERT_EQUALS(code2, tokenizeAndStringify(code1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestTokenizer)
|
||||
|
|
|
@ -19,15 +19,15 @@
|
|||
|
||||
#include "../src/tokenize.h"
|
||||
#include "testsuite.h"
|
||||
#include "../src/checkfunctionusage.h"
|
||||
#include "../src/checkunusedfunctions.h"
|
||||
#include <sstream>
|
||||
|
||||
extern std::ostringstream errout;
|
||||
|
||||
class TestFunctionUsage : public TestFixture
|
||||
class TestUnusedFunctions : public TestFixture
|
||||
{
|
||||
public:
|
||||
TestFunctionUsage() : TestFixture("TestFunctionUsage")
|
||||
TestUnusedFunctions() : TestFixture("TestUnusedFunctions")
|
||||
{ }
|
||||
|
||||
private:
|
||||
|
@ -37,6 +37,7 @@ private:
|
|||
{
|
||||
TEST_CASE(incondition);
|
||||
TEST_CASE(return1);
|
||||
TEST_CASE(return2);
|
||||
TEST_CASE(callback1);
|
||||
TEST_CASE(else1);
|
||||
TEST_CASE(functionpointer);
|
||||
|
@ -53,9 +54,9 @@ private:
|
|||
errout.str("");
|
||||
|
||||
// Check for unused functions..
|
||||
CheckFunctionUsage checkFunctionUsage(this);
|
||||
checkFunctionUsage.parseTokens(tokenizer);
|
||||
checkFunctionUsage.check();
|
||||
CheckUnusedFunctions checkUnusedFunctions(this);
|
||||
checkUnusedFunctions.parseTokens(tokenizer);
|
||||
checkUnusedFunctions.check();
|
||||
}
|
||||
|
||||
void incondition()
|
||||
|
@ -65,8 +66,7 @@ private:
|
|||
" if (f1())\n"
|
||||
" { }\n"
|
||||
"}\n");
|
||||
std::string err(errout.str());
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void return1()
|
||||
|
@ -75,8 +75,16 @@ private:
|
|||
"{\n"
|
||||
" return f1();\n"
|
||||
"}\n");
|
||||
std::string err(errout.str());
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void return2()
|
||||
{
|
||||
check("char * foo()\n"
|
||||
"{\n"
|
||||
" return *foo();\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void callback1()
|
||||
|
@ -85,8 +93,7 @@ private:
|
|||
"{\n"
|
||||
" void (*f)() = cond ? f1 : NULL;\n"
|
||||
"}\n");
|
||||
std::string err(errout.str());
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void else1()
|
||||
|
@ -96,8 +103,7 @@ private:
|
|||
" if (cond) ;\n"
|
||||
" else f1();\n"
|
||||
"}\n");
|
||||
std::string err(errout.str());
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void functionpointer()
|
||||
|
@ -111,9 +117,9 @@ private:
|
|||
" f(&abc::foo);\n"
|
||||
" return 0\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestFunctionUsage)
|
||||
REGISTER_TEST(TestUnusedFunctions)
|
||||
|
|
@ -100,7 +100,7 @@ private:
|
|||
"\n"
|
||||
"A::A()\n"
|
||||
"{ }\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,7 +116,7 @@ private:
|
|||
"\n"
|
||||
"A::~A()\n"
|
||||
"{ B(); }\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,7 +132,7 @@ private:
|
|||
"\n"
|
||||
"A::A() : _owner(false)\n"
|
||||
"{ b(); }\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -180,7 +180,7 @@ private:
|
|||
" int numOfThreads;\n"
|
||||
"};\n");
|
||||
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ private:
|
|||
" int b = abc.b;\n"
|
||||
" int c = abc.c;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void structmember3()
|
||||
|
@ -109,7 +109,7 @@ private:
|
|||
" int b = abc[0].b;\n"
|
||||
" int c = abc[0].c;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,7 +125,7 @@ private:
|
|||
" ABC abc;\n"
|
||||
" if (abc.a == 2);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,7 +147,7 @@ private:
|
|||
" struct AB ab;\n"
|
||||
" ab.reset();\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
#define MyAppName "cppcheck"
|
||||
#define AppVersion "1.32"
|
||||
#define AppVersion "1.33"
|
||||
#define MyAppURL "http://cppcheck.wiki.sourceforge.net/"
|
||||
#define MyAppExeName "cppcheck.exe"
|
||||
#define QTGuiExe "gui.exe"
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
Windows installer for the cppcheck
|
||||
----------------------------------
|
||||
|
||||
Simple Windows installer installing executable, license file and readme.txt to
|
||||
program files/cppcheck folder.
|
||||
Windows installer for both command line cppcheck and for QT-based GUI. All
|
||||
needed runtimes and libraries are installed.
|
||||
|
||||
Shortcuts are created to start cmd.exe in installation folder. So when the user
|
||||
selects start menu/desktop icon he gets command prompt in cppcheck folder.
|
||||
Command line cppccheck shortcuts are created to start cmd.exe in installation
|
||||
folder. So when the user selects start menu/desktop icon he gets command prompt
|
||||
in cppcheck folder.
|
||||
|
||||
Get the InnoSetup from:
|
||||
http://www.innosetup.com/
|
||||
|
@ -13,10 +14,14 @@ Be sure to download the 'QuickStart Pack' as it installs some nice tools
|
|||
like ISTool and preprocessor support.
|
||||
|
||||
Files the installer needs:
|
||||
/Release/cppcheck.exe
|
||||
/COPYING
|
||||
/readme.txt
|
||||
/AUTHORS
|
||||
/gui/release/gui.exe
|
||||
/Release/cppcheck.exe
|
||||
/win_installer/icon.bmp
|
||||
/win_installer/LargeLogo.bmp
|
||||
/win_installer/
|
||||
|
||||
NOTE: Remember to convert COPYING and AUTHORS to Windows EOL format! Otherwise
|
||||
Windows Notepad (default viewer) can't show then properly.
|
||||
|
@ -30,6 +35,14 @@ and modify RuntimesFolder -macro in begin of cppcheck.iss to point to the
|
|||
folder where files are. You can find runtime files from VS installation or from
|
||||
net.
|
||||
|
||||
QT Libraries:
|
||||
Visual Studio is used to build the GUI executable. And QT must be build with VS
|
||||
also. When building QT make sure you build release targets!
|
||||
|
||||
Copy following files to same RuntimesFolder than VS runtime files:
|
||||
- QtCore4.dll
|
||||
- QtGui4.dll
|
||||
|
||||
Creating the installer executable:
|
||||
#1 Open the ISTool and load cppcheck.iss
|
||||
#2 Update the release version number:
|
||||
|
|
Loading…
Reference in New Issue