Skip to content

Commit 77406bd

Browse files
authored
Tokenizer: removed some wrapper functions (#6054)
These were used inconsistently. Also `Tokenizer::list` is public and used directly across the code already.
1 parent 2aee9b3 commit 77406bd

File tree

5 files changed

+8
-26
lines changed

5 files changed

+8
-26
lines changed

lib/cppcheck.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
893893
{
894894
Timer timer("Tokenizer::createTokens", mSettings.showtime, &s_timerResults);
895895
simplecpp::TokenList tokensP = preprocessor.preprocess(tokens1, mCurrentConfig, files, true);
896-
tokenizer.createTokens(std::move(tokensP));
896+
tokenizer.list.createTokens(std::move(tokensP));
897897
}
898898
hasValidConfig = true;
899899

lib/tokenize.cpp

+1-12
Original file line numberDiff line numberDiff line change
@@ -3345,17 +3345,6 @@ void Tokenizer::simplifyUsingError(const Token* usingStart, const Token* usingEn
33453345
}
33463346
}
33473347

3348-
bool Tokenizer::createTokens(std::istream &code,
3349-
const std::string& FileName)
3350-
{
3351-
return list.createTokens(code, FileName);
3352-
}
3353-
3354-
void Tokenizer::createTokens(simplecpp::TokenList&& tokenList)
3355-
{
3356-
list.createTokens(std::move(tokenList));
3357-
}
3358-
33593348
bool Tokenizer::simplifyTokens1(const std::string &configuration)
33603349
{
33613350
// Fill the map mTypeSize..
@@ -3441,7 +3430,7 @@ bool Tokenizer::tokenize(std::istream &code,
34413430
const char FileName[],
34423431
const std::string &configuration)
34433432
{
3444-
if (!createTokens(code, FileName))
3433+
if (!list.createTokens(code, FileName))
34453434
return false;
34463435

34473436
return simplifyTokens1(configuration);

lib/tokenize.h

-7
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ class ErrorLogger;
3939
class Preprocessor;
4040
enum class Severity;
4141

42-
namespace simplecpp {
43-
class TokenList;
44-
}
45-
4642
/// @addtogroup Core
4743
/// @{
4844

@@ -83,9 +79,6 @@ class CPPCHECKLIB Tokenizer {
8379
*/
8480
bool isScopeNoReturn(const Token *endScopeToken, bool *unknown = nullptr) const;
8581

86-
bool createTokens(std::istream &code, const std::string& FileName);
87-
void createTokens(simplecpp::TokenList&& tokenList);
88-
8982
bool simplifyTokens1(const std::string &configuration);
9083
/**
9184
* Tokenize code

test/helpers.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void PreprocessorHelper::preprocess(const char code[], std::vector<std::string>
155155
simplecpp::preprocess(tokens2, tokens1, files, filedata, simplecpp::DUI());
156156

157157
// Tokenizer..
158-
tokenizer.createTokens(std::move(tokens2));
158+
tokenizer.list.createTokens(std::move(tokens2));
159159
}
160160

161161
void PreprocessorHelper::preprocess(Preprocessor &preprocessor, const char code[], std::vector<std::string> &files, Tokenizer& tokenizer)
@@ -174,7 +174,7 @@ void PreprocessorHelper::preprocess(Preprocessor &preprocessor, const char code[
174174
simplecpp::preprocess(tokens2, tokens1, files, filedata, dui);
175175

176176
// Tokenizer..
177-
tokenizer.createTokens(std::move(tokens2));
177+
tokenizer.list.createTokens(std::move(tokens2));
178178

179179
preprocessor.setDirectives(tokens1);
180180
}

test/testsimplifytemplate.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -5290,7 +5290,7 @@ class TestSimplifyTemplate : public TestFixture {
52905290
Tokenizer tokenizer(settings, this);
52915291

52925292
std::istringstream istr(code);
5293-
tokenizer.createTokens(istr, "test.cpp");
5293+
tokenizer.list.createTokens(istr, "test.cpp");
52945294
tokenizer.createLinks();
52955295
tokenizer.splitTemplateRightAngleBrackets(false);
52965296

@@ -5357,7 +5357,7 @@ class TestSimplifyTemplate : public TestFixture {
53575357
Tokenizer tokenizer(settings, this);
53585358

53595359
std::istringstream istr(code);
5360-
tokenizer.createTokens(istr, "test.cpp");
5360+
tokenizer.list.createTokens(istr, "test.cpp");
53615361
tokenizer.createLinks();
53625362
tokenizer.splitTemplateRightAngleBrackets(false);
53635363

@@ -5427,7 +5427,7 @@ class TestSimplifyTemplate : public TestFixture {
54275427
Tokenizer tokenizer(settings, this);
54285428

54295429
std::istringstream istr(code);
5430-
tokenizer.createTokens(istr, "test.cpp");
5430+
tokenizer.list.createTokens(istr, "test.cpp");
54315431
tokenizer.createLinks();
54325432
tokenizer.splitTemplateRightAngleBrackets(false);
54335433

@@ -5456,7 +5456,7 @@ class TestSimplifyTemplate : public TestFixture {
54565456
Tokenizer tokenizer(settings, this);
54575457

54585458
std::istringstream istr(code);
5459-
tokenizer.createTokens(istr, "test.cpp");
5459+
tokenizer.list.createTokens(istr, "test.cpp");
54605460
tokenizer.createLinks();
54615461
tokenizer.splitTemplateRightAngleBrackets(false);
54625462

0 commit comments

Comments
 (0)