fix exprengine.cpp:2833:18: debug: Executable scope 'executeAllFunctions' with unknown function. (#3019)

This commit is contained in:
IOBYTE 2021-01-06 11:29:23 -05:00 committed by GitHub
parent 50cdb6cbfc
commit c085151eb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 3 deletions

View File

@ -2356,11 +2356,15 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
int arg_path_length = path_length; int arg_path_length = path_length;
int offset = 0; int offset = 0;
int openParen = 0;
while (first->str() == second->str() && while (first->str() == second->str() &&
first->isLong() == second->isLong() && first->isLong() == second->isLong() &&
first->isUnsigned() == second->isUnsigned()) { first->isUnsigned() == second->isUnsigned()) {
if (first->str() == "(")
openParen++;
// skip optional type information // skip optional type information
if (Token::Match(first->next(), "struct|enum|union|class")) if (Token::Match(first->next(), "struct|enum|union|class"))
first = first->next(); first = first->next();
@ -2377,7 +2381,10 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
// at end of argument list // at end of argument list
if (first->str() == ")") { if (first->str() == ")") {
return true; if (openParen == 1)
return true;
else
--openParen;
} }
// skip default value assignment // skip default value assignment
@ -2483,8 +2490,11 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
std::string param = path; std::string param = path;
if (Token::simpleMatch(second->next(), param.c_str(), param.size())) { if (Token::simpleMatch(second->next(), param.c_str(), param.size())) {
second = second->tokAt(int(arg_path_length)); // check for redundant qualification before skipping it
arg_path_length = 0; if (!Token::simpleMatch(first->next(), param.c_str(), param.size())) {
second = second->tokAt(int(arg_path_length));
arg_path_length = 0;
}
} }
// nested or base class variable // nested or base class variable

View File

@ -343,6 +343,7 @@ private:
TEST_CASE(symboldatabase88); // #10040 (using namespace) TEST_CASE(symboldatabase88); // #10040 (using namespace)
TEST_CASE(symboldatabase89); // valuetype name TEST_CASE(symboldatabase89); // valuetype name
TEST_CASE(symboldatabase90); TEST_CASE(symboldatabase90);
TEST_CASE(symboldatabase91);
TEST_CASE(createSymbolDatabaseFindAllScopes1); TEST_CASE(createSymbolDatabaseFindAllScopes1);
@ -4658,6 +4659,20 @@ private:
ASSERT(functok->function()->name() == "foo"); ASSERT(functok->function()->name() == "foo");
} }
void symboldatabase91() {
GET_SYMBOL_DB("namespace Fred {\n"
" struct Value {};\n"
" void foo(const std::vector<std::function<void(const Fred::Value &)>> &callbacks);\n"
"}\n"
"void Fred::foo(const std::vector<std::function<void(const Fred::Value &)>> &callbacks) { }");
ASSERT_EQUALS("", errout.str());
const Token *functok = Token::findsimplematch(tokenizer.tokens(),
"foo ( const std :: vector < std :: function < void ( const Fred :: Value & ) > > & callbacks ) { }");
ASSERT(functok);
ASSERT(functok->function());
ASSERT(functok->function()->name() == "foo");
}
void createSymbolDatabaseFindAllScopes1() { void createSymbolDatabaseFindAllScopes1() {
GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }"); GET_SYMBOL_DB("void f() { union {int x; char *p;} a={0}; }");
ASSERT(db->scopeList.size() == 3); ASSERT(db->scopeList.size() == 3);