Skip to content

Commit b5d9811

Browse files
committed
Tokenizer: removed TestSimplifyTemplate friend class declaration
1 parent 3947a3a commit b5d9811

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

lib/tokenize.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class CPPCHECKLIB Tokenizer {
4949

5050
friend class SymbolDatabase;
5151

52-
friend class TestSimplifyTemplate;
5352
friend class TestSimplifyTypedef;
5453
friend class TestTokenizer;
5554

@@ -115,6 +114,7 @@ class CPPCHECKLIB Tokenizer {
115114
void removeExtraTemplateKeywords();
116115

117116

117+
protected:
118118
/** Split up template right angle brackets.
119119
* foo < bar < >> => foo < bar < > >
120120
*/
@@ -353,11 +353,13 @@ class CPPCHECKLIB Tokenizer {
353353
*/
354354
NORETURN void cppcheckError(const Token *tok) const;
355355

356+
protected:
356357
/**
357358
* Setup links for tokens so that one can call Token::link().
358359
*/
359360
void createLinks();
360361

362+
private:
361363
/**
362364
* Setup links between < and >.
363365
*/
@@ -645,8 +647,10 @@ class CPPCHECKLIB Tokenizer {
645647
/** Symbol database that all checks etc can use */
646648
SymbolDatabase* mSymbolDatabase{};
647649

650+
protected:
648651
TemplateSimplifier * const mTemplateSimplifier;
649652

653+
private:
650654
std::set<nonneg int> mTemplateVarIdUsage;
651655

652656
/** E.g. "A" for code where "#ifdef A" is true. This is used to

test/testsimplifytemplate.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,15 @@ class TestSimplifyTemplate : public TestFixture {
319319
TEST_CASE(dumpTemplateArgFrom);
320320
}
321321

322+
class TokenizerTest : public Tokenizer
323+
{
324+
friend class TestSimplifyTemplate;
325+
public:
326+
TokenizerTest(TokenList tokenList, ErrorLogger &errorLogger)
327+
: Tokenizer(std::move(tokenList), errorLogger)
328+
{}
329+
};
330+
322331
struct CheckOptions
323332
{
324333
bool debugwarnings = false;
@@ -5461,7 +5470,7 @@ class TestSimplifyTemplate : public TestFixture {
54615470
tokenlist.appendFileIfNew("test.cpp");
54625471
if (!tokenlist.createTokensFromString(data))
54635472
return false;
5464-
Tokenizer tokenizer(std::move(tokenlist), *this);
5473+
TokenizerTest tokenizer(std::move(tokenlist), *this);
54655474
tokenizer.createLinks();
54665475
tokenizer.splitTemplateRightAngleBrackets(false);
54675476

@@ -5531,7 +5540,7 @@ class TestSimplifyTemplate : public TestFixture {
55315540
tokenlist.appendFileIfNew("test.cpp");
55325541
if (!tokenlist.createTokensFromString(data))
55335542
return false;
5534-
Tokenizer tokenizer(std::move(tokenlist), *this);
5543+
TokenizerTest tokenizer(std::move(tokenlist), *this);
55355544
tokenizer.createLinks();
55365545
tokenizer.splitTemplateRightAngleBrackets(false);
55375546

@@ -5602,7 +5611,7 @@ class TestSimplifyTemplate : public TestFixture {
56025611
TokenList tokenlist{settings, Standards::Language::CPP};
56035612
if (!TokenListHelper::createTokensFromString(tokenlist, data, "test.cpp"))
56045613
return false;
5605-
Tokenizer tokenizer(std::move(tokenlist), *this);
5614+
TokenizerTest tokenizer(std::move(tokenlist), *this);
56065615
tokenizer.createLinks();
56075616
tokenizer.splitTemplateRightAngleBrackets(false);
56085617

@@ -5633,7 +5642,7 @@ class TestSimplifyTemplate : public TestFixture {
56335642

56345643
if (!TokenListHelper::createTokensFromString(tokenlist, data, "test.cpp"))
56355644
return false;
5636-
Tokenizer tokenizer(std::move(tokenlist), *this);
5645+
TokenizerTest tokenizer(std::move(tokenlist), *this);
56375646
tokenizer.createLinks();
56385647
tokenizer.splitTemplateRightAngleBrackets(false);
56395648

0 commit comments

Comments
 (0)