@@ -1323,7 +1323,7 @@ void SymbolDatabase::createSymbolDatabaseSetVariablePointers()
13231323 Token* memberTok = tok->next ()->link ()->tokAt (2 );
13241324 const Scope* scope = vt->containerTypeToken ->scope ();
13251325 const Type* contType{};
1326- const std::string typeStr = vt->containerTypeToken ->expressionString ();
1326+ const std::string& typeStr = vt->containerTypeToken ->str (); // TODO: handle complex type expressions
13271327 while (scope && !contType) {
13281328 contType = scope->findType (typeStr); // find the type stored in the container
13291329 scope = scope->nestedIn ;
@@ -2276,20 +2276,27 @@ void Variable::setValueType(const ValueType &valueType)
22762276 setFlag (fIsSmartPointer , true );
22772277}
22782278
2279- const Type * Variable::smartPointerType () const
2279+ const Type* Variable::smartPointerType () const
22802280{
22812281 if (!isSmartPointer ())
22822282 return nullptr ;
22832283
22842284 if (mValueType ->smartPointerType )
22852285 return mValueType ->smartPointerType ;
22862286
2287- // TODO: Cache result
2288- const Token *ptrType = typeStartToken ();
2289- while (Token::Match (ptrType, " %name%|::" ))
2290- ptrType = ptrType->next ();
2291- if (Token::Match (ptrType, " < %name% >" ))
2292- return ptrType->scope ()->findType (ptrType->next ()->str ());
2287+ // TODO: Cache result, handle more complex type expression
2288+ const Token* typeTok = typeStartToken ();
2289+ while (Token::Match (typeTok, " %name%|::" ))
2290+ typeTok = typeTok->next ();
2291+ if (Token::Match (typeTok, " < %name% >" )) {
2292+ const Scope* scope = typeTok->scope ();
2293+ const Type* ptrType{};
2294+ while (scope && !ptrType) {
2295+ ptrType = scope->findType (typeTok->next ()->str ());
2296+ scope = scope->nestedIn ;
2297+ }
2298+ return ptrType;
2299+ }
22932300 return nullptr ;
22942301}
22952302
0 commit comments