Skip to content

Commit

Permalink
Tokenizer: removed some wrapper functions (danmar#6054)
Browse files Browse the repository at this point in the history
These were used inconsistently. Also `Tokenizer::list` is public and
used directly across the code already.
  • Loading branch information
firewave committed Mar 5, 2024
1 parent 2aee9b3 commit 77406bd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 26 deletions.
2 changes: 1 addition & 1 deletion lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
{
Timer timer("Tokenizer::createTokens", mSettings.showtime, &s_timerResults);
simplecpp::TokenList tokensP = preprocessor.preprocess(tokens1, mCurrentConfig, files, true);
tokenizer.createTokens(std::move(tokensP));
tokenizer.list.createTokens(std::move(tokensP));
}
hasValidConfig = true;

Expand Down
13 changes: 1 addition & 12 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3345,17 +3345,6 @@ void Tokenizer::simplifyUsingError(const Token* usingStart, const Token* usingEn
}
}

bool Tokenizer::createTokens(std::istream &code,
const std::string& FileName)
{
return list.createTokens(code, FileName);
}

void Tokenizer::createTokens(simplecpp::TokenList&& tokenList)
{
list.createTokens(std::move(tokenList));
}

bool Tokenizer::simplifyTokens1(const std::string &configuration)
{
// Fill the map mTypeSize..
Expand Down Expand Up @@ -3441,7 +3430,7 @@ bool Tokenizer::tokenize(std::istream &code,
const char FileName[],
const std::string &configuration)
{
if (!createTokens(code, FileName))
if (!list.createTokens(code, FileName))
return false;

return simplifyTokens1(configuration);
Expand Down
7 changes: 0 additions & 7 deletions lib/tokenize.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ class ErrorLogger;
class Preprocessor;
enum class Severity;

namespace simplecpp {
class TokenList;
}

/// @addtogroup Core
/// @{

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

bool createTokens(std::istream &code, const std::string& FileName);
void createTokens(simplecpp::TokenList&& tokenList);

bool simplifyTokens1(const std::string &configuration);
/**
* Tokenize code
Expand Down
4 changes: 2 additions & 2 deletions test/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void PreprocessorHelper::preprocess(const char code[], std::vector<std::string>
simplecpp::preprocess(tokens2, tokens1, files, filedata, simplecpp::DUI());

// Tokenizer..
tokenizer.createTokens(std::move(tokens2));
tokenizer.list.createTokens(std::move(tokens2));
}

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

// Tokenizer..
tokenizer.createTokens(std::move(tokens2));
tokenizer.list.createTokens(std::move(tokens2));

preprocessor.setDirectives(tokens1);
}
8 changes: 4 additions & 4 deletions test/testsimplifytemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5290,7 +5290,7 @@ class TestSimplifyTemplate : public TestFixture {
Tokenizer tokenizer(settings, this);

std::istringstream istr(code);
tokenizer.createTokens(istr, "test.cpp");
tokenizer.list.createTokens(istr, "test.cpp");
tokenizer.createLinks();
tokenizer.splitTemplateRightAngleBrackets(false);

Expand Down Expand Up @@ -5357,7 +5357,7 @@ class TestSimplifyTemplate : public TestFixture {
Tokenizer tokenizer(settings, this);

std::istringstream istr(code);
tokenizer.createTokens(istr, "test.cpp");
tokenizer.list.createTokens(istr, "test.cpp");
tokenizer.createLinks();
tokenizer.splitTemplateRightAngleBrackets(false);

Expand Down Expand Up @@ -5427,7 +5427,7 @@ class TestSimplifyTemplate : public TestFixture {
Tokenizer tokenizer(settings, this);

std::istringstream istr(code);
tokenizer.createTokens(istr, "test.cpp");
tokenizer.list.createTokens(istr, "test.cpp");
tokenizer.createLinks();
tokenizer.splitTemplateRightAngleBrackets(false);

Expand Down Expand Up @@ -5456,7 +5456,7 @@ class TestSimplifyTemplate : public TestFixture {
Tokenizer tokenizer(settings, this);

std::istringstream istr(code);
tokenizer.createTokens(istr, "test.cpp");
tokenizer.list.createTokens(istr, "test.cpp");
tokenizer.createLinks();
tokenizer.splitTemplateRightAngleBrackets(false);

Expand Down

0 comments on commit 77406bd

Please sign in to comment.