Skip to content

Commit 37bc048

Browse files
authored
made check.h less heavy (danmar#2633)
1 parent 0832830 commit 37bc048

91 files changed

Lines changed: 855 additions & 765 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 118 additions & 114 deletions
Large diffs are not rendered by default.

cli/cppcheckexecutor.cpp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <cstring>
4141
#include <iostream>
4242
#include <list>
43+
#include <memory>
4344
#include <utility>
4445
#include <vector>
4546

@@ -106,9 +107,9 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
106107

107108
if (parser.getShowErrorMessages()) {
108109
mShowAllErrors = true;
109-
std::cout << ErrorLogger::ErrorMessage::getXMLHeader();
110+
std::cout << ErrorMessage::getXMLHeader();
110111
cppcheck->getErrorMessages();
111-
std::cout << ErrorLogger::ErrorMessage::getXMLFooter() << std::endl;
112+
std::cout << ErrorMessage::getXMLFooter() << std::endl;
112113
}
113114

114115
if (parser.exitAfterPrinting()) {
@@ -851,8 +852,8 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
851852
for (const std::string &lib : settings.libraries) {
852853
if (!tryLoadLibrary(settings.library, argv[0], lib.c_str())) {
853854
const std::string msg("Failed to load the library " + lib);
854-
const std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;
855-
ErrorLogger::ErrorMessage errmsg(callstack, emptyString, Severity::information, msg, "failedToLoadCfg", false);
855+
const std::list<ErrorMessage::FileLocation> callstack;
856+
ErrorMessage errmsg(callstack, emptyString, Severity::information, msg, "failedToLoadCfg", false);
856857
reportErr(errmsg);
857858
return EXIT_FAILURE;
858859
}
@@ -866,7 +867,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
866867
windows = tryLoadLibrary(settings.library, argv[0], "windows.cfg");
867868

868869
if (!std || !posix || !windows) {
869-
const std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;
870+
const std::list<ErrorMessage::FileLocation> callstack;
870871
const std::string msg("Failed to load " + std::string(!std ? "std.cfg" : !posix ? "posix.cfg" : "windows.cfg") + ". Your Cppcheck installation is broken, please re-install.");
871872
#ifdef FILESDIR
872873
const std::string details("The Cppcheck binary was compiled with FILESDIR set to \""
@@ -878,7 +879,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
878879
"std.cfg should be available in " + cfgfolder + " or the FILESDIR "
879880
"should be configured.");
880881
#endif
881-
ErrorLogger::ErrorMessage errmsg(callstack, emptyString, Severity::information, msg+" "+details, "failedToLoadCfg", false);
882+
ErrorMessage errmsg(callstack, emptyString, Severity::information, msg+" "+details, "failedToLoadCfg", false);
882883
reportErr(errmsg);
883884
return EXIT_FAILURE;
884885
}
@@ -891,7 +892,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
891892
}
892893

893894
if (settings.xml) {
894-
reportErr(ErrorLogger::ErrorMessage::getXMLHeader());
895+
reportErr(ErrorMessage::getXMLHeader());
895896
}
896897

897898
if (!settings.buildDir.empty()) {
@@ -980,24 +981,24 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
980981
cppcheck.tooManyConfigsError("",0U);
981982

982983
if (settings.isEnabled(Settings::MISSING_INCLUDE) && (Preprocessor::missingIncludeFlag || Preprocessor::missingSystemIncludeFlag)) {
983-
const std::list<ErrorLogger::ErrorMessage::FileLocation> callStack;
984-
ErrorLogger::ErrorMessage msg(callStack,
985-
emptyString,
986-
Severity::information,
987-
"Cppcheck cannot find all the include files (use --check-config for details)\n"
988-
"Cppcheck cannot find all the include files. Cppcheck can check the code without the "
989-
"include files found. But the results will probably be more accurate if all the include "
990-
"files are found. Please check your project's include directories and add all of them "
991-
"as include directories for Cppcheck. To see what files Cppcheck cannot find use "
992-
"--check-config.",
993-
Preprocessor::missingIncludeFlag ? "missingInclude" : "missingIncludeSystem",
994-
false);
984+
const std::list<ErrorMessage::FileLocation> callStack;
985+
ErrorMessage msg(callStack,
986+
emptyString,
987+
Severity::information,
988+
"Cppcheck cannot find all the include files (use --check-config for details)\n"
989+
"Cppcheck cannot find all the include files. Cppcheck can check the code without the "
990+
"include files found. But the results will probably be more accurate if all the include "
991+
"files are found. Please check your project's include directories and add all of them "
992+
"as include directories for Cppcheck. To see what files Cppcheck cannot find use "
993+
"--check-config.",
994+
Preprocessor::missingIncludeFlag ? "missingInclude" : "missingIncludeSystem",
995+
false);
995996
reportInfo(msg);
996997
}
997998
}
998999

9991000
if (settings.xml) {
1000-
reportErr(ErrorLogger::ErrorMessage::getXMLFooter());
1001+
reportErr(ErrorMessage::getXMLFooter());
10011002
}
10021003

10031004
mSettings = nullptr;
@@ -1072,7 +1073,7 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st
10721073
}
10731074
}
10741075

1075-
void CppCheckExecutor::reportInfo(const ErrorLogger::ErrorMessage &msg)
1076+
void CppCheckExecutor::reportInfo(const ErrorMessage &msg)
10761077
{
10771078
reportErr(msg);
10781079
}
@@ -1089,7 +1090,7 @@ void CppCheckExecutor::reportStatus(std::size_t fileindex, std::size_t filecount
10891090
}
10901091
}
10911092

1092-
void CppCheckExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
1093+
void CppCheckExecutor::reportErr(const ErrorMessage &msg)
10931094
{
10941095
if (mShowAllErrors) {
10951096
reportOut(msg.toXML());

cli/cppcheckexecutor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ class CppCheckExecutor : public ErrorLogger {
7272
void reportOut(const std::string &outmsg) OVERRIDE;
7373

7474
/** xml output of errors */
75-
void reportErr(const ErrorLogger::ErrorMessage &msg) OVERRIDE;
75+
void reportErr(const ErrorMessage &msg) OVERRIDE;
7676

7777
void reportProgress(const std::string &filename, const char stage[], const std::size_t value) OVERRIDE;
7878

7979
/**
8080
* Output information messages.
8181
*/
82-
void reportInfo(const ErrorLogger::ErrorMessage &msg) OVERRIDE;
82+
void reportInfo(const ErrorMessage &msg) OVERRIDE;
8383

8484
void bughuntingReport(const std::string &str) OVERRIDE;
8585

cli/threadexecutor.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
117117
if (type == REPORT_OUT) {
118118
mErrorLogger.reportOut(buf);
119119
} else if (type == REPORT_ERROR || type == REPORT_INFO) {
120-
ErrorLogger::ErrorMessage msg;
120+
ErrorMessage msg;
121121
msg.deserialize(buf);
122122

123123
if (!mSettings.nomsg.isSuppressed(msg.toSuppressionsErrorMessage())) {
@@ -299,14 +299,14 @@ unsigned int ThreadExecutor::check()
299299
std::ostringstream oss;
300300
oss << "Internal error: Child process crashed with signal " << WTERMSIG(stat);
301301

302-
std::list<ErrorLogger::ErrorMessage::FileLocation> locations;
302+
std::list<ErrorMessage::FileLocation> locations;
303303
locations.emplace_back(childname, 0, 0);
304-
const ErrorLogger::ErrorMessage errmsg(locations,
305-
emptyString,
306-
Severity::error,
307-
oss.str(),
308-
"cppcheckError",
309-
false);
304+
const ErrorMessage errmsg(locations,
305+
emptyString,
306+
Severity::error,
307+
oss.str(),
308+
"cppcheckError",
309+
false);
310310

311311
if (!mSettings.nomsg.isSuppressed(errmsg.toSuppressionsErrorMessage()))
312312
mErrorLogger.reportErr(errmsg);
@@ -344,12 +344,12 @@ void ThreadExecutor::reportOut(const std::string &outmsg)
344344
writeToPipe(REPORT_OUT, outmsg);
345345
}
346346

347-
void ThreadExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
347+
void ThreadExecutor::reportErr(const ErrorMessage &msg)
348348
{
349349
writeToPipe(REPORT_ERROR, msg.serialize());
350350
}
351351

352-
void ThreadExecutor::reportInfo(const ErrorLogger::ErrorMessage &msg)
352+
void ThreadExecutor::reportInfo(const ErrorMessage &msg)
353353
{
354354
writeToPipe(REPORT_INFO, msg.serialize());
355355
}
@@ -496,12 +496,12 @@ void ThreadExecutor::reportOut(const std::string &outmsg)
496496

497497
LeaveCriticalSection(&mReportSync);
498498
}
499-
void ThreadExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
499+
void ThreadExecutor::reportErr(const ErrorMessage &msg)
500500
{
501501
report(msg, MessageType::REPORT_ERROR);
502502
}
503503

504-
void ThreadExecutor::reportInfo(const ErrorLogger::ErrorMessage &msg)
504+
void ThreadExecutor::reportInfo(const ErrorMessage &msg)
505505
{
506506

507507
}
@@ -511,7 +511,7 @@ void ThreadExecutor::bughuntingReport(const std::string &/*str*/)
511511
// TODO
512512
}
513513

514-
void ThreadExecutor::report(const ErrorLogger::ErrorMessage &msg, MessageType msgType)
514+
void ThreadExecutor::report(const ErrorMessage &msg, MessageType msgType)
515515
{
516516
if (mSettings.nomsg.isSuppressed(msg.toSuppressionsErrorMessage()))
517517
return;
@@ -559,12 +559,12 @@ void ThreadExecutor::reportOut(const std::string &/*outmsg*/)
559559
{
560560

561561
}
562-
void ThreadExecutor::reportErr(const ErrorLogger::ErrorMessage &/*msg*/)
562+
void ThreadExecutor::reportErr(const ErrorMessage &/*msg*/)
563563
{
564564

565565
}
566566

567-
void ThreadExecutor::reportInfo(const ErrorLogger::ErrorMessage &/*msg*/)
567+
void ThreadExecutor::reportInfo(const ErrorMessage &/*msg*/)
568568
{
569569

570570
}

cli/threadexecutor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class ThreadExecutor : public ErrorLogger {
5454
unsigned int check();
5555

5656
void reportOut(const std::string &outmsg) OVERRIDE;
57-
void reportErr(const ErrorLogger::ErrorMessage &msg) OVERRIDE;
58-
void reportInfo(const ErrorLogger::ErrorMessage &msg) OVERRIDE;
57+
void reportErr(const ErrorMessage &msg) OVERRIDE;
58+
void reportInfo(const ErrorMessage &msg) OVERRIDE;
5959
void bughuntingReport(const std::string &str) OVERRIDE;
6060

6161
/**
@@ -129,7 +129,7 @@ class ThreadExecutor : public ErrorLogger {
129129

130130
CRITICAL_SECTION mReportSync;
131131

132-
void report(const ErrorLogger::ErrorMessage &msg, MessageType msgType);
132+
void report(const ErrorMessage &msg, MessageType msgType);
133133

134134
static unsigned __stdcall threadProc(void*);
135135

democlient/democlient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class CppcheckExecutor : public ErrorLogger {
4545
}
4646

4747
void reportOut(const std::string &outmsg) override { }
48-
void reportErr(const ErrorLogger::ErrorMessage &msg) override {
48+
void reportErr(const ErrorMessage &msg) override {
4949
const std::string s = msg.toString(true);
5050

5151
std::cout << s << std::endl;

gui/applicationdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
#include <QDialog>
2323
#include <QString>
24-
#include "application.h"
2524
#include "ui_application.h"
2625

2726
class QWidget;
27+
class Application;
2828

2929
/// @addtogroup GUI
3030
/// @{

gui/checkthread.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,14 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS
395395
if (isSuppressed(errorMessage))
396396
continue;
397397

398-
std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;
398+
std::list<ErrorMessage::FileLocation> callstack;
399399
foreach (const QErrorPathItem &path, e.errorPath) {
400-
callstack.push_back(ErrorLogger::ErrorMessage::FileLocation(path.file.toStdString(), path.info.toStdString(), path.line, path.column));
400+
callstack.push_back(ErrorMessage::FileLocation(path.file.toStdString(), path.info.toStdString(), path.line, path.column));
401401
}
402402
const std::string f0 = file0.toStdString();
403403
const std::string msg = e.message.toStdString();
404404
const std::string id = e.errorId.toStdString();
405-
ErrorLogger::ErrorMessage errmsg(callstack, f0, e.severity, msg, id, false);
405+
ErrorMessage errmsg(callstack, f0, e.severity, msg, id, false);
406406
mResult.reportErr(errmsg);
407407
}
408408
}

gui/erroritem.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "erroritem.h"
2020
#include "common.h"
2121

22-
QErrorPathItem::QErrorPathItem(const ErrorLogger::ErrorMessage::FileLocation &loc)
22+
QErrorPathItem::QErrorPathItem(const ErrorMessage::FileLocation &loc)
2323
: file(QString::fromStdString(loc.getfile(false)))
2424
, line(loc.line)
2525
, column(loc.column)
@@ -40,7 +40,7 @@ ErrorItem::ErrorItem()
4040
{
4141
}
4242

43-
ErrorItem::ErrorItem(const ErrorLogger::ErrorMessage &errmsg)
43+
ErrorItem::ErrorItem(const ErrorMessage &errmsg)
4444
: file0(QString::fromStdString(errmsg.file0))
4545
, function(QString::fromStdString(errmsg.function))
4646
, errorId(QString::fromStdString(errmsg.id))
@@ -52,7 +52,7 @@ ErrorItem::ErrorItem(const ErrorLogger::ErrorMessage &errmsg)
5252
, cwe(errmsg.cwe.id)
5353
, symbolNames(QString::fromStdString(errmsg.symbolNames()))
5454
{
55-
for (std::list<ErrorLogger::ErrorMessage::FileLocation>::const_iterator loc = errmsg.callStack.begin();
55+
for (std::list<ErrorMessage::FileLocation>::const_iterator loc = errmsg.callStack.begin();
5656
loc != errmsg.callStack.end();
5757
++loc) {
5858
errorPath << QErrorPathItem(*loc);

gui/erroritem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class GuiSeverity {
5050
class QErrorPathItem {
5151
public:
5252
QErrorPathItem() : line(0), column(-1) {}
53-
explicit QErrorPathItem(const ErrorLogger::ErrorMessage::FileLocation &loc);
53+
explicit QErrorPathItem(const ErrorMessage::FileLocation &loc);
5454
QString file;
5555
int line;
5656
int column;
@@ -70,7 +70,7 @@ bool operator==(const QErrorPathItem &i1, const QErrorPathItem &i2);
7070
class ErrorItem {
7171
public:
7272
ErrorItem();
73-
explicit ErrorItem(const ErrorLogger::ErrorMessage &errmsg);
73+
explicit ErrorItem(const ErrorMessage &errmsg);
7474

7575
/**
7676
* @brief Convert error item to string.

0 commit comments

Comments
 (0)