@@ -249,6 +249,7 @@ class TestSymbolDatabase: public TestFixture {
249249 TEST_CASE (findFunction5); // #6230
250250 TEST_CASE (findFunction6);
251251 TEST_CASE (findFunction7); // #6700
252+ TEST_CASE (findFunction8);
252253
253254 TEST_CASE (noexceptFunction1);
254255 TEST_CASE (noexceptFunction2);
@@ -2606,6 +2607,83 @@ class TestSymbolDatabase: public TestFixture {
26062607 ASSERT_EQUALS (true , callfunc && callfunc->tokAt (2 )->function () && callfunc->tokAt (2 )->function ()->tokenDef ->linenr () == 3 );
26072608 }
26082609
2610+ void findFunction8 () {
2611+ GET_SYMBOL_DB (" struct S {\n "
2612+ " void f() { }\n "
2613+ " void f() & { }\n "
2614+ " void f() &&{ }\n "
2615+ " void f() const { }\n "
2616+ " void f() const & { }\n "
2617+ " void f() const &&{ }\n "
2618+ " void g() ;\n "
2619+ " void g() & ;\n "
2620+ " void g() &&;\n "
2621+ " void g() const ;\n "
2622+ " void g() const & ;\n "
2623+ " void g() const &&;\n "
2624+ " };\n "
2625+ " void S::g() { }\n "
2626+ " void S::g() & { }\n "
2627+ " void S::g() &&{ }\n "
2628+ " void S::g() const { }\n "
2629+ " void S::g() const & { }\n "
2630+ " void S::g() const &&{ }\n " );
2631+ ASSERT_EQUALS (" " , errout.str ());
2632+
2633+ const Token *f = Token::findsimplematch (tokenizer.tokens (), " f ( ) {" );
2634+ ASSERT_EQUALS (true , db && f && f->function () && f->function ()->tokenDef ->linenr () == 2 );
2635+
2636+ f = Token::findsimplematch (tokenizer.tokens (), " f ( ) & {" );
2637+ ASSERT_EQUALS (true , db && f && f->function () && f->function ()->tokenDef ->linenr () == 3 );
2638+
2639+ f = Token::findsimplematch (tokenizer.tokens (), " f ( ) && {" );
2640+ ASSERT_EQUALS (true , db && f && f->function () && f->function ()->tokenDef ->linenr () == 4 );
2641+
2642+ f = Token::findsimplematch (tokenizer.tokens (), " f ( ) const {" );
2643+ ASSERT_EQUALS (true , db && f && f->function () && f->function ()->tokenDef ->linenr () == 5 );
2644+
2645+ f = Token::findsimplematch (tokenizer.tokens (), " f ( ) const & {" );
2646+ ASSERT_EQUALS (true , db && f && f->function () && f->function ()->tokenDef ->linenr () == 6 );
2647+
2648+ f = Token::findsimplematch (tokenizer.tokens (), " f ( ) const && {" );
2649+ ASSERT_EQUALS (true , db && f && f->function () && f->function ()->tokenDef ->linenr () == 7 );
2650+
2651+ f = Token::findsimplematch (tokenizer.tokens (), " g ( ) {" );
2652+ ASSERT_EQUALS (true , db && f && f->function () && f->function ()->tokenDef ->linenr () == 8 && f->function ()->token ->linenr () == 15 );
2653+
2654+ f = Token::findsimplematch (tokenizer.tokens (), " g ( ) & {" );
2655+ ASSERT_EQUALS (true , db && f && f->function () && f->function ()->tokenDef ->linenr () == 9 && f->function ()->token ->linenr () == 16 );
2656+
2657+ f = Token::findsimplematch (tokenizer.tokens (), " g ( ) && {" );
2658+ ASSERT_EQUALS (true , db && f && f->function () && f->function ()->tokenDef ->linenr () == 10 && f->function ()->token ->linenr () == 17 );
2659+
2660+ f = Token::findsimplematch (tokenizer.tokens (), " g ( ) const {" );
2661+ ASSERT_EQUALS (true , db && f && f->function () && f->function ()->tokenDef ->linenr () == 11 && f->function ()->token ->linenr () == 18 );
2662+
2663+ f = Token::findsimplematch (tokenizer.tokens (), " g ( ) const & {" );
2664+ ASSERT_EQUALS (true , db && f && f->function () && f->function ()->tokenDef ->linenr () == 12 && f->function ()->token ->linenr () == 19 );
2665+
2666+ f = Token::findsimplematch (tokenizer.tokens (), " g ( ) const && {" );
2667+ ASSERT_EQUALS (true , db && f && f->function () && f->function ()->tokenDef ->linenr () == 13 && f->function ()->token ->linenr () == 20 );
2668+
2669+ f = Token::findsimplematch (tokenizer.tokens (), " S :: g ( ) {" );
2670+ ASSERT_EQUALS (true , db && f && f->tokAt (2 )->function () && f->tokAt (2 )->function ()->tokenDef ->linenr () == 8 && f->tokAt (2 )->function ()->token ->linenr () == 15 );
2671+
2672+ f = Token::findsimplematch (tokenizer.tokens (), " S :: g ( ) & {" );
2673+ ASSERT_EQUALS (true , db && f && f->tokAt (2 )->function () && f->tokAt (2 )->function ()->tokenDef ->linenr () == 9 && f->tokAt (2 )->function ()->token ->linenr () == 16 );
2674+
2675+ f = Token::findsimplematch (tokenizer.tokens (), " S :: g ( ) && {" );
2676+ ASSERT_EQUALS (true , db && f && f->tokAt (2 )->function () && f->tokAt (2 )->function ()->tokenDef ->linenr () == 10 && f->tokAt (2 )->function ()->token ->linenr () == 17 );
2677+
2678+ f = Token::findsimplematch (tokenizer.tokens (), " S :: g ( ) const {" );
2679+ ASSERT_EQUALS (true , db && f && f->tokAt (2 )->function () && f->tokAt (2 )->function ()->tokenDef ->linenr () == 11 && f->tokAt (2 )->function ()->token ->linenr () == 18 );
2680+
2681+ f = Token::findsimplematch (tokenizer.tokens (), " S :: g ( ) const & {" );
2682+ ASSERT_EQUALS (true , db && f && f->tokAt (2 )->function () && f->tokAt (2 )->function ()->tokenDef ->linenr () == 12 && f->tokAt (2 )->function ()->token ->linenr () == 19 );
2683+
2684+ f = Token::findsimplematch (tokenizer.tokens (), " S :: g ( ) const && {" );
2685+ ASSERT_EQUALS (true , db && f && f->tokAt (2 )->function () && f->tokAt (2 )->function ()->tokenDef ->linenr () == 13 && f->tokAt (2 )->function ()->token ->linenr () == 20 );
2686+ }
26092687
26102688
26112689#define FUNC (x ) const Function *x = findFunctionByName(#x, &db->scopeList.front()); \
0 commit comments