Moved implementation of two functions to new file check.cpp -> Don't include <iostream> everywhere

This commit is contained in:
PKEuS 2014-05-23 14:17:39 +02:00
parent 8f79dc3ff8
commit 1fc1ff1993
8 changed files with 54 additions and 17 deletions

View File

@ -19,9 +19,9 @@
#include "threadexecutor.h"
#include "cppcheck.h"
#include "cppcheckexecutor.h"
#include <iostream>
#ifdef THREADING_MODEL_FORK
#include <algorithm>
#include <iostream>
#include <sys/select.h>
#include <sys/wait.h>
#include <unistd.h>

44
lib/check.cpp Normal file
View File

@ -0,0 +1,44 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2014 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/>.
*/
//---------------------------------------------------------------------------
// 64-bit portability
//---------------------------------------------------------------------------
#include "check.h"
#include <iostream>
//---------------------------------------------------------------------------
Check::Check(const std::string &aname)
: _tokenizer(0), _settings(0), _errorLogger(0), _name(aname)
{
for (std::list<Check*>::iterator i = instances().begin(); i != instances().end(); ++i) {
if ((*i)->name() > aname) {
instances().insert(i, this);
return;
}
}
instances().push_back(this);
}
void Check::reportError(const ErrorLogger::ErrorMessage &errmsg)
{
std::cout << errmsg.toXML(true, 1) << std::endl;
}

View File

@ -28,7 +28,6 @@
#include "errorlogger.h"
#include <list>
#include <iostream>
#include <set>
/// @addtogroup Core
@ -41,16 +40,7 @@
class CPPCHECKLIB Check {
public:
/** This constructor is used when registering the CheckClass */
explicit Check(const std::string &aname)
: _tokenizer(0), _settings(0), _errorLogger(0), _name(aname) {
for (std::list<Check*>::iterator i = instances().begin(); i != instances(). end(); ++i) {
if ((*i)->name() > aname) {
instances().insert(i, this);
return;
}
}
instances().push_back(this);
}
explicit Check(const std::string &aname);
/** This constructor is used when running checks. */
Check(const std::string &aname, const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
@ -111,9 +101,7 @@ public:
* This is for for printout out the error list with --errorlist
* @param errmsg Error message to write
*/
static void reportError(const ErrorLogger::ErrorMessage &errmsg) {
std::cout << errmsg.toXML(true, 1) << std::endl;
}
static void reportError(const ErrorLogger::ErrorMessage &errmsg);
bool inconclusiveFlag() const {
return _settings && _settings->inconclusive;

View File

@ -28,6 +28,7 @@
#include "tokenize.h"
#include "symboldatabase.h"
#include <iostream>
//---------------------------------------------------------------------------
const int DEALLOC = -1;

View File

@ -310,7 +310,7 @@ void CheckSizeof::sizeofVoid()
// Get 'struct.member' complete name (without spaces)
varname = tok2->stringifyList(tok->next());
varname.erase(std::remove_if(varname.begin(), varname.end(),
static_cast<int (*)(int)>(std::isspace)), varname.end());
static_cast<int (*)(int)>(std::isspace)), varname.end());
}
}
// Check for cast on operations with '+|-'

View File

@ -36,6 +36,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\externals\tinyxml\tinyxml2.cpp" />
<ClCompile Include="check.cpp" />
<ClCompile Include="check64bit.cpp" />
<ClCompile Include="checkassert.cpp" />
<ClCompile Include="checkassignif.cpp" />

View File

@ -131,6 +131,9 @@
<ClCompile Include="valueflow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="check.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="checkbufferoverrun.h">

View File

@ -23,11 +23,11 @@
#include "token.h"
#include "settings.h"
#include "errorlogger.h"
#include "check.h"
#include <string>
#include <sstream>
#include <climits>
#include <iostream>
//---------------------------------------------------------------------------