* Fix #10174 debug: Executable scope 'x' with unknown function

* Format

* Add test for #10198
This commit is contained in:
chrchr-github 2022-04-05 13:04:20 +02:00 committed by GitHub
parent 0000bb2792
commit 3ba6914563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 15 deletions

View File

@ -4880,21 +4880,45 @@ private:
} }
} }
void symboldatabase100() { // #10174 void symboldatabase100() {
GET_SYMBOL_DB("namespace N {\n" {
" struct S {};\n" GET_SYMBOL_DB("namespace N {\n" // #10174
" struct T { void f(S s); };\n" " struct S {};\n"
" void T::f(N::S s) {}\n" " struct T { void f(S s); };\n"
"}\n"); " void T::f(N::S s) {}\n"
ASSERT(db); "}\n");
ASSERT_EQUALS(1, db->functionScopes.size()); ASSERT(db);
auto it = std::find_if(db->scopeList.begin(), db->scopeList.end(), [](const Scope& s) { ASSERT_EQUALS(1, db->functionScopes.size());
return s.className == "T"; auto it = std::find_if(db->scopeList.begin(), db->scopeList.end(), [](const Scope& s) {
}); return s.className == "T";
ASSERT(it != db->scopeList.end()); });
const Function* function = findFunctionByName("f", &*it); ASSERT(it != db->scopeList.end());
ASSERT(function && function->token->str() == "f"); const Function* function = findFunctionByName("f", &*it);
ASSERT(function->hasBody()); ASSERT(function && function->token->str() == "f");
ASSERT(function->hasBody());
}
{
GET_SYMBOL_DB("namespace N {\n" // #10198
" class I {};\n"
" class A {\n"
" public:\n"
" A(I*);\n"
" };\n"
"}\n"
"using N::I;\n"
"namespace N {\n"
" A::A(I*) {}\n"
"}\n");
ASSERT(db);
ASSERT_EQUALS(1, db->functionScopes.size());
auto it = std::find_if(db->scopeList.begin(), db->scopeList.end(), [](const Scope& s) {
return s.className == "A";
});
ASSERT(it != db->scopeList.end());
const Function* function = findFunctionByName("A", &*it);
ASSERT(function && function->token->str() == "A");
ASSERT(function->hasBody());
}
} }
void createSymbolDatabaseFindAllScopes1() { void createSymbolDatabaseFindAllScopes1() {