Skip to content

Commit

Permalink
Fix #13637 Stack overflow in findShadowed() (#7306)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Feb 15, 2025
1 parent 2e4f606 commit 391a109
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3396,8 +3396,11 @@ void SymbolDatabase::addClassFunction(Scope *&scope, const Token *&tok, const To
const Token *closeParen = tok->linkAt(1);
if (closeParen) {
const Token *eq = TokenList::isFunctionHead(closeParen, ";");
if (eq && Token::simpleMatch(eq->tokAt(-2), "= default ;")) {
func->isDefault(true);
if (eq && Token::Match(eq->tokAt(-2), "= default|delete ;")) {
if (eq->strAt(-1) == "default")
func->isDefault(true);
else
func->isDelete(true);
return;
}
if (func->type == Function::eDestructor && destructor) {
Expand Down
18 changes: 18 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5727,6 +5727,24 @@ class TestSymbolDatabase : public TestFixture {
ASSERT(it->isDefault());
ASSERT_EQUALS(it->type, Function::Type::eDestructor);
}
{
GET_SYMBOL_DB("struct S {\n" // #13637
" ~S();\n"
"};\n"
"S::~S() = delete;\n");
ASSERT_EQUALS(db->scopeList.size(), 2);
auto scope = db->scopeList.begin();
ASSERT(!scope->functionOf);
++scope;
ASSERT_EQUALS(scope->className, "S");
ASSERT_EQUALS(scope->functionList.size(), 1);
auto it = scope->functionList.begin();
ASSERT_EQUALS(it->name(), "S");
ASSERT_EQUALS(it->tokenDef->linenr(), 2);
ASSERT(it->isDelete());
ASSERT(!it->isDefault());
ASSERT_EQUALS(it->type, Function::Type::eDestructor);
}
}

void symboldatabase109() { // #13553
Expand Down

0 comments on commit 391a109

Please sign in to comment.