Symbol database: Improved function lookup for foo.f(). Ticket #4494
This commit is contained in:
parent
683c8adb74
commit
cecd726b11
|
@ -2434,6 +2434,19 @@ const Function* SymbolDatabase::findFunctionByNameAndArgs(const Token *tok, cons
|
|||
}
|
||||
}
|
||||
|
||||
// check for member function
|
||||
else if (tok->strAt(-1) == ".") {
|
||||
if (Token::Match(tok->tokAt(-2), "%var% .")) {
|
||||
const Token *tok1 = tok->tokAt(-2);
|
||||
|
||||
if (tok1->varId()) {
|
||||
const Variable *var = getVariableFromVarId(tok1->varId());
|
||||
if (var && var->type())
|
||||
return findFunctionByNameAndArgsInScope(tok, var->type());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check in enclosing scopes
|
||||
else {
|
||||
while (currScope) {
|
||||
|
|
|
@ -2714,6 +2714,17 @@ private:
|
|||
"[test.cpp:13]: (error) Uninitialized variable: p\n"
|
||||
"[test.cpp:15]: (error) Uninitialized variable: p\n"
|
||||
"[test.cpp:17]: (error) Uninitialized variable: p\n", errout.str());
|
||||
|
||||
checkUninitVar2("class Fred {\n"
|
||||
"public:\n"
|
||||
" void f1(char *p) { *p = 0; }\n"
|
||||
"};\n"
|
||||
"Fred fred;\n"
|
||||
"void f(void) {\n"
|
||||
" char *p;\n"
|
||||
" fred.f1(p);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (error) Uninitialized variable: p\n", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue