4444
4545class TestSymbolDatabase ;
4646
47- #define GET_SYMBOL_DB_STD (code ) \
48- Tokenizer tokenizer (settings1, this ); \
49- LOAD_LIB_2 (settings1.library, " std.cfg" ); \
50- const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code, " test.cpp" ); \
51- ASSERT (db); \
52- do {} while (false )
53-
5447#define GET_SYMBOL_DB (code ) \
5548 Tokenizer tokenizer (settings1, this ); \
5649 const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code, " test.cpp" ); \
@@ -62,15 +55,22 @@ class TestSymbolDatabase;
6255 const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code, " test.c" ); \
6356 do {} while (false )
6457
58+ #define GET_SYMBOL_DB_DBG (code ) \
59+ Tokenizer tokenizer (settingsDbg, this ); \
60+ const SymbolDatabase *db = getSymbolDB_inner(tokenizer, code, " test.cpp" ); \
61+ ASSERT (db); \
62+ do {} while (false )
63+
6564class TestSymbolDatabase : public TestFixture {
6665public:
6766 TestSymbolDatabase () : TestFixture(" TestSymbolDatabase" ) {}
6867
6968private:
7069 const Token* vartok{nullptr };
7170 const Token* typetok{nullptr };
72- Settings settings1 = settingsBuilder().library(" std.cfg" ).build();
71+ const Settings settings1 = settingsBuilder().library(" std.cfg" ).build();
7372 const Settings settings2 = settingsBuilder().platform(Platform::Type::Unspecified).build();
73+ const Settings settingsDbg = settingsBuilder().library(" std.cfg" ).debugwarnings(true ).build();
7474
7575 void reset () {
7676 vartok = nullptr ;
@@ -2174,8 +2174,7 @@ class TestSymbolDatabase : public TestFixture {
21742174 }
21752175
21762176 void functionDeclarations2 () {
2177- const Settings settingsOld = settings1;
2178- GET_SYMBOL_DB_STD (" std::array<int,2> foo(int x);" );
2177+ GET_SYMBOL_DB (" std::array<int,2> foo(int x);" );
21792178
21802179 // 1 scopes: Global
21812180 ASSERT (db && db->scopeList .size () == 1 );
@@ -2193,13 +2192,10 @@ class TestSymbolDatabase : public TestFixture {
21932192 const Token*parenthesis = foo->tokenDef ->next ();
21942193 ASSERT (parenthesis->str () == " (" && parenthesis->previous ()->str () == " foo" );
21952194 ASSERT (parenthesis->valueType ()->type == ValueType::Type::CONTAINER);
2196-
2197- settings1 = settingsOld;
21982195 }
21992196
22002197 void constexprFunction () {
2201- const Settings settingsOld = settings1;
2202- GET_SYMBOL_DB_STD (" constexpr int foo();" );
2198+ GET_SYMBOL_DB (" constexpr int foo();" );
22032199
22042200 // 1 scopes: Global
22052201 ASSERT (db && db->scopeList .size () == 1 );
@@ -2214,8 +2210,6 @@ class TestSymbolDatabase : public TestFixture {
22142210 ASSERT (foo->tokenDef ->str () == " foo" );
22152211 ASSERT (!foo->hasBody ());
22162212 ASSERT (foo->isConstexpr ());
2217-
2218- settings1 = settingsOld;
22192213 }
22202214
22212215 void constructorInitialization () {
@@ -3003,25 +2997,22 @@ class TestSymbolDatabase : public TestFixture {
30032997 }
30042998
30052999 void needInitialization () {
3006- const auto oldSettings = settings1;
3007- settings1.debugwarnings = true ;
30083000 {
3009- GET_SYMBOL_DB (" template <typename T>\n " // #10259
3010- " struct A {\n "
3011- " using type = T;\n "
3012- " type t_;\n "
3013- " };\n " );
3001+ GET_SYMBOL_DB_DBG (" template <typename T>\n " // #10259
3002+ " struct A {\n "
3003+ " using type = T;\n "
3004+ " type t_;\n "
3005+ " };\n " );
30143006 ASSERT_EQUALS (" " , errout.str ());
30153007 }
30163008 {
3017- GET_SYMBOL_DB (" class T;\n " // #12367
3018- " struct S {\n "
3019- " S(T& t);\n "
3020- " T& _t;\n "
3021- " };\n " );
3009+ GET_SYMBOL_DB_DBG (" class T;\n " // #12367
3010+ " struct S {\n "
3011+ " S(T& t);\n "
3012+ " T& _t;\n "
3013+ " };\n " );
30223014 ASSERT_EQUALS (" " , errout.str ());
30233015 }
3024- settings1 = oldSettings;
30253016 }
30263017
30273018 void tryCatch1 () {
@@ -5043,11 +5034,8 @@ class TestSymbolDatabase : public TestFixture {
50435034 }
50445035
50455036 void symboldatabase83 () { // #9431
5046- const Settings settingsOld = settings1;
5047- settings1.debugwarnings = true ;
5048- GET_SYMBOL_DB (" struct a { a() noexcept; };\n "
5049- " a::a() noexcept = default;" );
5050- settings1 = settingsOld;
5037+ GET_SYMBOL_DB_DBG (" struct a { a() noexcept; };\n "
5038+ " a::a() noexcept = default;" );
50515039 const Scope *scope = db->findScopeByName (" a" );
50525040 ASSERT (scope);
50535041 ASSERT (scope->functionList .size () == 1 );
@@ -5061,11 +5049,8 @@ class TestSymbolDatabase : public TestFixture {
50615049
50625050 void symboldatabase84 () {
50635051 {
5064- const bool old = settings1.debugwarnings ;
5065- settings1.debugwarnings = true ;
5066- GET_SYMBOL_DB (" struct a { a() noexcept(false); };\n "
5067- " a::a() noexcept(false) = default;" );
5068- settings1.debugwarnings = old;
5052+ GET_SYMBOL_DB_DBG (" struct a { a() noexcept(false); };\n "
5053+ " a::a() noexcept(false) = default;" );
50695054 const Scope *scope = db->findScopeByName (" a" );
50705055 ASSERT (scope);
50715056 ASSERT (scope->functionList .size () == 1 );
@@ -5077,11 +5062,8 @@ class TestSymbolDatabase : public TestFixture {
50775062 ASSERT_EQUALS (" " , errout.str ());
50785063 }
50795064 {
5080- const bool old = settings1.debugwarnings ;
5081- settings1.debugwarnings = true ;
5082- GET_SYMBOL_DB (" struct a { a() noexcept(true); };\n "
5083- " a::a() noexcept(true) = default;" );
5084- settings1.debugwarnings = old;
5065+ GET_SYMBOL_DB_DBG (" struct a { a() noexcept(true); };\n "
5066+ " a::a() noexcept(true) = default;" );
50855067 const Scope *scope = db->findScopeByName (" a" );
50865068 ASSERT (scope);
50875069 ASSERT (scope->functionList .size () == 1 );
@@ -5383,46 +5365,43 @@ class TestSymbolDatabase : public TestFixture {
53835365 }
53845366
53855367 void symboldatabase104 () {
5386- const bool oldDebug = settings1.debugwarnings ;
5387- settings1.debugwarnings = true ;
5388- {
5389- GET_SYMBOL_DB (" struct S {\n " // #11535
5390- " void f1(char* const c);\n "
5391- " void f2(char* const c);\n "
5392- " void f3(char* const);\n "
5393- " void f4(char* c);\n "
5394- " void f5(char* c);\n "
5395- " void f6(char*);\n "
5396- " };\n "
5397- " void S::f1(char* c) {}\n "
5398- " void S::f2(char*) {}\n "
5399- " void S::f3(char* c) {}\n "
5400- " void S::f4(char* const c) {}\n "
5401- " void S::f5(char* const) {}\n "
5402- " void S::f6(char* const c) {}\n " );
5368+ {
5369+ GET_SYMBOL_DB_DBG (" struct S {\n " // #11535
5370+ " void f1(char* const c);\n "
5371+ " void f2(char* const c);\n "
5372+ " void f3(char* const);\n "
5373+ " void f4(char* c);\n "
5374+ " void f5(char* c);\n "
5375+ " void f6(char*);\n "
5376+ " };\n "
5377+ " void S::f1(char* c) {}\n "
5378+ " void S::f2(char*) {}\n "
5379+ " void S::f3(char* c) {}\n "
5380+ " void S::f4(char* const c) {}\n "
5381+ " void S::f5(char* const) {}\n "
5382+ " void S::f6(char* const c) {}\n " );
54035383 ASSERT (db != nullptr );
54045384 ASSERT_EQUALS (" " , errout.str ());
54055385 }
54065386 {
5407- GET_SYMBOL_DB (" struct S2 {\n " // #11602
5408- " enum E {};\n "
5409- " };\n "
5410- " struct S1 {\n "
5411- " void f(S2::E) const;\n "
5412- " };\n "
5413- " void S1::f(const S2::E) const {}\n " );
5387+ GET_SYMBOL_DB_DBG (" struct S2 {\n " // #11602
5388+ " enum E {};\n "
5389+ " };\n "
5390+ " struct S1 {\n "
5391+ " void f(S2::E) const;\n "
5392+ " };\n "
5393+ " void S1::f(const S2::E) const {}\n " );
54145394 ASSERT (db != nullptr );
54155395 ASSERT_EQUALS (" " , errout.str ());
54165396 }
54175397 {
5418- GET_SYMBOL_DB (" struct S {\n "
5419- " void f(const bool b = false);\n "
5420- " };\n "
5421- " void S::f(const bool b) {}\n " );
5398+ GET_SYMBOL_DB_DBG (" struct S {\n "
5399+ " void f(const bool b = false);\n "
5400+ " };\n "
5401+ " void S::f(const bool b) {}\n " );
54225402 ASSERT (db != nullptr );
54235403 ASSERT_EQUALS (" " , errout.str ());
54245404 }
5425- settings1.debugwarnings = oldDebug;
54265405 }
54275406
54285407 void createSymbolDatabaseFindAllScopes1 () {
0 commit comments