Remove unnecessary includes

Also add a unit test related to #3427
Also improve the description text in checkclass and remove unused variable.
This commit is contained in:
PKEuS 2011-12-23 23:31:48 +02:00 committed by Reijo Tomperi
parent 8e94e2261b
commit dca03c3ce2
23 changed files with 25 additions and 36 deletions

View File

@ -21,7 +21,6 @@
#include "threadexecutor.h"
#include "preprocessor.h"
#include "errorlogger.h"
#include <fstream>
#include <iostream>
#include <cstdlib> // EXIT_SUCCESS and EXIT_FAILURE
#include <cstring>

View File

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

View File

@ -23,8 +23,7 @@
#include "checkautovariables.h"
#include "symboldatabase.h"
#include <sstream>
#include <iostream>
#include <list>
#include <string>
//---------------------------------------------------------------------------

View File

@ -24,7 +24,6 @@
#include "check.h"
#include "token.h"
#include <set>
/// @addtogroup Checks
/// @{

View File

@ -17,8 +17,6 @@
*/
#include "checkboost.h"
#include "symboldatabase.h"
#include <sstream>
// Register this check class (by creating a static instance of it)
namespace {

View File

@ -30,12 +30,8 @@
#include <algorithm>
#include <sstream>
#include <list>
#include <cstring>
#include <cctype>
#include <climits>
#include <cassert> // <- assert
#include <cstdlib> // <- strtoul
#include <cstdlib>
//---------------------------------------------------------------------------
@ -2160,7 +2156,6 @@ void CheckBufferOverrun::arrayIndexThenCheck()
return;
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
if (Token::Match(tok, "%var% [ %var% ]")) {
const std::string arrayName(tok->str());
const std::string indexName(tok->strAt(2));
// skip array index..

View File

@ -24,7 +24,6 @@
#include "errorlogger.h"
#include "symboldatabase.h"
#include <cstring>
#include <string>
#include <algorithm>

View File

@ -22,10 +22,10 @@
//---------------------------------------------------------------------------
#include "check.h"
#include "settings.h"
#include "symboldatabase.h"
class Token;
class Scope;
class Function;
/// @addtogroup Checks
/// @{
@ -147,8 +147,8 @@ private:
return "Check the code for each class.\n"
"* Missing constructors\n"
"* Are all variables initialized by the constructors?\n"
"* [[CheckMemset|Warn if memset, memcpy etc are used on a class]]\n"
//"* If it's a base class, check that the destructor is virtual\n"
"* Warn if memset, memcpy etc are used on a class\n"
"* If it's a base class, check that the destructor is virtual\n"
"* Are there unused private functions\n"
"* 'operator=' should return reference to self\n"
"* 'operator=' should check for assignment to self\n"

View File

@ -18,6 +18,7 @@
#include "checkmemoryleak.h"
#include "symboldatabase.h"
#include "mathlib.h"
#include "tokenize.h"

View File

@ -35,13 +35,12 @@
*/
#include "check.h"
#include "symboldatabase.h"
#include <list>
#include <string>
#include <vector>
class Token;
class Scope;
/// @addtogroup Core
/// @{

View File

@ -24,7 +24,7 @@
#include "check.h"
#include <string>
#include <list>
#include <map>
/// @addtogroup Checks

View File

@ -26,7 +26,6 @@
#include <string>
#include <list>
#include <sstream>
#include <vector>
/// @addtogroup Core
/// @{

View File

@ -23,7 +23,6 @@
#include <list>
#include <string>
#include "settings.h"
#include "suppressions.h"
class Token;

View File

@ -22,7 +22,6 @@
#include "tokenize.h"
#include <string>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <cmath>

View File

@ -29,7 +29,6 @@
#include <fstream>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <vector>
#include <set>
#include <stack>

View File

@ -21,7 +21,6 @@
#include "path.h"
#include <sstream>
#include <iostream>
#include <stack>
#include <cctype> // std::isdigit, std::isalnum, etc

View File

@ -25,10 +25,8 @@
#include "errorlogger.h"
#include "check.h"
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <climits>
// Define ULLONG_MAX and LLONG_MAX for Borland

View File

@ -1606,7 +1606,7 @@ private:
checkVirtualDestructor("class Base\n"
"{\n"
"public:\n"
"~Base() {}\n"
" ~Base() {}\n"
"};\n"
"class A : private Base\n"
"{\n"
@ -1619,7 +1619,7 @@ private:
"public:\n"
" ~B() { int a; }\n"
"};\n");
TODO_ASSERT_EQUALS("[test.cpp:7]: (error) Class A which is inherited by class B does not have a virtual destructor\n",
TODO_ASSERT_EQUALS("[test.cpp:7]: (error) Class Base which is inherited by class B does not have a virtual destructor\n",
"", errout.str());
}

View File

@ -27,9 +27,8 @@
#include "path.h"
#include <algorithm>
#include <map>
#include <list>
#include <string>
#include <stdexcept>
// use tinyxml with STL
#include <tinyxml.h>

View File

@ -1394,6 +1394,14 @@ private:
" const char *c = f().c_str();\n"
"}");
ASSERT_EQUALS("[test.cpp:4]: (error) Dangerous usage of c_str(). The returned value by c_str() is invalid after this call.\n", errout.str());
check("const char* foo() {\n"
" static std::string text;\n"
" text = \"hello world\n\";\n"
" return text.c_str();\n"
"}");
ASSERT_EQUALS("", errout.str()); // #3427
}
void autoPointer() {

View File

@ -26,10 +26,9 @@
#include "threadexecutor.h"
#include "cppcheckexecutor.h"
#include <algorithm>
#include <map>
#include <string>
#include <stdexcept>
#include <vector>
extern std::ostringstream errout;
extern std::ostringstream output;

View File

@ -21,7 +21,6 @@
#include "token.h"
#include "settings.h"
#include <cstring>
#include <vector>
#include <string>

View File

@ -18,9 +18,11 @@
#ifndef TestUtilsH
#define TestUtilsH
#include "settings.h"
#include "tokenize.h"
#include "token.h"
class Token;
class givenACodeSampleToTokenize {
private: