@@ -5957,9 +5957,9 @@ class TestTokenizer : public TestFixture {
59575957 Z3
59585958 };
59595959
5960- std::string testAst (const char code[], AstStyle style = AstStyle::Simple) const {
5960+ std::string testAst (const char code[], AstStyle style = AstStyle::Simple) {
59615961 // tokenize given code..
5962- Tokenizer tokenizer (settings0, nullptr );
5962+ Tokenizer tokenizer (settings0, this );
59635963 std::istringstream istr (code);
59645964 if (!tokenizer.list .createTokens (istr," test.cpp" ))
59655965 return " ERROR" ;
@@ -6006,7 +6006,7 @@ class TestTokenizer : public TestFixture {
60066006 return ret;
60076007 }
60086008
6009- void astexpr () const { // simple expressions with arithmetical ops
6009+ void astexpr () { // simple expressions with arithmetical ops
60106010 ASSERT_EQUALS (" 12+3+" , testAst (" 1+2+3" ));
60116011 ASSERT_EQUALS (" 12*3+" , testAst (" 1*2+3" ));
60126012 ASSERT_EQUALS (" 123*+" , testAst (" 1+2*3" ));
@@ -6268,7 +6268,7 @@ class TestTokenizer : public TestFixture {
62686268 ASSERT_NO_THROW (tokenizeAndStringify (code));
62696269 }
62706270
6271- void astnewdelete () const {
6271+ void astnewdelete () {
62726272 ASSERT_EQUALS (" aintnew=" , testAst (" a = new int;" ));
62736273 ASSERT_EQUALS (" aint4[new=" , testAst (" a = new int[4];" ));
62746274 ASSERT_EQUALS (" aFoobar(new=" , testAst (" a = new Foo(bar);" ));
@@ -6492,15 +6492,15 @@ class TestTokenizer : public TestFixture {
64926492 " }\n " ));
64936493 }
64946494
6495- void astbrackets () const { // []
6495+ void astbrackets () { // []
64966496 ASSERT_EQUALS (" a23+[4+" , testAst (" a[2+3]+4" ));
64976497 ASSERT_EQUALS (" a1[0[" , testAst (" a[1][0]" ));
64986498 ASSERT_EQUALS (" ab0[=" , testAst (" a=(b)[0];" ));
64996499 ASSERT_EQUALS (" abc.0[=" , testAst (" a=b.c[0];" ));
65006500 ASSERT_EQUALS (" ab0[1[=" , testAst (" a=b[0][1];" ));
65016501 }
65026502
6503- void astvardecl () const {
6503+ void astvardecl () {
65046504 // Variable declaration
65056505 ASSERT_EQUALS (" a1[\"\" =" , testAst (" char a[1]=\"\" ;" ));
65066506 ASSERT_EQUALS (" charp*(3[char5[3[new=" , testAst (" char (*p)[3] = new char[5][3];" ));
@@ -6538,7 +6538,7 @@ class TestTokenizer : public TestFixture {
65386538 ASSERT_EQUALS (" " , testAst (" void f(bool& var){}" ));
65396539 }
65406540
6541- void astunaryop () const { // unary operators
6541+ void astunaryop () { // unary operators
65426542 ASSERT_EQUALS (" 1a--+" , testAst (" 1 + --a" ));
65436543 ASSERT_EQUALS (" 1a--+" , testAst (" 1 + a--" ));
65446544 ASSERT_EQUALS (" ab+!" , testAst (" !(a+b)" ));
@@ -6564,7 +6564,7 @@ class TestTokenizer : public TestFixture {
65646564 ASSERT_EQUALS (" int0{1&return" , testAst (" int g() { return int{ 0 } & 1; }" ));
65656565 }
65666566
6567- void astfunction () const { // function calls
6567+ void astfunction () { // function calls
65686568 ASSERT_EQUALS (" 1f(+2+" , testAst (" 1+f()+2" ));
65696569 ASSERT_EQUALS (" 1f2(+3+" , testAst (" 1+f(2)+3" ));
65706570 ASSERT_EQUALS (" 1f23,(+4+" , testAst (" 1+f(2,3)+4" ));
@@ -6628,7 +6628,7 @@ class TestTokenizer : public TestFixture {
66286628 " }\n " ));
66296629 }
66306630
6631- void astcast () const {
6631+ void astcast () {
66326632 ASSERT_EQUALS (" ac&(=" , testAst (" a = (long)&c;" ));
66336633 ASSERT_EQUALS (" ac*(=" , testAst (" a = (Foo*)*c;" ));
66346634 ASSERT_EQUALS (" ac-(=" , testAst (" a = (long)-c;" ));
@@ -6814,14 +6814,14 @@ class TestTokenizer : public TestFixture {
68146814 ASSERT_EQUALS (" sf.{(i[{={" , testAst (" void g(int i) { S s{ .f = { [i]() {} } }; }" ));
68156815 }
68166816
6817- void astcase () const {
6817+ void astcase () {
68186818 ASSERT_EQUALS (" 0case" , testAst (" case 0:" ));
68196819 ASSERT_EQUALS (" 12+case" , testAst (" case 1+2:" ));
68206820 ASSERT_EQUALS (" xyz:?case" , testAst (" case (x?y:z):" ));
68216821 ASSERT_EQUALS (" switchx( 1case y++ 2case" , testAst (" switch(x){case 1:{++y;break;case 2:break;}}" ));
68226822 }
68236823
6824- void astrefqualifier () const {
6824+ void astrefqualifier () {
68256825 ASSERT_EQUALS (" b(int." , testAst (" class a { auto b() -> int&; };" ));
68266826 ASSERT_EQUALS (" b(int." , testAst (" class a { auto b() -> int&&; };" ));
68276827 ASSERT_EQUALS (" b(" , testAst (" class a { void b() &&; };" ));
@@ -6832,7 +6832,7 @@ class TestTokenizer : public TestFixture {
68326832
68336833 // Verify that returning a newly constructed object generates the correct AST even when the class name is scoped
68346834 // Addresses https://trac.cppcheck.net/ticket/9700
6835- void astnewscoped () const {
6835+ void astnewscoped () {
68366836 ASSERT_EQUALS (" (return (new A))" , testAst (" return new A;" , AstStyle::Z3));
68376837 ASSERT_EQUALS (" (return (new (( A)))" , testAst (" return new A();" , AstStyle::Z3));
68386838 ASSERT_EQUALS (" (return (new (( A true)))" , testAst (" return new A(true);" , AstStyle::Z3));
0 commit comments