SymbolDatabase: Fix crash if std::shared_ptr type is only forwarded, not defined
This commit is contained in:
parent
e50b9e2bef
commit
82d8f3e7f5
|
@ -1175,7 +1175,8 @@ void SymbolDatabase::createSymbolDatabaseSetVariablePointers()
|
|||
fixVarId(varIds, tok, const_cast<Token *>(membertok), membervar);
|
||||
}
|
||||
} else if (const ::Type *type = var ? var->smartPointerType() : nullptr) {
|
||||
const Variable *membervar = type->classScope->getVariable(membertok->str());
|
||||
const Scope *classScope = type->classScope;
|
||||
const Variable *membervar = classScope ? classScope->getVariable(membertok->str()) : nullptr;
|
||||
if (membervar) {
|
||||
membertok->variable(membervar);
|
||||
if (membertok->varId() == 0 || mVariableList[membertok->varId()] == nullptr)
|
||||
|
|
|
@ -352,6 +352,7 @@ private:
|
|||
TEST_CASE(findFunction27);
|
||||
TEST_CASE(findFunction28);
|
||||
TEST_CASE(findFunction29);
|
||||
TEST_CASE(findFunction30);
|
||||
TEST_CASE(findFunctionContainer);
|
||||
TEST_CASE(findFunctionExternC);
|
||||
TEST_CASE(findFunctionGlobalScope); // ::foo
|
||||
|
@ -5776,6 +5777,16 @@ private:
|
|||
ASSERT_EQUALS(2, foo->function()->token->linenr());
|
||||
}
|
||||
|
||||
void findFunction30() {
|
||||
GET_SYMBOL_DB("struct A;\n"
|
||||
"void foo(std::shared_ptr<A> ptr) {\n"
|
||||
" int x = ptr->bar();\n"
|
||||
"}");
|
||||
const Token *bar = Token::findsimplematch(tokenizer.tokens(), "bar ( ) ;");
|
||||
ASSERT(bar);
|
||||
ASSERT(!bar->function());
|
||||
}
|
||||
|
||||
void findFunctionContainer() {
|
||||
{
|
||||
GET_SYMBOL_DB("void dostuff(std::vector<int> v);\n"
|
||||
|
|
Loading…
Reference in New Issue