SymbolDatabase: Fix function lookup for '::func()'
This commit is contained in:
parent
d98ac017f7
commit
4a4b4963cc
|
@ -4547,6 +4547,9 @@ const Function* SymbolDatabase::findFunction(const Token *tok) const
|
|||
if (tok1->strAt(-1) == "::") {
|
||||
currScope = &scopeList.front();
|
||||
|
||||
if (Token::Match(tok1, "%name% ("))
|
||||
return currScope->findFunction(tok);
|
||||
|
||||
currScope = currScope->findRecordInNestedList(tok1->str());
|
||||
}
|
||||
|
||||
|
|
|
@ -353,6 +353,7 @@ private:
|
|||
TEST_CASE(findFunction28);
|
||||
TEST_CASE(findFunctionContainer);
|
||||
TEST_CASE(findFunctionExternC);
|
||||
TEST_CASE(findFunctionGlobalScope); // ::foo
|
||||
|
||||
TEST_CASE(valueTypeMatchParameter); // ValueType::matchParameter
|
||||
|
||||
|
@ -5770,6 +5771,22 @@ private:
|
|||
ASSERT(a->function());
|
||||
}
|
||||
|
||||
void findFunctionGlobalScope() {
|
||||
GET_SYMBOL_DB("struct S {\n"
|
||||
" void foo();\n"
|
||||
" int x;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"int bar(int x);\n"
|
||||
"\n"
|
||||
"void S::foo() {\n"
|
||||
" x = ::bar(x);\n"
|
||||
"}");
|
||||
const Token *bar = Token::findsimplematch(tokenizer.tokens(), "bar ( x )");
|
||||
ASSERT(bar);
|
||||
ASSERT(bar->function());
|
||||
}
|
||||
|
||||
void valueTypeMatchParameter() {
|
||||
ValueType vt_int(ValueType::Sign::SIGNED, ValueType::Type::INT, 0);
|
||||
ValueType vt_const_int(ValueType::Sign::SIGNED, ValueType::Type::INT, 0, 1);
|
||||
|
|
Loading…
Reference in New Issue