fix #10135 ("debug: Executable scope 'what' with unknown function." with custom std::exception) (#3089)
This commit is contained in:
parent
e17d22eb87
commit
6914f375e1
|
@ -2429,10 +2429,17 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
|
||||||
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() == "(")
|
if (first->str() == "(")
|
||||||
openParen++;
|
openParen++;
|
||||||
|
|
||||||
|
// at end of argument list
|
||||||
|
else if (first->str() == ")") {
|
||||||
|
if (openParen == 1)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
--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();
|
||||||
|
@ -2447,14 +2454,6 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
|
||||||
!Token::Match(second->next(), "const %type% %name%| ["))
|
!Token::Match(second->next(), "const %type% %name%| ["))
|
||||||
second = second->next();
|
second = second->next();
|
||||||
|
|
||||||
// at end of argument list
|
|
||||||
if (first->str() == ")") {
|
|
||||||
if (openParen == 1)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
--openParen;
|
|
||||||
}
|
|
||||||
|
|
||||||
// skip default value assignment
|
// skip default value assignment
|
||||||
else if (first->next()->str() == "=") {
|
else if (first->next()->str() == "=") {
|
||||||
first = first->nextArgument();
|
first = first->nextArgument();
|
||||||
|
@ -2506,7 +2505,7 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
|
||||||
first = first->next();
|
first = first->next();
|
||||||
|
|
||||||
// argument list has different number of arguments
|
// argument list has different number of arguments
|
||||||
else if (second->str() == ")")
|
else if (openParen == 1 && second->str() == ")" && first->str() != ")")
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ckeck for type * x == type x[]
|
// ckeck for type * x == type x[]
|
||||||
|
|
|
@ -404,6 +404,7 @@ private:
|
||||||
TEST_CASE(findFunction37); // #10124
|
TEST_CASE(findFunction37); // #10124
|
||||||
TEST_CASE(findFunction38); // #10125
|
TEST_CASE(findFunction38); // #10125
|
||||||
TEST_CASE(findFunction39); // #10127
|
TEST_CASE(findFunction39); // #10127
|
||||||
|
TEST_CASE(findFunction40); // #10135
|
||||||
TEST_CASE(findFunctionContainer);
|
TEST_CASE(findFunctionContainer);
|
||||||
TEST_CASE(findFunctionExternC);
|
TEST_CASE(findFunctionExternC);
|
||||||
TEST_CASE(findFunctionGlobalScope); // ::foo
|
TEST_CASE(findFunctionGlobalScope); // ::foo
|
||||||
|
@ -6343,6 +6344,22 @@ private:
|
||||||
ASSERT_EQUALS(8, functok->function()->tokenDef->linenr());
|
ASSERT_EQUALS(8, functok->function()->tokenDef->linenr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void findFunction40() { // #10135
|
||||||
|
GET_SYMBOL_DB("class E : public std::exception {\n"
|
||||||
|
"public:\n"
|
||||||
|
" const char* what() const noexcept override;\n"
|
||||||
|
"};\n"
|
||||||
|
"const char* E::what() const noexcept {\n"
|
||||||
|
" return nullptr;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
const Token *functok = Token::findsimplematch(tokenizer.tokens(), "what ( ) const noexcept {");
|
||||||
|
ASSERT(functok);
|
||||||
|
ASSERT(functok->function());
|
||||||
|
ASSERT(functok->function()->name() == "what");
|
||||||
|
ASSERT_EQUALS(3, functok->function()->tokenDef->linenr());
|
||||||
|
}
|
||||||
|
|
||||||
void findFunctionContainer() {
|
void findFunctionContainer() {
|
||||||
{
|
{
|
||||||
GET_SYMBOL_DB("void dostuff(std::vector<int> v);\n"
|
GET_SYMBOL_DB("void dostuff(std::vector<int> v);\n"
|
||||||
|
|
Loading…
Reference in New Issue