This commit is contained in:
parent
36192c50f6
commit
29b651f264
|
@ -1323,7 +1323,7 @@ void SymbolDatabase::createSymbolDatabaseSetVariablePointers()
|
||||||
Token* memberTok = tok->next()->link()->tokAt(2);
|
Token* memberTok = tok->next()->link()->tokAt(2);
|
||||||
const Scope* scope = vt->containerTypeToken->scope();
|
const Scope* scope = vt->containerTypeToken->scope();
|
||||||
const Type* contType{};
|
const Type* contType{};
|
||||||
const std::string typeStr = vt->containerTypeToken->expressionString();
|
const std::string& typeStr = vt->containerTypeToken->str(); // TODO: handle complex type expressions
|
||||||
while (scope && !contType) {
|
while (scope && !contType) {
|
||||||
contType = scope->findType(typeStr); // find the type stored in the container
|
contType = scope->findType(typeStr); // find the type stored in the container
|
||||||
scope = scope->nestedIn;
|
scope = scope->nestedIn;
|
||||||
|
@ -2276,7 +2276,7 @@ void Variable::setValueType(const ValueType &valueType)
|
||||||
setFlag(fIsSmartPointer, true);
|
setFlag(fIsSmartPointer, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Type *Variable::smartPointerType() const
|
const Type* Variable::smartPointerType() const
|
||||||
{
|
{
|
||||||
if (!isSmartPointer())
|
if (!isSmartPointer())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2284,12 +2284,19 @@ const Type *Variable::smartPointerType() const
|
||||||
if (mValueType->smartPointerType)
|
if (mValueType->smartPointerType)
|
||||||
return mValueType->smartPointerType;
|
return mValueType->smartPointerType;
|
||||||
|
|
||||||
// TODO: Cache result
|
// TODO: Cache result, handle more complex type expression
|
||||||
const Token *ptrType = typeStartToken();
|
const Token* typeTok = typeStartToken();
|
||||||
while (Token::Match(ptrType, "%name%|::"))
|
while (Token::Match(typeTok, "%name%|::"))
|
||||||
ptrType = ptrType->next();
|
typeTok = typeTok->next();
|
||||||
if (Token::Match(ptrType, "< %name% >"))
|
if (Token::Match(typeTok, "< %name% >")) {
|
||||||
return ptrType->scope()->findType(ptrType->next()->str());
|
const Scope* scope = typeTok->scope();
|
||||||
|
const Type* ptrType{};
|
||||||
|
while (scope && !ptrType) {
|
||||||
|
ptrType = scope->findType(typeTok->next()->str());
|
||||||
|
scope = scope->nestedIn;
|
||||||
|
}
|
||||||
|
return ptrType;
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1966,6 +1966,17 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("struct S {\n" // #11543
|
||||||
|
" S() {}\n"
|
||||||
|
" std::vector<std::shared_ptr<S>> v;\n"
|
||||||
|
" void f(int i) const;\n"
|
||||||
|
"};\n"
|
||||||
|
"void S::f(int i) const {\n"
|
||||||
|
" for (const std::shared_ptr<S>& c : v)\n"
|
||||||
|
" c->f(i);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("namespace N {\n"
|
check("namespace N {\n"
|
||||||
" struct S { static const std::set<std::string> s; };\n"
|
" struct S { static const std::set<std::string> s; };\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
Loading…
Reference in New Issue