Skip to content

Commit

Permalink
Fix #12439 Destructors missing 'overriddenFunction' when they are ove…
Browse files Browse the repository at this point in the history
…rriden (#6001)
  • Loading branch information
chrchr-github committed Feb 23, 2024
1 parent e2a3758 commit f303757
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4709,6 +4709,14 @@ const Function * Function::getOverriddenFunctionRecursive(const ::Type* baseType
}
}

if (isDestructor()) {
auto it = std::find_if(parent->functionList.begin(), parent->functionList.end(), [](const Function& f) {
return f.isDestructor() && f.isImplicitlyVirtual();
});
if (it != parent->functionList.end())
return &*it;
}

if (!derivedFromType->derivedFrom.empty() && !derivedFromType->hasCircularDependencies() && !isDerivedFromItself(baseType->classScope->className, i.name)) {
// avoid endless recursion, see #5289 Crash: Stack overflow in isImplicitlyVirtual_rec when checking SVN and
// #5590 with a loop within the class hierarchy.
Expand Down
9 changes: 9 additions & 0 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8558,6 +8558,15 @@ class TestClass : public TestFixture {
" }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:5]: (style) The function 'Calculate' overrides a function in a base class but is not marked with a 'override' specifier.\n", errout.str());

checkOverride("struct S {\n" // #12439
" virtual ~S() = default;\n"
"};\n"
"struct D : S {\n"
" ~D() {}\n"
"};\n");
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:5]: (style) The destructor '~D' overrides a destructor in a base class but is not marked with a 'override' specifier.\n",
errout.str());
}

void overrideCVRefQualifiers() {
Expand Down

0 comments on commit f303757

Please sign in to comment.