File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4394,7 +4394,7 @@ const Function * Function::getOverriddenFunctionRecursive(const ::Type* baseType
43944394 bool match = true ;
43954395
43964396 // check for matching return parameters
4397- while (!Token::Match (temp1, " virtual|{|}|;" )) {
4397+ while (!Token::Match (temp1, " virtual|public:|private:|protected:| {|}|;" )) {
43984398 if (temp1->str () != temp2->str () &&
43994399 !(temp1->str () == derivedFromType->name () &&
44004400 temp2->str () == baseType->name ())) {
Original file line number Diff line number Diff line change @@ -249,6 +249,7 @@ class TestSymbolDatabase : public TestFixture {
249249 TEST_CASE (functionArgs20);
250250
251251 TEST_CASE (functionImplicitlyVirtual);
252+ TEST_CASE (functionGetOverridden);
252253
253254 TEST_CASE (functionIsInlineKeyword);
254255
@@ -2730,6 +2731,24 @@ class TestSymbolDatabase : public TestFixture {
27302731 ASSERT_EQUALS (true , function && function->isImplicitlyVirtual (false ));
27312732 }
27322733
2734+ void functionGetOverridden () {
2735+ GET_SYMBOL_DB (" struct B { virtual void f(); };\n "
2736+ " struct D : B {\n "
2737+ " public:\n "
2738+ " void f() override;\n "
2739+ " };\n "
2740+ " struct D2 : D { void f() override {} };\n " );
2741+ ASSERT (db != nullptr );
2742+ ASSERT_EQUALS (5 , db->scopeList .size ());
2743+ const Function *func = db->scopeList .back ().function ;
2744+ ASSERT (func && func->nestedIn );
2745+ ASSERT_EQUALS (" D2" , func->nestedIn ->className );
2746+ bool foundAllBaseClasses{};
2747+ const Function* baseFunc = func->getOverriddenFunction (&foundAllBaseClasses);
2748+ ASSERT (baseFunc && baseFunc->nestedIn && foundAllBaseClasses);
2749+ ASSERT_EQUALS (" D" , baseFunc->nestedIn ->className );
2750+ }
2751+
27332752 void functionIsInlineKeyword () {
27342753 GET_SYMBOL_DB (" inline void fs() {}" );
27352754 (void )db;
You can’t perform that action at this time.
0 commit comments