Skip to content

Commit 1fc1ff1

Browse files
committed
Moved implementation of two functions to new file check.cpp -> Don't include <iostream> everywhere
1 parent 8f79dc3 commit 1fc1ff1

File tree

8 files changed

+54
-17
lines changed

8 files changed

+54
-17
lines changed

cli/threadexecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
#include "threadexecutor.h"
2020
#include "cppcheck.h"
2121
#include "cppcheckexecutor.h"
22+
#include <iostream>
2223
#ifdef THREADING_MODEL_FORK
2324
#include <algorithm>
24-
#include <iostream>
2525
#include <sys/select.h>
2626
#include <sys/wait.h>
2727
#include <unistd.h>

lib/check.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Cppcheck - A tool for static C/C++ code analysis
3+
* Copyright (C) 2007-2014 Daniel Marjamäki and Cppcheck team.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
//---------------------------------------------------------------------------
20+
// 64-bit portability
21+
//---------------------------------------------------------------------------
22+
23+
#include "check.h"
24+
25+
#include <iostream>
26+
27+
//---------------------------------------------------------------------------
28+
29+
Check::Check(const std::string &aname)
30+
: _tokenizer(0), _settings(0), _errorLogger(0), _name(aname)
31+
{
32+
for (std::list<Check*>::iterator i = instances().begin(); i != instances().end(); ++i) {
33+
if ((*i)->name() > aname) {
34+
instances().insert(i, this);
35+
return;
36+
}
37+
}
38+
instances().push_back(this);
39+
}
40+
41+
void Check::reportError(const ErrorLogger::ErrorMessage &errmsg)
42+
{
43+
std::cout << errmsg.toXML(true, 1) << std::endl;
44+
}

lib/check.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "errorlogger.h"
2929

3030
#include <list>
31-
#include <iostream>
3231
#include <set>
3332

3433
/// @addtogroup Core
@@ -41,16 +40,7 @@
4140
class CPPCHECKLIB Check {
4241
public:
4342
/** This constructor is used when registering the CheckClass */
44-
explicit Check(const std::string &aname)
45-
: _tokenizer(0), _settings(0), _errorLogger(0), _name(aname) {
46-
for (std::list<Check*>::iterator i = instances().begin(); i != instances(). end(); ++i) {
47-
if ((*i)->name() > aname) {
48-
instances().insert(i, this);
49-
return;
50-
}
51-
}
52-
instances().push_back(this);
53-
}
43+
explicit Check(const std::string &aname);
5444

5545
/** This constructor is used when running checks. */
5646
Check(const std::string &aname, const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
@@ -111,9 +101,7 @@ class CPPCHECKLIB Check {
111101
* This is for for printout out the error list with --errorlist
112102
* @param errmsg Error message to write
113103
*/
114-
static void reportError(const ErrorLogger::ErrorMessage &errmsg) {
115-
std::cout << errmsg.toXML(true, 1) << std::endl;
116-
}
104+
static void reportError(const ErrorLogger::ErrorMessage &errmsg);
117105

118106
bool inconclusiveFlag() const {
119107
return _settings && _settings->inconclusive;

lib/checkleakautovar.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "tokenize.h"
2929
#include "symboldatabase.h"
3030

31+
#include <iostream>
3132
//---------------------------------------------------------------------------
3233

3334
const int DEALLOC = -1;

lib/checksizeof.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ void CheckSizeof::sizeofVoid()
310310
// Get 'struct.member' complete name (without spaces)
311311
varname = tok2->stringifyList(tok->next());
312312
varname.erase(std::remove_if(varname.begin(), varname.end(),
313-
static_cast<int (*)(int)>(std::isspace)), varname.end());
313+
static_cast<int (*)(int)>(std::isspace)), varname.end());
314314
}
315315
}
316316
// Check for cast on operations with '+|-'

lib/cppcheck.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
</ItemGroup>
3737
<ItemGroup>
3838
<ClCompile Include="..\externals\tinyxml\tinyxml2.cpp" />
39+
<ClCompile Include="check.cpp" />
3940
<ClCompile Include="check64bit.cpp" />
4041
<ClCompile Include="checkassert.cpp" />
4142
<ClCompile Include="checkassignif.cpp" />

lib/cppcheck.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@
131131
<ClCompile Include="valueflow.cpp">
132132
<Filter>Source Files</Filter>
133133
</ClCompile>
134+
<ClCompile Include="check.cpp">
135+
<Filter>Source Files</Filter>
136+
</ClCompile>
134137
</ItemGroup>
135138
<ItemGroup>
136139
<ClInclude Include="checkbufferoverrun.h">

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
#include "token.h"
2424
#include "settings.h"
2525
#include "errorlogger.h"
26-
#include "check.h"
2726

2827
#include <string>
2928
#include <sstream>
3029
#include <climits>
30+
#include <iostream>
3131

3232
//---------------------------------------------------------------------------
3333

0 commit comments

Comments
 (0)