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 "threadexecutor.h"
#include "cppcheck.h" #include "cppcheck.h"
#include "cppcheckexecutor.h" #include "cppcheckexecutor.h"
#include <iostream>
#ifdef THREADING_MODEL_FORK #ifdef THREADING_MODEL_FORK
#include <algorithm> #include <algorithm>
#include <iostream>
#include <sys/select.h> #include <sys/select.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.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 "errorlogger.h"
#include <list> #include <list>
#include <iostream>
#include <set> #include <set>
/// @addtogroup Core /// @addtogroup Core
@ -41,16 +40,7 @@
class CPPCHECKLIB Check { class CPPCHECKLIB Check {
public: public:
/** This constructor is used when registering the CheckClass */ /** This constructor is used when registering the CheckClass */
explicit Check(const std::string &aname) 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);
}
/** This constructor is used when running checks. */ /** This constructor is used when running checks. */
Check(const std::string &aname, const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) 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 * This is for for printout out the error list with --errorlist
* @param errmsg Error message to write * @param errmsg Error message to write
*/ */
static void reportError(const ErrorLogger::ErrorMessage &errmsg) { static void reportError(const ErrorLogger::ErrorMessage &errmsg);
std::cout << errmsg.toXML(true, 1) << std::endl;
}
bool inconclusiveFlag() const { bool inconclusiveFlag() const {
return _settings && _settings->inconclusive; return _settings && _settings->inconclusive;

View File

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

View File

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

View File

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

View File

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