@@ -5902,9 +5902,9 @@ class TestTokenizer : public TestFixture {
59025902 Z3
59035903 };
59045904
5905- std::string testAst (const char code[], AstStyle style = AstStyle::Simple) const {
5905+ std::string testAst (const char code[], AstStyle style = AstStyle::Simple) {
59065906 // tokenize given code..
5907- Tokenizer tokenList (&settings0, nullptr );
5907+ Tokenizer tokenList (&settings0, this );
59085908 std::istringstream istr (code);
59095909 if (!tokenList.list .createTokens (istr," test.cpp" ))
59105910 return " ERROR" ;
@@ -5951,7 +5951,7 @@ class TestTokenizer : public TestFixture {
59515951 return ret;
59525952 }
59535953
5954- void astexpr () const { // simple expressions with arithmetical ops
5954+ void astexpr () { // simple expressions with arithmetical ops
59555955 ASSERT_EQUALS (" 12+3+" , testAst (" 1+2+3" ));
59565956 ASSERT_EQUALS (" 12*3+" , testAst (" 1*2+3" ));
59575957 ASSERT_EQUALS (" 123*+" , testAst (" 1+2*3" ));
@@ -6212,7 +6212,7 @@ class TestTokenizer : public TestFixture {
62126212 ASSERT_NO_THROW (tokenizeAndStringify (code));
62136213 }
62146214
6215- void astnewdelete () const {
6215+ void astnewdelete () {
62166216 ASSERT_EQUALS (" aintnew=" , testAst (" a = new int;" ));
62176217 ASSERT_EQUALS (" aint4[new=" , testAst (" a = new int[4];" ));
62186218 ASSERT_EQUALS (" aFoobar(new=" , testAst (" a = new Foo(bar);" ));
@@ -6436,15 +6436,15 @@ class TestTokenizer : public TestFixture {
64366436 " }\n " ));
64376437 }
64386438
6439- void astbrackets () const { // []
6439+ void astbrackets () { // []
64406440 ASSERT_EQUALS (" a23+[4+" , testAst (" a[2+3]+4" ));
64416441 ASSERT_EQUALS (" a1[0[" , testAst (" a[1][0]" ));
64426442 ASSERT_EQUALS (" ab0[=" , testAst (" a=(b)[0];" ));
64436443 ASSERT_EQUALS (" abc.0[=" , testAst (" a=b.c[0];" ));
64446444 ASSERT_EQUALS (" ab0[1[=" , testAst (" a=b[0][1];" ));
64456445 }
64466446
6447- void astvardecl () const {
6447+ void astvardecl () {
64486448 // Variable declaration
64496449 ASSERT_EQUALS (" a1[\"\" =" , testAst (" char a[1]=\"\" ;" ));
64506450 ASSERT_EQUALS (" charp*(3[char5[3[new=" , testAst (" char (*p)[3] = new char[5][3];" ));
@@ -6478,7 +6478,7 @@ class TestTokenizer : public TestFixture {
64786478 ASSERT_EQUALS (" i(j=" , testAst (" (int&)(i) = j;" ));
64796479 }
64806480
6481- void astunaryop () const { // unary operators
6481+ void astunaryop () { // unary operators
64826482 ASSERT_EQUALS (" 1a--+" , testAst (" 1 + --a" ));
64836483 ASSERT_EQUALS (" 1a--+" , testAst (" 1 + a--" ));
64846484 ASSERT_EQUALS (" ab+!" , testAst (" !(a+b)" ));
@@ -6504,7 +6504,7 @@ class TestTokenizer : public TestFixture {
65046504 ASSERT_EQUALS (" int0{1&return" , testAst (" int g() { return int{ 0 } & 1; }" ));
65056505 }
65066506
6507- void astfunction () const { // function calls
6507+ void astfunction () { // function calls
65086508 ASSERT_EQUALS (" 1f(+2+" , testAst (" 1+f()+2" ));
65096509 ASSERT_EQUALS (" 1f2(+3+" , testAst (" 1+f(2)+3" ));
65106510 ASSERT_EQUALS (" 1f23,(+4+" , testAst (" 1+f(2,3)+4" ));
@@ -6567,7 +6567,7 @@ class TestTokenizer : public TestFixture {
65676567 " }\n " ));
65686568 }
65696569
6570- void astcast () const {
6570+ void astcast () {
65716571 ASSERT_EQUALS (" ac&(=" , testAst (" a = (long)&c;" ));
65726572 ASSERT_EQUALS (" ac*(=" , testAst (" a = (Foo*)*c;" ));
65736573 ASSERT_EQUALS (" ac-(=" , testAst (" a = (long)-c;" ));
@@ -6740,14 +6740,14 @@ class TestTokenizer : public TestFixture {
67406740 ASSERT_EQUALS (" sf.{(i[{={" , testAst (" void g(int i) { S s{ .f = { [i]() {} } }; }" ));
67416741 }
67426742
6743- void astcase () const {
6743+ void astcase () {
67446744 ASSERT_EQUALS (" 0case" , testAst (" case 0:" ));
67456745 ASSERT_EQUALS (" 12+case" , testAst (" case 1+2:" ));
67466746 ASSERT_EQUALS (" xyz:?case" , testAst (" case (x?y:z):" ));
67476747 ASSERT_EQUALS (" switchx( 1case y++ 2case" , testAst (" switch(x){case 1:{++y;break;case 2:break;}}" ));
67486748 }
67496749
6750- void astrefqualifier () const {
6750+ void astrefqualifier () {
67516751 ASSERT_EQUALS (" b(int." , testAst (" class a { auto b() -> int&; };" ));
67526752 ASSERT_EQUALS (" b(int." , testAst (" class a { auto b() -> int&&; };" ));
67536753 ASSERT_EQUALS (" b(" , testAst (" class a { void b() &&; };" ));
@@ -6758,7 +6758,7 @@ class TestTokenizer : public TestFixture {
67586758
67596759 // Verify that returning a newly constructed object generates the correct AST even when the class name is scoped
67606760 // Addresses https://trac.cppcheck.net/ticket/9700
6761- void astnewscoped () const {
6761+ void astnewscoped () {
67626762 ASSERT_EQUALS (" (return (new A))" , testAst (" return new A;" , AstStyle::Z3));
67636763 ASSERT_EQUALS (" (return (new (( A)))" , testAst (" return new A();" , AstStyle::Z3));
67646764 ASSERT_EQUALS (" (return (new (( A true)))" , testAst (" return new A(true);" , AstStyle::Z3));
0 commit comments