Skip to content

Commit 0d7e8a0

Browse files
committed
Tokenizer: removed TestTokenizer friend class declaration
1 parent 769bafc commit 0d7e8a0

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

lib/tokenize.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ class CPPCHECKLIB Tokenizer {
4949

5050
friend class SymbolDatabase;
5151

52-
friend class TestTokenizer;
53-
5452
public:
5553
Tokenizer(TokenList tokenList, ErrorLogger &errorLogger);
5654
~Tokenizer();
@@ -191,6 +189,7 @@ class CPPCHECKLIB Tokenizer {
191189
*/
192190
void simplifyVariableMultipleAssign();
193191

192+
protected:
194193
/**
195194
* Simplify the 'C Alternative Tokens'
196195
* Examples:
@@ -200,6 +199,7 @@ class CPPCHECKLIB Tokenizer {
200199
*/
201200
bool simplifyCAlternativeTokens();
202201

202+
private:
203203
/** Add braces to an if-block, for-block, etc.
204204
* @return true if no syntax errors
205205
*/
@@ -307,10 +307,12 @@ class CPPCHECKLIB Tokenizer {
307307

308308
void fillTypeSizes();
309309

310+
protected:
310311
void combineOperators();
311312

312313
void combineStringAndCharLiterals();
313314

315+
private:
314316
void concatenateNegativeNumberAndAnyPositive();
315317

316318
void simplifyExternC();
@@ -327,6 +329,7 @@ class CPPCHECKLIB Tokenizer {
327329

328330
void findComplicatedSyntaxErrorsInTemplates();
329331

332+
protected:
330333
/**
331334
* Modify strings in the token list by replacing hex and oct
332335
* values. E.g. "\x61" -> "a" and "\000" -> "\0"
@@ -360,12 +363,12 @@ class CPPCHECKLIB Tokenizer {
360363
*/
361364
void createLinks();
362365

363-
private:
364366
/**
365367
* Setup links between < and >.
366368
*/
367369
void createLinks2();
368370

371+
private:
369372
/**
370373
* Set isCast() for C++ casts
371374
*/
@@ -439,9 +442,11 @@ class CPPCHECKLIB Tokenizer {
439442
*/
440443
void simplifyCppcheckAttribute();
441444

445+
protected:
442446
/** Simplify c++20 spaceship operator */
443447
void simplifySpaceshipOperator();
444448

449+
private:
445450
/**
446451
* Remove keywords "volatile", "inline", "register", and "restrict"
447452
*/
@@ -528,11 +533,13 @@ class CPPCHECKLIB Tokenizer {
528533
*/
529534
void simplifyCoroutines();
530535

536+
protected:
531537
/**
532538
* Prepare ternary operators with parentheses so that the AST can be created
533539
* */
534540
void prepareTernaryOpForAST();
535541

542+
private:
536543
/**
537544
* report error message
538545
*/

test/testtokenize.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,15 @@ class TestTokenizer : public TestFixture {
508508
TEST_CASE(simplifyRedundantParentheses);
509509
}
510510

511+
class TokenizerTest : public Tokenizer
512+
{
513+
friend class TestTokenizer;
514+
public:
515+
TokenizerTest(TokenList tokenList, ErrorLogger &errorLogger)
516+
: Tokenizer(std::move(tokenList), errorLogger)
517+
{}
518+
};
519+
511520
struct TokenizeOptions
512521
{
513522
bool expand = true;
@@ -3782,7 +3791,7 @@ class TestTokenizer : public TestFixture {
37823791

37833792
void simplifyString() {
37843793
TokenList tokenlist{settings0, Standards::Language::CPP};
3785-
Tokenizer tokenizer(std::move(tokenlist), *this);
3794+
TokenizerTest tokenizer(std::move(tokenlist), *this);
37863795
ASSERT_EQUALS("\"abc\"", tokenizer.simplifyString("\"abc\""));
37873796
ASSERT_EQUALS("\"\n\"", tokenizer.simplifyString("\"\\xa\""));
37883797
ASSERT_EQUALS("\"3\"", tokenizer.simplifyString("\"\\x33\""));
@@ -6349,7 +6358,7 @@ class TestTokenizer : public TestFixture {
63496358
if (!tokenlist.createTokensFromString(data))
63506359
return "ERROR";
63516360

6352-
Tokenizer tokenizer(std::move(tokenlist), *this);
6361+
TokenizerTest tokenizer(std::move(tokenlist), *this);
63536362
tokenizer.combineStringAndCharLiterals();
63546363
tokenizer.combineOperators();
63556364
tokenizer.simplifySpaceshipOperator();

0 commit comments

Comments
 (0)