Merge branch 'master' of git@github.com:danmar/cppcheck

This commit is contained in:
Vesa Pikki 2009-06-09 09:31:54 +03:00
commit de0bea3479
54 changed files with 11058 additions and 1438 deletions

7
.gitignore vendored
View File

@ -8,6 +8,8 @@ tools/errmsg
*.ncb *.ncb
*.suo *.suo
*.user *.user
*.idb
*.pdb
# VS build folders # VS build folders
Build/ Build/
BuildTmp/ BuildTmp/
@ -17,6 +19,9 @@ gui/release/
gui/temp/ gui/temp/
# Other (generated) GUI files # Other (generated) GUI files
gui/Makefile gui/Makefile
gui/Makefile.debug
gui/Makefile.release
gui/gui.sln
gui/gui.vcproj
gui/gui gui/gui
gui/qrc_gui.cpp gui/qrc_gui.cpp

9257
Changelog Normal file

File diff suppressed because it is too large Load Diff

View File

@ -9,12 +9,12 @@ OBJECTS = src/checkautovariables.o \
src/checkbufferoverrun.o \ src/checkbufferoverrun.o \
src/checkclass.o \ src/checkclass.o \
src/checkdangerousfunctions.o \ src/checkdangerousfunctions.o \
src/checkfunctionusage.o \
src/checkheaders.o \ src/checkheaders.o \
src/checkmemoryleak.o \ src/checkmemoryleak.o \
src/checkother.o \ src/checkother.o \
src/checksecurity.o \ src/checksecurity.o \
src/checkstl.o \ src/checkstl.o \
src/checkunusedfunctions.o \
src/cppcheck.o \ src/cppcheck.o \
src/cppcheckexecutor.o \ src/cppcheckexecutor.o \
src/errorlogger.o \ src/errorlogger.o \
@ -36,11 +36,9 @@ TESTOBJ = test/testautovariables.o \
test/testdangerousfunctions.o \ test/testdangerousfunctions.o \
test/testdivision.o \ test/testdivision.o \
test/testfilelister.o \ test/testfilelister.o \
test/testfunctionusage.o \
test/testincompletestatement.o \ test/testincompletestatement.o \
test/testmathlib.o \ test/testmathlib.o \
test/testmemleak.o \ test/testmemleak.o \
test/testmemleakmp.o \
test/testother.o \ test/testother.o \
test/testpreprocessor.o \ test/testpreprocessor.o \
test/testredundantif.o \ test/testredundantif.o \
@ -51,18 +49,19 @@ TESTOBJ = test/testautovariables.o \
test/testsuite.o \ test/testsuite.o \
test/testtoken.o \ test/testtoken.o \
test/testtokenize.o \ test/testtokenize.o \
test/testunusedfunctions.o \
test/testunusedprivfunc.o \ test/testunusedprivfunc.o \
test/testunusedvar.o \ test/testunusedvar.o \
src/checkautovariables.o \ src/checkautovariables.o \
src/checkbufferoverrun.o \ src/checkbufferoverrun.o \
src/checkclass.o \ src/checkclass.o \
src/checkdangerousfunctions.o \ src/checkdangerousfunctions.o \
src/checkfunctionusage.o \
src/checkheaders.o \ src/checkheaders.o \
src/checkmemoryleak.o \ src/checkmemoryleak.o \
src/checkother.o \ src/checkother.o \
src/checksecurity.o \ src/checksecurity.o \
src/checkstl.o \ src/checkstl.o \
src/checkunusedfunctions.o \
src/cppcheck.o \ src/cppcheck.o \
src/cppcheckexecutor.o \ src/cppcheckexecutor.o \
src/errorlogger.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 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 $(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 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 $(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 $(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 $(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 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 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 $(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 $(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 $(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 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 src/mathlib.o: src/mathlib.cpp src/mathlib.h src/token.h
$(CXX) $(CXXFLAGS) -c -o src/mathlib.o src/mathlib.cpp $(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 $(CXX) $(CXXFLAGS) -c -o src/preprocessor.o src/preprocessor.cpp
src/settings.o: src/settings.cpp src/settings.h src/settings.o: src/settings.cpp src/settings.h
$(CXX) $(CXXFLAGS) -c -o src/settings.o src/settings.cpp $(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 $(CXX) $(CXXFLAGS) -c -o src/threadexecutor.o src/threadexecutor.cpp
src/token.o: src/token.cpp src/token.h 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 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 $(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 $(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 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 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 $(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 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 $(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 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 $(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 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 $(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 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 $(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 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 $(CXX) $(CXXFLAGS) -c -o test/testunusedprivfunc.o test/testunusedprivfunc.cpp

View File

@ -30,6 +30,8 @@
<Add option="-Wall" /> <Add option="-Wall" />
<Add option="-fexceptions" /> <Add option="-fexceptions" />
</Compiler> </Compiler>
<Unit filename="gui/aboutdialog.cpp" />
<Unit filename="gui/aboutdialog.h" />
<Unit filename="gui/applicationdialog.cpp" /> <Unit filename="gui/applicationdialog.cpp" />
<Unit filename="gui/applicationdialog.h" /> <Unit filename="gui/applicationdialog.h" />
<Unit filename="gui/applicationlist.cpp" /> <Unit filename="gui/applicationlist.cpp" />

View File

@ -59,6 +59,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="shlwapi.lib"
LinkIncremental="2" LinkIncremental="2"
GenerateDebugInformation="true" GenerateDebugInformation="true"
SubSystem="1" SubSystem="1"
@ -127,6 +128,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="shlwapi.lib"
LinkIncremental="1" LinkIncremental="1"
GenerateDebugInformation="false" GenerateDebugInformation="false"
SubSystem="1" SubSystem="1"
@ -185,10 +187,6 @@
RelativePath=".\src\checkdangerousfunctions.h" RelativePath=".\src\checkdangerousfunctions.h"
> >
</File> </File>
<File
RelativePath=".\src\checkfunctionusage.h"
>
</File>
<File <File
RelativePath=".\src\checkheaders.h" RelativePath=".\src\checkheaders.h"
> >
@ -209,6 +207,10 @@
RelativePath=".\src\checkstl.h" RelativePath=".\src\checkstl.h"
> >
</File> </File>
<File
RelativePath=".\src\checkunusedfunctions.h"
>
</File>
<File <File
RelativePath=".\src\cppcheck.h" RelativePath=".\src\cppcheck.h"
> >
@ -289,10 +291,6 @@
RelativePath=".\src\checkdangerousfunctions.cpp" RelativePath=".\src\checkdangerousfunctions.cpp"
> >
</File> </File>
<File
RelativePath=".\src\checkfunctionusage.cpp"
>
</File>
<File <File
RelativePath=".\src\checkheaders.cpp" RelativePath=".\src\checkheaders.cpp"
> >
@ -313,6 +311,10 @@
RelativePath=".\src\checkstl.cpp" RelativePath=".\src\checkstl.cpp"
> >
</File> </File>
<File
RelativePath=".\src\checkunusedfunctions.cpp"
>
</File>
<File <File
RelativePath=".\src\cppcheck.cpp" RelativePath=".\src\cppcheck.cpp"
> >

View File

@ -4,7 +4,7 @@
# Archive files are created in user's home directory. # Archive files are created in user's home directory.
# Tag to use # Tag to use
tag=1.32 tag=1.33
# Name of release # Name of release
releasename=cppcheck-$tag releasename=cppcheck-$tag

View File

@ -1,6 +1,6 @@
/* /*
* Cppcheck - A tool for static C/C++ code analysis * 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 * 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
@ -28,20 +28,20 @@ AboutDialog::AboutDialog(const QString &version, QWidget *parent)
{ {
setWindowTitle(tr("About cppcheck")); setWindowTitle(tr("About cppcheck"));
// Left icon area and right text area // Left icon area and right text area
QHBoxLayout *iconLayout = new QHBoxLayout(this); QHBoxLayout *iconLayout = new QHBoxLayout();
// Keep icon at the top of the dialog // Keep icon at the top of the dialog
QVBoxLayout *iconVLayout = new QVBoxLayout(this); QVBoxLayout *iconVLayout = new QVBoxLayout();
// Texts // Texts
QVBoxLayout *mainLayout = new QVBoxLayout(this); QVBoxLayout *mainLayout = new QVBoxLayout();
// Keep close button in right // Keep close button in right
QHBoxLayout *btnLayout = new QHBoxLayout(this); QHBoxLayout *btnLayout = new QHBoxLayout();
QIcon *icon = new QIcon(":icon.png"); QIcon *icon = new QIcon(":icon.png");
QLabel *iconLabel = new QLabel(); QLabel *iconLabel = new QLabel();
iconLabel->setPixmap(icon->pixmap(QSize(48, 48))); iconLabel->setPixmap(icon->pixmap(QSize(48, 48)));
QLabel *name = new QLabel(tr("Cppcheck - A tool for static C/C++ code analysis.")); 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 *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); copy->setWordWrap(true);
QLabel *gpl = new QLabel(tr("This program is licensed under the terms " \ QLabel *gpl = new QLabel(tr("This program is licensed under the terms " \
"of the GNU General Public License version 3")); "of the GNU General Public License version 3"));
@ -63,6 +63,7 @@ AboutDialog::AboutDialog(const QString &version, QWidget *parent)
btnLayout->addStretch(); btnLayout->addStretch();
btnLayout->addWidget(quit); btnLayout->addWidget(quit);
setLayout(iconLayout);
connect(quit, SIGNAL(clicked()), this, SLOT(close())); connect(quit, SIGNAL(clicked()), this, SLOT(close()));
} }

View File

@ -1,6 +1,6 @@
/* /*
* Cppcheck - A tool for static C/C++ code analysis * 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 * 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

View File

@ -28,11 +28,14 @@
ApplicationDialog::ApplicationDialog(const QString &name, ApplicationDialog::ApplicationDialog(const QString &name,
const QString &path, const QString &path,
const QString &title) const QString &title,
QWidget *parent) :
QDialog(parent)
{ {
QVBoxLayout *layout = new QVBoxLayout(); QVBoxLayout *layout = new QVBoxLayout();
mName = new QLineEdit(name); 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" \ 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" \ "Specify a name for the application and the application to execute.\n\n" \
@ -79,7 +82,6 @@ ApplicationDialog::~ApplicationDialog()
//dtor //dtor
} }
void ApplicationDialog::Browse() void ApplicationDialog::Browse()
{ {
QFileDialog dialog(this); QFileDialog dialog(this);
@ -90,7 +92,18 @@ void ApplicationDialog::Browse()
QStringList list = dialog.selectedFiles(); QStringList list = dialog.selectedFiles();
if (list.size() > 0) 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 else
{ {
// Convert possible native (Windows) path to internal presentation format
mPath->setText(QDir::fromNativeSeparators(mPath->text()));
accept(); accept();
} }
} }

View File

@ -38,10 +38,12 @@ public:
* @param name Default name for the application to start * @param name Default name for the application to start
* @param path Path for the application * @param path Path for the application
* @param title Title for the dialog * @param title Title for the dialog
* @param parent Parent widget
*/ */
ApplicationDialog(const QString &name, ApplicationDialog(const QString &name,
const QString &path, const QString &path,
const QString &title); const QString &title,
QWidget *parent = 0);
virtual ~ApplicationDialog(); virtual ~ApplicationDialog();
/** /**

View File

@ -36,9 +36,9 @@ HEADERS += mainwindow.h \
../src/settings.h \ ../src/settings.h \
../src/tokenize.h \ ../src/tokenize.h \
../src/checkbufferoverrun.h \ ../src/checkbufferoverrun.h \
../src/checkfunctionusage.h \
../src/checkmemoryleak.h \ ../src/checkmemoryleak.h \
../src/checkstl.h \ ../src/checkstl.h \
../src/checkunusedfunctions.h \
../src/errorlogger.h \ ../src/errorlogger.h \
../src/preprocessor.h \ ../src/preprocessor.h \
../src/threadexecutor.h \ ../src/threadexecutor.h \
@ -70,7 +70,6 @@ SOURCES += main.cpp \
../src/mathlib.cpp \ ../src/mathlib.cpp \
../src/threadexecutor.cpp \ ../src/threadexecutor.cpp \
../src/checkbufferoverrun.cpp \ ../src/checkbufferoverrun.cpp \
../src/checkfunctionusage.cpp \
../src/checkother.cpp \ ../src/checkother.cpp \
../src/cppcheck.cpp \ ../src/cppcheck.cpp \
../src/filelister.cpp \ ../src/filelister.cpp \
@ -80,5 +79,6 @@ SOURCES += main.cpp \
../src/checkheaders.cpp \ ../src/checkheaders.cpp \
../src/checksecurity.cpp \ ../src/checksecurity.cpp \
../src/cppcheckexecutor.cpp \ ../src/cppcheckexecutor.cpp \
../src/checkunusedfunctions.cpp \
../src/settings.cpp \ ../src/settings.cpp \
../src/tokenize.cpp ../src/tokenize.cpp

View File

@ -18,6 +18,7 @@
#include <QApplication> #include <QApplication>
#include <QTextCodec>
#include "mainwindow.h" #include "mainwindow.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -25,6 +26,10 @@ int main(int argc, char *argv[])
QApplication app(argc, argv); QApplication app(argc, argv);
app.setWindowIcon(QIcon(":icon.png")); 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; MainWindow window;
window.show(); window.show();
return app.exec(); return app.exec();

View File

@ -300,7 +300,7 @@ void MainWindow::CheckDone()
void MainWindow::ProgramSettings() void MainWindow::ProgramSettings()
{ {
SettingsDialog dialog(mSettings, mApplications); SettingsDialog dialog(mSettings, mApplications, this);
if (dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
dialog.SaveCheckboxValues(); dialog.SaveCheckboxValues();

38
gui/readme.txt Normal file
View File

@ -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.

View File

@ -36,10 +36,10 @@ ResultsTree::ResultsTree(QSettings &settings, ApplicationList &list) :
labels << tr("File") << tr("Severity") << tr("Line") << tr("Message"); labels << tr("File") << tr("Severity") << tr("Line") << tr("Message");
mModel.setHorizontalHeaderLabels(labels); mModel.setHorizontalHeaderLabels(labels);
setExpandsOnDoubleClick(false); setExpandsOnDoubleClick(false);
setSortingEnabled(true);
LoadSettings(); LoadSettings();
connect(this, SIGNAL(doubleClicked(const QModelIndex &)), connect(this, SIGNAL(doubleClicked(const QModelIndex &)),
this, SLOT(QuickStartApplication(const QModelIndex &))); this, SLOT(QuickStartApplication(const QModelIndex &)));
} }
ResultsTree::~ResultsTree() ResultsTree::~ResultsTree()
@ -47,8 +47,6 @@ ResultsTree::~ResultsTree()
SaveSettings(); SaveSettings();
} }
QStandardItem *ResultsTree::CreateItem(const QString &name) QStandardItem *ResultsTree::CreateItem(const QString &name)
{ {
QStandardItem *item = new QStandardItem(name); QStandardItem *item = new QStandardItem(name);
@ -56,7 +54,6 @@ QStandardItem *ResultsTree::CreateItem(const QString &name)
return item; return item;
} }
void ResultsTree::AddErrorItem(const QString &file, void ResultsTree::AddErrorItem(const QString &file,
const QString &severity, const QString &severity,
const QString &message, const QString &message,
@ -66,7 +63,6 @@ void ResultsTree::AddErrorItem(const QString &file,
{ {
Q_UNUSED(file); Q_UNUSED(file);
if (files.isEmpty()) if (files.isEmpty())
{ {
return; return;
@ -100,7 +96,6 @@ void ResultsTree::AddErrorItem(const QString &file,
data["id"] = id; data["id"] = id;
item->setData(QVariant(data)); item->setData(QVariant(data));
//Add backtrace files as children //Add backtrace files as children
for (int i = 1;i < files.size() && i < lines.size();i++) 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(QString("%1").arg(line));
list << CreateItem(message); list << CreateItem(message);
QModelIndex index = QModelIndex(); QModelIndex index = QModelIndex();
parent->appendRow(list); parent->appendRow(list);
setRowHidden(parent->rowCount() - 1, parent->index(), hide); setRowHidden(parent->rowCount() - 1, parent->index(), hide);
if (!icon.isEmpty()) if (!icon.isEmpty())
{ {
list[0]->setIcon(QIcon(icon)); 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("(message)", data["message"].toString(), Qt::CaseInsensitive);
program.replace("(severity)", data["severity"].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; out << line << endl;
} }
} }
@ -623,7 +627,6 @@ void ResultsTree::RefreshFilePaths(QStandardItem *item)
//Loop through all errors within this file //Loop through all errors within this file
for (int i = 0;i < item->rowCount();i++) for (int i = 0;i < item->rowCount();i++)
{ {
//Get error i //Get error i
QStandardItem *error = item->child(i, 0); QStandardItem *error = item->child(i, 0);
@ -632,7 +635,6 @@ void ResultsTree::RefreshFilePaths(QStandardItem *item)
continue; continue;
} }
//Get error's user data //Get error's user data
QVariant userdata = error->data(); QVariant userdata = error->data();
//Convert it to QVariantMap //Convert it to QVariantMap
@ -650,7 +652,6 @@ void ResultsTree::RefreshFilePaths(QStandardItem *item)
//Update this error's text //Update this error's text
error->setText(StripPath(files[0], false)); error->setText(StripPath(files[0], false));
//If this error has backtraces make sure the files list has enough filenames //If this error has backtraces make sure the files list has enough filenames
if (error->rowCount() <= files.size() - 1) if (error->rowCount() <= files.size() - 1)
{ {
@ -678,7 +679,6 @@ void ResultsTree::RefreshFilePaths(QStandardItem *item)
} }
} }
void ResultsTree::RefreshFilePaths() void ResultsTree::RefreshFilePaths()
{ {
qDebug("Refreshing file paths"); qDebug("Refreshing file paths");
@ -688,6 +688,4 @@ void ResultsTree::RefreshFilePaths()
{ {
RefreshFilePaths(mModel.item(i, 0)); RefreshFilePaths(mModel.item(i, 0));
} }
} }

View File

@ -18,12 +18,16 @@
#include "settingsdialog.h" #include "settingsdialog.h"
#include <QDialog>
#include <QWidget>
#include <QLabel> #include <QLabel>
#include <QDebug> #include <QDebug>
#include <QTabWidget> #include <QTabWidget>
#include "applicationdialog.h" #include "applicationdialog.h"
SettingsDialog::SettingsDialog(QSettings &programSettings, ApplicationList &list) : SettingsDialog::SettingsDialog(QSettings &programSettings, ApplicationList &list,
QWidget *parent) :
QDialog(parent),
mSettings(programSettings), mSettings(programSettings),
mApplications(list) mApplications(list)
{ {
@ -210,7 +214,7 @@ void SettingsDialog::SaveCheckboxValue(QCheckBox *box, const QString &name)
void SettingsDialog::AddApplication() void SettingsDialog::AddApplication()
{ {
ApplicationDialog dialog("", "", tr("Add a new application")); ApplicationDialog dialog("", "", tr("Add a new application"), this);
if (dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
@ -267,10 +271,16 @@ void SettingsDialog::DefaultApplication()
void SettingsDialog::PopulateListWidget() void SettingsDialog::PopulateListWidget()
{ {
for (int i = 0;i < mTempApplications.GetApplicationCount();i++) for (int i = 0; i < mTempApplications.GetApplicationCount(); i++)
{ {
mListWidget->addItem(mTempApplications.GetApplicationName(i)); mListWidget->addItem(mTempApplications.GetApplicationName(i));
} }
// If list contains items select first item
if (mTempApplications.GetApplicationCount())
{
mListWidget->setCurrentRow(0);
}
} }
void SettingsDialog::Ok() void SettingsDialog::Ok()

View File

@ -41,7 +41,7 @@ class SettingsDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
SettingsDialog(QSettings &programSettings, ApplicationList &list); SettingsDialog(QSettings &programSettings, ApplicationList &list, QWidget *parent = 0);
virtual ~SettingsDialog(); virtual ~SettingsDialog();
/** /**

View File

@ -24,6 +24,7 @@
#include "errorlogger.h" #include "errorlogger.h"
#include <list> #include <list>
#include <iostream>
class Check class Check
{ {
@ -78,6 +79,13 @@ protected:
/** report an error */ /** report an error */
void reportError(const std::list<const Token *> &callstack, const std::string &severity, const std::string &id, const std::string &msg) 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; std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
for (std::list<const Token *>::const_iterator it = callstack.begin(); it != callstack.end(); ++it) for (std::list<const Token *>::const_iterator it = callstack.begin(); it != callstack.end(); ++it)
{ {

View File

@ -191,17 +191,17 @@ void CheckAutoVariables::autoVariables()
continue; continue;
addVD(tok->tokAt(2)); 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, reportError(tok,
"error", "error",
"autoVariables", "autoVariables",
"Wrong assignement of an auto-variable to an effective parameter of a function"); "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, reportError(tok,
"error", "error",
"autoVariables", "autoVariables",

View File

@ -56,6 +56,7 @@ private:
void getErrorMessages() void getErrorMessages()
{ {
std::cout << "===auto variables===" << "\n";
reportError(0, "error", "autoVariables", "Wrong assignement of an auto-variable to an effective parameter of a function"); reportError(0, "error", "autoVariables", "Wrong assignement of an auto-variable to an effective parameter of a function");
} }
}; };

View File

@ -75,6 +75,7 @@ private:
void getErrorMessages() void getErrorMessages()
{ {
std::cout << "===buffer overruns===" << "\n";
arrayIndexOutOfBounds(0); arrayIndexOutOfBounds(0);
bufferOverrun(0); bufferOverrun(0);
strncatUsage(0); strncatUsage(0);

View File

@ -82,6 +82,10 @@ struct CheckClass::VAR *CheckClass::ClassChecking_GetVarList(const Token *tok1,
if (next->str() == "static") if (next->str() == "static")
continue; continue;
// Type definitions shall be ignored..
if (next->str() == "typedef")
continue;
// Is it a variable declaration? // Is it a variable declaration?
if (Token::Match(next, "%type% %var% ;")) if (Token::Match(next, "%type% %var% ;"))
{ {

View File

@ -109,6 +109,7 @@ private:
void getErrorMessages() void getErrorMessages()
{ {
std::cout << "===classes===" << "\n";
noConstructorError(0, "classname"); noConstructorError(0, "classname");
uninitVarError(0, "classname", "varname"); uninitVarError(0, "classname", "varname");
operatorEqVarError(0, "classname", ""); operatorEqVarError(0, "classname", "");

View File

@ -56,6 +56,7 @@ private:
void getErrorMessages() void getErrorMessages()
{ {
std::cout << "===dangerous functions===" << "\n";
dangerousFunctionmktemp(0); dangerousFunctionmktemp(0);
dangerousFunctiongets(0); dangerousFunctiongets(0);
dangerousFunctionscanf(0); dangerousFunctionscanf(0);

File diff suppressed because it is too large Load Diff

View File

@ -19,11 +19,17 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#ifndef CheckMemoryLeakH #ifndef checkmemoryleakH
#define 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" #include "check.h"
@ -33,62 +39,85 @@
class Token; 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: 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) : Check(tokenizer, settings, errorLogger)
{ } { }
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
{ {
CheckMemoryLeakClass checkMemoryLeakClass(tokenizer, settings, errorLogger); CheckMemoryLeakInFunction checkMemoryLeak(tokenizer, settings, errorLogger);
checkMemoryLeakClass.CheckMemoryLeak(); checkMemoryLeak.check();
} }
#ifndef UNIT_TESTING
void CheckMemoryLeak(); private:
#endif
void check();
private: private:
/** What type of allocation are used.. the "Many" means that several types of allocation and deallocation are used */ bool MatchFunctionsThatReturnArg(const Token *tok, const std::string &varname);
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);
/** /**
* Simplify code e.g. by replacing empty "{ }" with ";" * Check if there is a "!var" match inside a condition
* @param tok first token. The tokens list can be modified. * @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 const char * call_func(const Token *tok, std::list<const Token *> callstack, const char *varnames[], AllocType &alloctype, AllocType &dealloctype, bool &all, unsigned int sz);
* 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);
/** /**
* Extract a new tokens list that is easier to parse than the "tokens" * Extract a new tokens list that is easier to parse than the "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); 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 * Simplify code e.g. by replacing empty "{ }" with ";"
* @param tok first token to match * @param tok first token. The tokens list can be modified.
* @param varnames the varname
* @param endpar if this is true the "!var" must be followed by ")"
* @return true if match
*/ */
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 checkScope(const Token *Tok1, const char varname[], bool classmember, unsigned int sz);
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);
std::list<AllocFunc> _listAllocFunc; void error(const Token *tok, const std::string &severity, const std::string &id, const std::string &msg)
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()
{ {
memleakError(0, "varname"); reportError(tok, severity, id, msg);
memleakallError(0, "varname");
resourceLeakError(0, "varname");
deallocDeallocError(0, "varname");
deallocuseError(0, "varname");
mismatchSizeError(0, "sz");
std::list<const Token *> callstack;
mismatchAllocDealloc(callstack, "varname");
} }
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 #endif

View File

@ -147,6 +147,7 @@ private:
void getErrorMessages() void getErrorMessages()
{ {
std::cout << "===other===" << "\n";
cstyleCastError(0); cstyleCastError(0);
redundantIfDelete0Error(0); redundantIfDelete0Error(0);
redundantIfRemoveError(0); redundantIfRemoveError(0);

View File

@ -54,6 +54,7 @@ private:
void getErrorMessages() void getErrorMessages()
{ {
std::cout << "===security===" << "\n";
unvalidatedInput(0); unvalidatedInput(0);
} }
}; };

View File

@ -98,6 +98,7 @@ private:
void getErrorMessages() void getErrorMessages()
{ {
std::cout << "===stl===" << "\n";
iteratorsError(0, "container1", "container2"); iteratorsError(0, "container1", "container2");
dereferenceErasedError(0, "iter"); dereferenceErasedError(0, "iter");
stlOutOfBoundsError(0, "i", "foo"); stlOutOfBoundsError(0, "i", "foo");

View File

@ -18,7 +18,7 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#include "checkfunctionusage.h" #include "checkunusedfunctions.h"
#include "tokenize.h" #include "tokenize.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -29,22 +29,22 @@
// FUNCTION USAGE - Check for unused functions etc // FUNCTION USAGE - Check for unused functions etc
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
CheckFunctionUsage::CheckFunctionUsage(ErrorLogger *errorLogger) CheckUnusedFunctions::CheckUnusedFunctions(ErrorLogger *errorLogger)
{ {
_errorLogger = errorLogger; _errorLogger = errorLogger;
} }
CheckFunctionUsage::~CheckFunctionUsage() CheckUnusedFunctions::~CheckUnusedFunctions()
{ {
} }
void CheckFunctionUsage::setErrorLogger(ErrorLogger *errorLogger) void CheckUnusedFunctions::setErrorLogger(ErrorLogger *errorLogger)
{ {
_errorLogger = errorLogger; _errorLogger = errorLogger;
} }
void CheckFunctionUsage::parseTokens(const Tokenizer &tokenizer) void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer)
{ {
// Function declarations.. // Function declarations..
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) 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 (Token::Match(tok->next(), "%var% ("))
{ {
if (tok->str() == "*" || (tok->isName() && !Token::Match(tok, "else|return")))
continue;
funcname = tok->next(); funcname = tok->next();
} }
if (Token::Match(tok, "[;{}.,()[=+-/&|!?:] %var% [(),;:}]")) else if (Token::Match(tok, "[;{}.,()[=+-/&|!?:] %var% [(),;:}]"))
funcname = tok->next(); funcname = tok->next();
if (Token::Match(tok, "[(,] & %var% :: %var% [,)]")) else if (Token::Match(tok, "[(,] & %var% :: %var% [,)]"))
funcname = tok->tokAt(4); funcname = tok->tokAt(4);
else
continue;
// funcname ( => Assert that the end paranthesis isn't followed by { // funcname ( => Assert that the end paranthesis isn't followed by {
if (Token::Match(funcname, "%var% (")) 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) for (std::map<std::string, FunctionUsage>::const_iterator it = _functions.begin(); it != _functions.end(); ++it)
{ {

View File

@ -18,18 +18,18 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#ifndef CheckFunctionUsageH #ifndef checkunusedfunctionsH
#define CheckFunctionUsageH #define checkunusedfunctionsH
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#include "tokenize.h" #include "tokenize.h"
#include "errorlogger.h" #include "errorlogger.h"
class CheckFunctionUsage class CheckUnusedFunctions
{ {
public: public:
CheckFunctionUsage(ErrorLogger *errorLogger = 0); CheckUnusedFunctions(ErrorLogger *errorLogger = 0);
~CheckFunctionUsage(); ~CheckUnusedFunctions();
/** /**
* Errors found by this class are forwarded to the given * Errors found by this class are forwarded to the given

View File

@ -20,7 +20,6 @@
#include "preprocessor.h" // preprocessor. #include "preprocessor.h" // preprocessor.
#include "tokenize.h" // <- Tokenizer #include "tokenize.h" // <- Tokenizer
#include "checkfunctionusage.h"
#include "filelister.h" #include "filelister.h"
#include "check.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++) for (int i = 1; i < argc; i++)
{ {
if (strcmp(argv[i], "--version") == 0) if (strcmp(argv[i], "--version") == 0)
return "Cppcheck 1.32\n"; return "Cppcheck 1.33\n";
// Flag used for various purposes during debugging // Flag used for various purposes during debugging
if (strcmp(argv[i], "--debug") == 0) if (strcmp(argv[i], "--debug") == 0)
@ -207,6 +206,16 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
_settings.autoDealloc(f); _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) else if (strncmp(argv[i], "-", 1) == 0 || strncmp(argv[i], "--", 2) == 0)
{ {
return "cppcheck: error: unrecognized command line option \"" + std::string(argv[i]) + "\"\n"; 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() unsigned int CppCheck::check()
{ {
_checkFunctionUsage.setErrorLogger(this); _checkUnusedFunctions.setErrorLogger(this);
std::sort(_filenames.begin(), _filenames.end()); std::sort(_filenames.begin(), _filenames.end());
for (unsigned int c = 0; c < _filenames.size(); c++) for (unsigned int c = 0; c < _filenames.size(); c++)
{ {
@ -357,7 +366,7 @@ unsigned int CppCheck::check()
if (_settings._errorsOnly == false) if (_settings._errorsOnly == false)
_errorLogger->reportOut("Checking usage of global functions.."); _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(); _tokenizer.simplifyTokenList();
if (_settings._unusedFunctions) if (_settings._unusedFunctions)
_checkFunctionUsage.parseTokens(_tokenizer); _checkUnusedFunctions.parseTokens(_tokenizer);
// call all "runSimplifiedChecks" in all registered Check classes // call all "runSimplifiedChecks" in all registered Check classes
for (std::list<Check *>::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it) for (std::list<Check *>::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it)

View File

@ -26,7 +26,7 @@
#include <map> #include <map>
#include "settings.h" #include "settings.h"
#include "errorlogger.h" #include "errorlogger.h"
#include "checkfunctionusage.h" #include "checkunusedfunctions.h"
/** /**
* This is the base class which will use other classes to do * This is the base class which will use other classes to do
@ -135,7 +135,7 @@ private:
std::vector<std::string> _filenames; std::vector<std::string> _filenames;
/** Key is file name, and value is the content of the file */ /** Key is file name, and value is the content of the file */
std::map<std::string, std::string> _fileContents; std::map<std::string, std::string> _fileContents;
CheckFunctionUsage _checkFunctionUsage; CheckUnusedFunctions _checkUnusedFunctions;
ErrorLogger *_errorLogger; ErrorLogger *_errorLogger;
/** Current configuration */ /** Current configuration */

View File

@ -1150,6 +1150,12 @@ std::string Preprocessor::expandMacros(std::string code, const std::string &file
++pos2; ++pos2;
while (pos2 < code.length() && code[pos2] != ch) while (pos2 < code.length() && code[pos2] != ch)
{ {
if (code[pos2] == '\\')
{
par += code[pos2];
++pos2;
}
par += code[pos2]; par += code[pos2];
++pos2; ++pos2;
} }

View File

@ -473,6 +473,9 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[])
} }
} }
// replace "unsigned i" with "unsigned int i"
unsignedint();
simplifyVarDecl(); simplifyVarDecl();
// Handle templates.. // 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% )")) else if (Token::Match(tok, "sizeof ( %type% )"))
{ {
const char *type = tok->strAt(2); const char *type = tok->strAt(2);
@ -1459,6 +1468,7 @@ void Tokenizer::simplifyTokenList()
modified |= removeReduntantConditions(); modified |= removeReduntantConditions();
modified |= simplifyRedundantParanthesis(); modified |= simplifyRedundantParanthesis();
modified |= simplifyCalculations(); modified |= simplifyCalculations();
modified |= simplifyQuestionMark();
} }
createLinks(); createLinks();
@ -1834,6 +1844,51 @@ bool Tokenizer::simplifyConditions()
return ret; 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() 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 Tokenizer::simplifyIfAssign()
{ {
bool ret = false; bool ret = false;

View File

@ -100,6 +100,17 @@ public:
*/ */
bool simplifyVarDecl(); 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.. * simplify if-assignments..

View File

@ -75,6 +75,13 @@ private:
" int num=2;" " int num=2;"
"res=&num;}"); "res=&num;}");
ASSERT_EQUALS("[test.cpp:3]: (error) Wrong assignement of an auto-variable to an effective parameter of a function\n", errout.str()); 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 = &num;\n"
"}");
ASSERT_EQUALS("", errout.str());
} }
void testautovararray() void testautovararray()
{ {

View File

@ -68,6 +68,7 @@ private:
TEST_CASE(sizeof1); TEST_CASE(sizeof1);
TEST_CASE(sizeof2); TEST_CASE(sizeof2);
TEST_CASE(sizeof3);
TEST_CASE(array_index_1); TEST_CASE(array_index_1);
TEST_CASE(array_index_2); TEST_CASE(array_index_2);
@ -123,7 +124,7 @@ private:
" char str[50];\n" " char str[50];\n"
" }\n" " }\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -145,7 +146,7 @@ private:
"{\n" "{\n"
" strcpy(buf, str);\n" " strcpy(buf, str);\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -156,7 +157,7 @@ private:
" char data[1];\n" " char data[1];\n"
" return abc.data[1];\n" " return abc.data[1];\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -168,7 +169,7 @@ private:
" char data[100];\n" " char data[100];\n"
" const char *p = &data[100];\n" " const char *p = &data[100];\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -181,7 +182,7 @@ private:
" char data[10];\n" " char data[10];\n"
" data[ sizeof(*data) ] = 0;\n" " data[ sizeof(*data) ] = 0;\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void sizeof2() void sizeof2()
@ -191,7 +192,7 @@ private:
" char data[10];\n" " char data[10];\n"
" data[ sizeof(data[0]) ] = 0;\n" " data[ sizeof(data[0]) ] = 0;\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
check("static void f()\n" check("static void f()\n"
"{\n" "{\n"
@ -201,8 +202,17 @@ private:
ASSERT_EQUALS("[test.cpp:4]: (all) Array index out of bounds\n", errout.str()); 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() void array_index_1()
{ {
@ -500,7 +510,7 @@ private:
" char str[5];\n" " char str[5];\n"
" snprintf(str, 5, \"%s\", \"abc\");\n" " snprintf(str, 5, \"%s\", \"abc\");\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void snprintf3() void snprintf3()
@ -510,7 +520,7 @@ private:
" char str[5];\n" " char str[5];\n"
" snprintf(str, sizeof str, \"%s\", \"abc\");\n" " snprintf(str, sizeof str, \"%s\", \"abc\");\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void snprintf4() void snprintf4()
@ -520,7 +530,7 @@ private:
" char str[5];\n" " char str[5];\n"
" snprintf(str, 8 - x, \"abcdefghijkl\");\n" " snprintf(str, 8 - x, \"abcdefghijkl\");\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -572,7 +582,7 @@ private:
" str[30] = 0;\n" " str[30] = 0;\n"
" }\n" " }\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -587,7 +597,7 @@ private:
" memset(str,0,50);\n" " memset(str,0,50);\n"
" }\n" " }\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void assign1() void assign1()

View File

@ -65,7 +65,7 @@ private:
" unsigned char ch = 0x80;\n" " unsigned char ch = 0x80;\n"
" buf[ch] = 0;\n" " buf[ch] = 0;\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
check("void foo()\n" check("void foo()\n"
"{\n" "{\n"
@ -106,7 +106,7 @@ private:
" char ch;\n" " char ch;\n"
" func(&ch);\n" " func(&ch);\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void return1() void return1()
@ -116,7 +116,7 @@ private:
" char c;\n" " char c;\n"
" return &c;\n" " return &c;\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
}; };

View File

@ -45,6 +45,7 @@ private:
TEST_CASE(uninitVar1); TEST_CASE(uninitVar1);
TEST_CASE(uninitVarEnum); TEST_CASE(uninitVarEnum);
TEST_CASE(uninitVarStream); TEST_CASE(uninitVarStream);
TEST_CASE(uninitVarTypedef);
TEST_CASE(privateCtor1); // If constructor is private.. TEST_CASE(privateCtor1); // If constructor is private..
TEST_CASE(privateCtor2); // If constructor is private.. TEST_CASE(privateCtor2); // If constructor is private..
TEST_CASE(function); // Function is not variable TEST_CASE(function); // Function is not variable
@ -80,10 +81,10 @@ private:
// Base class not found // Base class not found
checkVirtualDestructor("class Derived : public Base { };"); checkVirtualDestructor("class Derived : public Base { };");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
checkVirtualDestructor("class Derived : Base { };"); checkVirtualDestructor("class Derived : Base { };");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void virtualDestructor2() void virtualDestructor2()
@ -96,7 +97,7 @@ private:
checkVirtualDestructor("class Base { };\n" checkVirtualDestructor("class Base { };\n"
"class Derived : Base { public: ~Derived() { (void)11; } };"); "class Derived : Base { public: ~Derived() { (void)11; } };");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void virtualDestructor3() void virtualDestructor3()
@ -118,11 +119,11 @@ private:
checkVirtualDestructor("class Base { public: ~Base(); };\n" checkVirtualDestructor("class Base { public: ~Base(); };\n"
"class Derived : public Base { };"); "class Derived : public Base { };");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
checkVirtualDestructor("class Base { public: ~Base(); };\n" checkVirtualDestructor("class Base { public: ~Base(); };\n"
"class Derived : private Fred, public Base { };"); "class Derived : private Fred, public Base { };");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void virtualDestructor5() void virtualDestructor5()
@ -131,11 +132,11 @@ private:
checkVirtualDestructor("class Base { public: ~Base(); };\n" checkVirtualDestructor("class Base { public: ~Base(); };\n"
"class Derived : public Base { public: ~Derived() {} };"); "class Derived : public Base { public: ~Derived() {} };");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
checkVirtualDestructor("class Base { public: ~Base(); };\n" checkVirtualDestructor("class Base { public: ~Base(); };\n"
"class Derived : public Base { public: ~Derived(); }; Derived::~Derived() {}"); "class Derived : public Base { public: ~Derived(); }; Derived::~Derived() {}");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void virtualDestructorProtected() void virtualDestructorProtected()
@ -153,7 +154,7 @@ private:
"public:\n" "public:\n"
" ~B() { int a; }\n" " ~B() { int a; }\n"
"};\n"); "};\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void checkUninitVar(const char code[]) void checkUninitVar(const char code[])
@ -222,9 +223,21 @@ private:
" }\n" " }\n"
"};\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() void privateCtor1()
{ {
@ -233,7 +246,7 @@ private:
" Foo() { }\n" " Foo() { }\n"
"};\n"); "};\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void privateCtor2() void privateCtor2()
@ -269,7 +282,7 @@ private:
" return p;\n" " return p;\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }

View File

@ -146,7 +146,7 @@ private:
" { this->i = 0; }\n" " { this->i = 0; }\n"
" int i;\n" " int i;\n"
"};\n"); "};\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void initvar_if() void initvar_if()
@ -163,7 +163,7 @@ private:
" }\n" " }\n"
" int i;\n" " int i;\n"
"};\n"); "};\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void initvar_operator_eq1() void initvar_operator_eq1()
@ -187,7 +187,7 @@ private:
"};\n"); "};\n");
std::string err(errout.str()); std::string err(errout.str());
ASSERT_EQUALS(std::string(""), err); ASSERT_EQUALS("", err);
} }
@ -214,7 +214,7 @@ private:
" Init() { i = 0; }\n" " Init() { i = 0; }\n"
" int i;\n" " int i;\n"
"};\n"); "};\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void initvar_same_classname() void initvar_same_classname()
@ -240,7 +240,7 @@ private:
"}\n"); "}\n");
std::string err(errout.str()); std::string err(errout.str());
ASSERT_EQUALS(std::string(""), err); ASSERT_EQUALS("", err);
} }
void initvar_chained_assign() void initvar_chained_assign()
@ -261,7 +261,7 @@ private:
"}\n"); "}\n");
std::string err(errout.str()); std::string err(errout.str());
ASSERT_EQUALS(std::string(""), err); ASSERT_EQUALS("", err);
} }
@ -296,7 +296,7 @@ private:
"}\n"); "}\n");
std::string err(errout.str()); std::string err(errout.str());
ASSERT_EQUALS(std::string(""), err); ASSERT_EQUALS("", err);
} }
@ -337,7 +337,7 @@ private:
"};\n" "};\n"
"Fred::Fred()\n" "Fred::Fred()\n"
"{ }"); "{ }");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void initvar_destructor() void initvar_destructor()
@ -350,7 +350,7 @@ private:
" Fred() : var(0) {}\n" " Fred() : var(0) {}\n"
" ~Fred() {}\n" " ~Fred() {}\n"
"};\n"); "};\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void operatorEqSTL() void operatorEqSTL()

View File

@ -113,7 +113,7 @@ private:
" unsigned int i2;\n" " unsigned int i2;\n"
" result = i2 / i1;}\n" " result = i2 / i1;}\n"
); );
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void division5() void division5()
@ -124,7 +124,7 @@ private:
" unsigned int val = 32;\n" " unsigned int val = 32;\n"
" val = val / USER_HASH;}\n" " val = val / USER_HASH;}\n"
); );
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void division6() void division6()

View File

@ -80,7 +80,7 @@ private:
"#endif\n" "#endif\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void test2() void test2()
@ -100,7 +100,7 @@ private:
" const char *str[] = { \"abc\" };\n" " const char *str[] = { \"abc\" };\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void test4() void test4()
@ -115,7 +115,7 @@ private:
"};\n" "};\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void test5() void test5()
@ -143,13 +143,13 @@ private:
"};\n" "};\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void intarray() void intarray()
{ {
check("int arr[] = { 100/2, 1*100 };\n"); check("int arr[] = { 100/2, 1*100 };\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void structarraynull() void structarraynull()
@ -158,7 +158,7 @@ private:
" { 100/2, 1*100 }\n" " { 100/2, 1*100 }\n"
" { 90, 70 }\n" " { 90, 70 }\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void structarray() void structarray()
@ -167,7 +167,7 @@ private:
" { 100/2, 1*100 }\n" " { 100/2, 1*100 }\n"
" { 90, 70 }\n" " { 90, 70 }\n"
"};\n"); "};\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
}; };

File diff suppressed because it is too large Load Diff

View File

@ -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)

View File

@ -110,11 +110,15 @@ private:
" }\n" " }\n"
" cout<<b/sum;\n" " cout<<b/sum;\n"
"}\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() void delete1()
{ {
check("void foo()\n" check("void foo()\n"
@ -125,7 +129,7 @@ private:
" p = 0;\n" " p = 0;\n"
" }\n" " }\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void delete2() void delete2()
@ -172,7 +176,7 @@ private:
" break;\n" " break;\n"
" }\n" " }\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -213,7 +217,7 @@ private:
" char buf[100];\n" " char buf[100];\n"
" sprintf(buf,\"%i\",sizeof(buf));\n" " sprintf(buf,\"%i\",sizeof(buf));\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void sprintf3() void sprintf3()
@ -224,7 +228,7 @@ private:
" sprintf(buf,\"%i\",sizeof(buf));\n" " sprintf(buf,\"%i\",sizeof(buf));\n"
" if (buf[0]);\n" " if (buf[0]);\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void sprintf4() void sprintf4()
@ -240,7 +244,7 @@ private:
" struct A a;\n" " struct A a;\n"
" snprintf(a.filename, 128, \"%s\", filename);\n" " snprintf(a.filename, 128, \"%s\", filename);\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -293,7 +297,7 @@ private:
" std::string temp = \"/tmp\";\n" " std::string temp = \"/tmp\";\n"
" std::string path = temp + '/' + \"sub\" + '/';\n" " std::string path = temp + '/' + \"sub\" + '/';\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -332,7 +336,7 @@ private:
" char str[100] = {0};\n" " char str[100] = {0};\n"
" return str;\n" " return str;\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void varScope(const char code[]) void varScope(const char code[])
@ -381,7 +385,7 @@ private:
"\n" "\n"
" return 1;\n" " return 1;\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void varScope2() void varScope2()
@ -392,7 +396,7 @@ private:
" e.SetValue(12);\n" " e.SetValue(12);\n"
" throw e;\n" " throw e;\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void varScope3() void varScope3()
@ -407,7 +411,7 @@ private:
" }\n" " }\n"
" *p = 1;\n" " *p = 1;\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -451,7 +455,7 @@ private:
" while (fred);\n" " while (fred);\n"
" fred.hello();\n" " fred.hello();\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
}; };

View File

@ -103,6 +103,7 @@ private:
TEST_CASE(macro_simple6); TEST_CASE(macro_simple6);
TEST_CASE(macro_simple7); TEST_CASE(macro_simple7);
TEST_CASE(macro_simple8); TEST_CASE(macro_simple8);
TEST_CASE(macro_simple9);
TEST_CASE(macro_mismatch); TEST_CASE(macro_mismatch);
TEST_CASE(macro_linenumbers); TEST_CASE(macro_linenumbers);
TEST_CASE(string1); TEST_CASE(string1);
@ -665,6 +666,14 @@ private:
ASSERT_EQUALS("\n\n123 1234", OurPreprocessor::expandMacros(filedata)); 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() void macro_mismatch()
{ {
const char filedata[] = "#define AAA(aa,bb) f(aa)\n" const char filedata[] = "#define AAA(aa,bb) f(aa)\n"

View File

@ -158,7 +158,7 @@ private:
" foo[ii] = 0;\n" " foo[ii] = 0;\n"
" }\n" " }\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
{ {
@ -169,7 +169,7 @@ private:
" {\n" " {\n"
" }\n" " }\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
{ {
@ -187,7 +187,7 @@ private:
" }\n" " }\n"
" }\n" " }\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
} }

View File

@ -145,6 +145,9 @@ private:
TEST_CASE(syntax_error); TEST_CASE(syntax_error);
TEST_CASE(removeKeywords); TEST_CASE(removeKeywords);
// unsigned i; => unsigned int i;
TEST_CASE(unsigned1);
} }
@ -1987,7 +1990,7 @@ private:
Tokenizer tokenizer(s, this); Tokenizer tokenizer(s, this);
std::istringstream istr(code); std::istringstream istr(code);
ASSERT_EQUALS(true, tokenizer.tokenize(istr, "test.cpp")); 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); std::istringstream istr(code);
ASSERT_EQUALS(true, tokenizer.tokenize(istr, "test.cpp")); ASSERT_EQUALS(true, tokenizer.tokenize(istr, "test.cpp"));
tokenizer.simplifyTokenList(); tokenizer.simplifyTokenList();
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
} }
@ -2028,6 +2031,28 @@ private:
ASSERT_EQUALS("if ( ! ! x ) { ; }", actual); 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) REGISTER_TEST(TestTokenizer)

View File

@ -19,15 +19,15 @@
#include "../src/tokenize.h" #include "../src/tokenize.h"
#include "testsuite.h" #include "testsuite.h"
#include "../src/checkfunctionusage.h" #include "../src/checkunusedfunctions.h"
#include <sstream> #include <sstream>
extern std::ostringstream errout; extern std::ostringstream errout;
class TestFunctionUsage : public TestFixture class TestUnusedFunctions : public TestFixture
{ {
public: public:
TestFunctionUsage() : TestFixture("TestFunctionUsage") TestUnusedFunctions() : TestFixture("TestUnusedFunctions")
{ } { }
private: private:
@ -37,6 +37,7 @@ private:
{ {
TEST_CASE(incondition); TEST_CASE(incondition);
TEST_CASE(return1); TEST_CASE(return1);
TEST_CASE(return2);
TEST_CASE(callback1); TEST_CASE(callback1);
TEST_CASE(else1); TEST_CASE(else1);
TEST_CASE(functionpointer); TEST_CASE(functionpointer);
@ -53,9 +54,9 @@ private:
errout.str(""); errout.str("");
// Check for unused functions.. // Check for unused functions..
CheckFunctionUsage checkFunctionUsage(this); CheckUnusedFunctions checkUnusedFunctions(this);
checkFunctionUsage.parseTokens(tokenizer); checkUnusedFunctions.parseTokens(tokenizer);
checkFunctionUsage.check(); checkUnusedFunctions.check();
} }
void incondition() void incondition()
@ -65,8 +66,7 @@ private:
" if (f1())\n" " if (f1())\n"
" { }\n" " { }\n"
"}\n"); "}\n");
std::string err(errout.str()); ASSERT_EQUALS("", errout.str());
ASSERT_EQUALS(std::string(""), errout.str());
} }
void return1() void return1()
@ -75,8 +75,16 @@ private:
"{\n" "{\n"
" return f1();\n" " return f1();\n"
"}\n"); "}\n");
std::string err(errout.str()); ASSERT_EQUALS("", errout.str());
ASSERT_EQUALS(std::string(""), errout.str()); }
void return2()
{
check("char * foo()\n"
"{\n"
" return *foo();\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }
void callback1() void callback1()
@ -85,8 +93,7 @@ private:
"{\n" "{\n"
" void (*f)() = cond ? f1 : NULL;\n" " void (*f)() = cond ? f1 : NULL;\n"
"}\n"); "}\n");
std::string err(errout.str()); ASSERT_EQUALS("", errout.str());
ASSERT_EQUALS(std::string(""), errout.str());
} }
void else1() void else1()
@ -96,8 +103,7 @@ private:
" if (cond) ;\n" " if (cond) ;\n"
" else f1();\n" " else f1();\n"
"}\n"); "}\n");
std::string err(errout.str()); ASSERT_EQUALS("", errout.str());
ASSERT_EQUALS(std::string(""), errout.str());
} }
void functionpointer() void functionpointer()
@ -111,9 +117,9 @@ private:
" f(&abc::foo);\n" " f(&abc::foo);\n"
" return 0\n" " return 0\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
}; };
REGISTER_TEST(TestFunctionUsage) REGISTER_TEST(TestUnusedFunctions)

View File

@ -100,7 +100,7 @@ private:
"\n" "\n"
"A::A()\n" "A::A()\n"
"{ }\n"); "{ }\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -116,7 +116,7 @@ private:
"\n" "\n"
"A::~A()\n" "A::~A()\n"
"{ B(); }\n"); "{ B(); }\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -132,7 +132,7 @@ private:
"\n" "\n"
"A::A() : _owner(false)\n" "A::A() : _owner(false)\n"
"{ b(); }\n"); "{ b(); }\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -180,7 +180,7 @@ private:
" int numOfThreads;\n" " int numOfThreads;\n"
"};\n"); "};\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }

View File

@ -89,7 +89,7 @@ private:
" int b = abc.b;\n" " int b = abc.b;\n"
" int c = abc.c;\n" " int c = abc.c;\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
void structmember3() void structmember3()
@ -109,7 +109,7 @@ private:
" int b = abc[0].b;\n" " int b = abc[0].b;\n"
" int c = abc[0].c;\n" " int c = abc[0].c;\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -125,7 +125,7 @@ private:
" ABC abc;\n" " ABC abc;\n"
" if (abc.a == 2);\n" " if (abc.a == 2);\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
@ -147,7 +147,7 @@ private:
" struct AB ab;\n" " struct AB ab;\n"
" ab.reset();\n" " ab.reset();\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS("", errout.str());
} }
}; };

View File

@ -19,7 +19,7 @@
#define MyAppName "cppcheck" #define MyAppName "cppcheck"
#define AppVersion "1.32" #define AppVersion "1.33"
#define MyAppURL "http://cppcheck.wiki.sourceforge.net/" #define MyAppURL "http://cppcheck.wiki.sourceforge.net/"
#define MyAppExeName "cppcheck.exe" #define MyAppExeName "cppcheck.exe"
#define QTGuiExe "gui.exe" #define QTGuiExe "gui.exe"

View File

@ -1,11 +1,12 @@
Windows installer for the cppcheck Windows installer for the cppcheck
---------------------------------- ----------------------------------
Simple Windows installer installing executable, license file and readme.txt to Windows installer for both command line cppcheck and for QT-based GUI. All
program files/cppcheck folder. needed runtimes and libraries are installed.
Shortcuts are created to start cmd.exe in installation folder. So when the user Command line cppccheck shortcuts are created to start cmd.exe in installation
selects start menu/desktop icon he gets command prompt in cppcheck folder. folder. So when the user selects start menu/desktop icon he gets command prompt
in cppcheck folder.
Get the InnoSetup from: Get the InnoSetup from:
http://www.innosetup.com/ 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. like ISTool and preprocessor support.
Files the installer needs: Files the installer needs:
/Release/cppcheck.exe
/COPYING /COPYING
/readme.txt /readme.txt
/AUTHORS /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 NOTE: Remember to convert COPYING and AUTHORS to Windows EOL format! Otherwise
Windows Notepad (default viewer) can't show then properly. 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 folder where files are. You can find runtime files from VS installation or from
net. 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: Creating the installer executable:
#1 Open the ISTool and load cppcheck.iss #1 Open the ISTool and load cppcheck.iss
#2 Update the release version number: #2 Update the release version number: