diff --git a/src/checkother.h b/src/checkother.h index ca34f56ce..1005872dd 100644 --- a/src/checkother.h +++ b/src/checkother.h @@ -118,7 +118,6 @@ public: /** Check for post increment/decrement in for loop*/ void postIncrement(); -protected: void lookupVar(const Token *tok1, const char varname[]); // Redundant condition @@ -126,7 +125,6 @@ protected: // haystack.remove(needle); void redundantCondition2(); -private: // Error messages.. void cstyleCastError(const Token *tok); void redundantIfDelete0Error(const Token *tok); diff --git a/src/tokenize.h b/src/tokenize.h index 5bede3bcb..3bc493dcc 100644 --- a/src/tokenize.h +++ b/src/tokenize.h @@ -79,9 +79,6 @@ public: /** Simplify tokenlist */ void simplifyTokenList(); - - // Helper functions for handling the tokens list.. - static void deleteTokens(Token *tok); static const char *getParameterName(const Token *ftok, int par); @@ -90,8 +87,6 @@ public: // Return size. int sizeOfType(const char type[]) const; - void initTokens(); - const std::vector *getFiles() const; void fillFunctionList(); @@ -110,6 +105,7 @@ public: */ static const Token *findClassFunction(const Token *tok, const char classname[], const char funcname[], int &indentlevel); +private: /** * Simplify variable declarations @@ -174,8 +170,6 @@ public: */ bool simplifyComma(); -protected: - /** Add braces to an if-block * @return true if something is modified * false if nothing is done. @@ -202,8 +196,6 @@ protected: std::vector _functionList; -private: - /** * Finds matching "end" for "start". * @param tok The start tag diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index f644a9f21..21312be2b 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -18,8 +18,6 @@ - -#define UNIT_TESTING #include "../src/tokenize.h" #include "../src/checkmemoryleak.h" #include "testsuite.h" diff --git a/test/testredundantif.cpp b/test/testredundantif.cpp index 905749edf..2551b832e 100644 --- a/test/testredundantif.cpp +++ b/test/testredundantif.cpp @@ -35,21 +35,6 @@ public: TestRedundantIf() : TestFixture("TestRedundantIf") { } - class OurCheckOther : public CheckOther - { - public: - OurCheckOther(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) - : CheckOther(tokenizer, settings, errorLogger) - { - - } - - void redundantCondition2() - { - CheckOther::redundantCondition2(); - } - }; - private: void check(const char code[]) { @@ -63,7 +48,7 @@ private: // Check for redundant condition.. Settings settings; - OurCheckOther checkOther(&tokenizer, &settings, this); + CheckOther checkOther(&tokenizer, &settings, this); checkOther.redundantCondition2(); } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index e64017eb2..aea47eb1d 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -19,33 +19,15 @@ #include "testsuite.h" +#define private public #include "../src/tokenize.h" +#undef private #include "../src/token.h" #include extern std::ostringstream errout; -// A test tokenizer where protected functions are made public -class OpenTokenizer : public Tokenizer -{ -public: - OpenTokenizer(const char code[]) : Tokenizer() - { - std::istringstream istr(code); - tokenize(istr, "test.cpp"); - } - - virtual ~OpenTokenizer() - { } - - bool elseif_() - { - return elseif(); - } -}; - - class TestSimplifyTokens : public TestFixture { public: @@ -471,8 +453,9 @@ private: { std::istringstream istr(code); - OpenTokenizer tokenizer(code); - tokenizer.elseif_(); + Tokenizer tokenizer; + tokenizer.createTokens(istr); + tokenizer.elseif(); return tokenizer.tokens()->stringifyList(false); } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 9d43ececd..80acea18e 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -23,7 +23,9 @@ #include #include "testsuite.h" +#define private public #include "../src/tokenize.h" +#undef private #include "../src/token.h" extern std::ostringstream errout; @@ -33,30 +35,6 @@ public: TestTokenizer() : TestFixture("TestTokenizer") { } - class OurTokenizer : public Tokenizer - { - public: - void simplifyCasts() - { - Tokenizer::simplifyCasts(); - } - - bool simplifyIfAddBraces() - { - return Tokenizer::simplifyIfAddBraces(); - } - - bool simplifyKnownVariables() - { - return Tokenizer::simplifyKnownVariables(); - } - - std::vector &getFunctionList() - { - return _functionList; - } - }; - private: void run() @@ -241,7 +219,7 @@ private: const char code[] = "int *f(int *);"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -259,7 +237,7 @@ private: const char code[] = "t = (static_cast *>(&p));\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -300,14 +278,14 @@ private: "void b()\n" "{ }\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); tokenizer.fillFunctionList(); - ASSERT_EQUALS(1, static_cast(tokenizer.getFunctionList().size())); - ASSERT_EQUALS("b", tokenizer.getFunctionList()[0]->str()); + ASSERT_EQUALS(1, static_cast(tokenizer._functionList.size())); + ASSERT_EQUALS("b", tokenizer._functionList[0]->str()); } void const_and_volatile_functions() @@ -331,18 +309,18 @@ private: // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); tokenizer.fillFunctionList(); - ASSERT_EQUALS(3, static_cast(tokenizer.getFunctionList().size())); - if (tokenizer.getFunctionList().size() == 3) + ASSERT_EQUALS(3, static_cast(tokenizer._functionList.size())); + if (tokenizer._functionList.size() == 3) { - ASSERT_EQUALS("a", tokenizer.getFunctionList()[0]->str()); - ASSERT_EQUALS("b", tokenizer.getFunctionList()[1]->str()); - ASSERT_EQUALS("c", tokenizer.getFunctionList()[2]->str()); + ASSERT_EQUALS("a", tokenizer._functionList[0]->str()); + ASSERT_EQUALS("b", tokenizer._functionList[1]->str()); + ASSERT_EQUALS("c", tokenizer._functionList[2]->str()); } } @@ -543,7 +521,7 @@ private: "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -564,7 +542,7 @@ private: "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -588,7 +566,7 @@ private: "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -614,7 +592,7 @@ private: "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -636,7 +614,7 @@ private: "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -658,7 +636,7 @@ private: "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -681,7 +659,7 @@ private: "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -703,7 +681,7 @@ private: " abc[++i] = 2;\n" "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -725,7 +703,7 @@ private: " abc[i] = 0;\n" "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -747,7 +725,7 @@ private: " ;\n" "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -777,7 +755,7 @@ private: " }\n" "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -805,7 +783,7 @@ private: " }\n" "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -830,7 +808,7 @@ private: " a(b);\n" "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -852,7 +830,7 @@ private: " int foo=0;\n" "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -871,7 +849,7 @@ private: "const double pi = 3.14;\n" "int main(){}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -2077,7 +2055,7 @@ private: "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); @@ -2100,7 +2078,7 @@ private: "}\n"; // tokenize.. - OurTokenizer tokenizer; + Tokenizer tokenizer; std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); tokenizer.simplifyTokenList();