@@ -5948,9 +5948,9 @@ class TestTokenizer : public TestFixture {
59485948 Z3
59495949 };
59505950
5951- std::string testAst (const char code[], AstStyle style = AstStyle::Simple) const {
5951+ std::string testAst (const char code[], AstStyle style = AstStyle::Simple) {
59525952 // tokenize given code..
5953- Tokenizer tokenizer (settings0, nullptr );
5953+ Tokenizer tokenizer (settings0, this );
59545954 std::istringstream istr (code);
59555955 if (!tokenizer.list .createTokens (istr," test.cpp" ))
59565956 return " ERROR" ;
@@ -5997,7 +5997,7 @@ class TestTokenizer : public TestFixture {
59975997 return ret;
59985998 }
59995999
6000- void astexpr () const { // simple expressions with arithmetical ops
6000+ void astexpr () { // simple expressions with arithmetical ops
60016001 ASSERT_EQUALS (" 12+3+" , testAst (" 1+2+3" ));
60026002 ASSERT_EQUALS (" 12*3+" , testAst (" 1*2+3" ));
60036003 ASSERT_EQUALS (" 123*+" , testAst (" 1+2*3" ));
@@ -6259,7 +6259,7 @@ class TestTokenizer : public TestFixture {
62596259 ASSERT_NO_THROW (tokenizeAndStringify (code));
62606260 }
62616261
6262- void astnewdelete () const {
6262+ void astnewdelete () {
62636263 ASSERT_EQUALS (" aintnew=" , testAst (" a = new int;" ));
62646264 ASSERT_EQUALS (" aint4[new=" , testAst (" a = new int[4];" ));
62656265 ASSERT_EQUALS (" aFoobar(new=" , testAst (" a = new Foo(bar);" ));
@@ -6483,15 +6483,15 @@ class TestTokenizer : public TestFixture {
64836483 " }\n " ));
64846484 }
64856485
6486- void astbrackets () const { // []
6486+ void astbrackets () { // []
64876487 ASSERT_EQUALS (" a23+[4+" , testAst (" a[2+3]+4" ));
64886488 ASSERT_EQUALS (" a1[0[" , testAst (" a[1][0]" ));
64896489 ASSERT_EQUALS (" ab0[=" , testAst (" a=(b)[0];" ));
64906490 ASSERT_EQUALS (" abc.0[=" , testAst (" a=b.c[0];" ));
64916491 ASSERT_EQUALS (" ab0[1[=" , testAst (" a=b[0][1];" ));
64926492 }
64936493
6494- void astvardecl () const {
6494+ void astvardecl () {
64956495 // Variable declaration
64966496 ASSERT_EQUALS (" a1[\"\" =" , testAst (" char a[1]=\"\" ;" ));
64976497 ASSERT_EQUALS (" charp*(3[char5[3[new=" , testAst (" char (*p)[3] = new char[5][3];" ));
@@ -6529,7 +6529,7 @@ class TestTokenizer : public TestFixture {
65296529 ASSERT_EQUALS (" " , testAst (" void f(bool& var){}" ));
65306530 }
65316531
6532- void astunaryop () const { // unary operators
6532+ void astunaryop () { // unary operators
65336533 ASSERT_EQUALS (" 1a--+" , testAst (" 1 + --a" ));
65346534 ASSERT_EQUALS (" 1a--+" , testAst (" 1 + a--" ));
65356535 ASSERT_EQUALS (" ab+!" , testAst (" !(a+b)" ));
@@ -6555,7 +6555,7 @@ class TestTokenizer : public TestFixture {
65556555 ASSERT_EQUALS (" int0{1&return" , testAst (" int g() { return int{ 0 } & 1; }" ));
65566556 }
65576557
6558- void astfunction () const { // function calls
6558+ void astfunction () { // function calls
65596559 ASSERT_EQUALS (" 1f(+2+" , testAst (" 1+f()+2" ));
65606560 ASSERT_EQUALS (" 1f2(+3+" , testAst (" 1+f(2)+3" ));
65616561 ASSERT_EQUALS (" 1f23,(+4+" , testAst (" 1+f(2,3)+4" ));
@@ -6619,7 +6619,7 @@ class TestTokenizer : public TestFixture {
66196619 " }\n " ));
66206620 }
66216621
6622- void astcast () const {
6622+ void astcast () {
66236623 ASSERT_EQUALS (" ac&(=" , testAst (" a = (long)&c;" ));
66246624 ASSERT_EQUALS (" ac*(=" , testAst (" a = (Foo*)*c;" ));
66256625 ASSERT_EQUALS (" ac-(=" , testAst (" a = (long)-c;" ));
@@ -6805,14 +6805,14 @@ class TestTokenizer : public TestFixture {
68056805 ASSERT_EQUALS (" sf.{(i[{={" , testAst (" void g(int i) { S s{ .f = { [i]() {} } }; }" ));
68066806 }
68076807
6808- void astcase () const {
6808+ void astcase () {
68096809 ASSERT_EQUALS (" 0case" , testAst (" case 0:" ));
68106810 ASSERT_EQUALS (" 12+case" , testAst (" case 1+2:" ));
68116811 ASSERT_EQUALS (" xyz:?case" , testAst (" case (x?y:z):" ));
68126812 ASSERT_EQUALS (" switchx( 1case y++ 2case" , testAst (" switch(x){case 1:{++y;break;case 2:break;}}" ));
68136813 }
68146814
6815- void astrefqualifier () const {
6815+ void astrefqualifier () {
68166816 ASSERT_EQUALS (" b(int." , testAst (" class a { auto b() -> int&; };" ));
68176817 ASSERT_EQUALS (" b(int." , testAst (" class a { auto b() -> int&&; };" ));
68186818 ASSERT_EQUALS (" b(" , testAst (" class a { void b() &&; };" ));
@@ -6823,7 +6823,7 @@ class TestTokenizer : public TestFixture {
68236823
68246824 // Verify that returning a newly constructed object generates the correct AST even when the class name is scoped
68256825 // Addresses https://trac.cppcheck.net/ticket/9700
6826- void astnewscoped () const {
6826+ void astnewscoped () {
68276827 ASSERT_EQUALS (" (return (new A))" , testAst (" return new A;" , AstStyle::Z3));
68286828 ASSERT_EQUALS (" (return (new (( A)))" , testAst (" return new A();" , AstStyle::Z3));
68296829 ASSERT_EQUALS (" (return (new (( A true)))" , testAst (" return new A(true);" , AstStyle::Z3));
0 commit comments