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:
parent
8e94e2261b
commit
dca03c3ce2
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
#include "checkautovariables.h"
|
||||
#include "symboldatabase.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include "check.h"
|
||||
#include "token.h"
|
||||
#include <set>
|
||||
|
||||
/// @addtogroup Checks
|
||||
/// @{
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
*/
|
||||
|
||||
#include "checkboost.h"
|
||||
#include "symboldatabase.h"
|
||||
#include <sstream>
|
||||
|
||||
// Register this check class (by creating a static instance of it)
|
||||
namespace {
|
||||
|
|
|
@ -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..
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "errorlogger.h"
|
||||
#include "symboldatabase.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
|
||||
#include "checkmemoryleak.h"
|
||||
#include "symboldatabase.h"
|
||||
#include "mathlib.h"
|
||||
#include "tokenize.h"
|
||||
|
||||
|
|
|
@ -35,13 +35,12 @@
|
|||
*/
|
||||
|
||||
#include "check.h"
|
||||
#include "symboldatabase.h"
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Token;
|
||||
class Scope;
|
||||
|
||||
/// @addtogroup Core
|
||||
/// @{
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "check.h"
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
|
||||
/// @addtogroup Checks
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <string>
|
||||
#include <list>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
/// @addtogroup Core
|
||||
/// @{
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "settings.h"
|
||||
#include "suppressions.h"
|
||||
|
||||
class Token;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "tokenize.h"
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <stack>
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "path.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <stack>
|
||||
#include <cctype> // std::isdigit, std::isalnum, etc
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,8 @@
|
|||
#include "path.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
// use tinyxml with STL
|
||||
#include <tinyxml.h>
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "token.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -18,9 +18,11 @@
|
|||
|
||||
#ifndef TestUtilsH
|
||||
#define TestUtilsH
|
||||
|
||||
#include "settings.h"
|
||||
#include "tokenize.h"
|
||||
#include "token.h"
|
||||
|
||||
class Token;
|
||||
|
||||
class givenACodeSampleToTokenize {
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue