@@ -365,22 +365,22 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
365365 // copy/move constructor?
366366 else if (Token::Match (function.tokenDef , " %name% ( const| %name% &|&& &| %name%| )" ) ||
367367 Token::Match (function.tokenDef , " %name% ( const| %name% <" )) {
368- const Token* typTok = function.tokenDef ->tokAt (2 );
369- if (typTok ->str () == " const" )
370- typTok = typTok ->next ();
371- if (typTok ->strAt (1 ) == " <" ) { // TODO: Remove this branch (#4710)
372- if (Token::Match (typTok ->linkAt (1 ), " > & %name%| )" ))
368+ const Token* typeTok = function.tokenDef ->tokAt (2 );
369+ if (typeTok ->str () == " const" )
370+ typeTok = typeTok ->next ();
371+ if (typeTok ->strAt (1 ) == " <" ) { // TODO: Remove this branch (#4710)
372+ if (Token::Match (typeTok ->linkAt (1 ), " > & %name%| )" ))
373373 function.type = Function::eCopyConstructor;
374- else if (Token::Match (typTok ->linkAt (1 ), " > &&|& & %name%| )" ))
374+ else if (Token::Match (typeTok ->linkAt (1 ), " > &&|& & %name%| )" ))
375375 function.type = Function::eMoveConstructor;
376376 else
377377 function.type = Function::eConstructor;
378- } else if (typTok ->strAt (1 ) == " &&" || typTok ->strAt (2 ) == " &" )
378+ } else if (typeTok ->strAt (1 ) == " &&" || typeTok ->strAt (2 ) == " &" )
379379 function.type = Function::eMoveConstructor;
380380 else
381381 function.type = Function::eCopyConstructor;
382382
383- if (typTok ->str () != function.tokenDef ->str ())
383+ if (typeTok ->str () != function.tokenDef ->str ())
384384 function.type = Function::eConstructor; // Overwrite, if types are not identical
385385 }
386386 // regular constructor
@@ -2528,6 +2528,29 @@ void SymbolDatabase::printXml(std::ostream &out) const
25282528
25292529// ---------------------------------------------------------------------------
25302530
2531+ static const Type* findVariableTypeIncludingUsedNamespaces (const SymbolDatabase* symbolDatabase, const Scope* scope, const Token* typeTok)
2532+ {
2533+ const Type* argType = symbolDatabase->findVariableType (scope, typeTok);
2534+ if (argType)
2535+ return argType;
2536+
2537+ // look for variable type in any using namespace in this scope or above
2538+ while (scope) {
2539+ for (std::list<Scope::UsingInfo>::const_iterator ui = scope->usingList .begin ();
2540+ ui != scope->usingList .end (); ++ui) {
2541+ if (ui->scope ) {
2542+ argType = symbolDatabase->findVariableType (ui->scope , typeTok);
2543+ if (argType)
2544+ return argType;
2545+ }
2546+ }
2547+ scope = scope->nestedIn ;
2548+ }
2549+ return nullptr ;
2550+ }
2551+
2552+ // ---------------------------------------------------------------------------
2553+
25312554void Function::addArguments (const SymbolDatabase *symbolDatabase, const Scope *scope)
25322555{
25332556 // check for non-empty argument list "( ... )"
@@ -2587,24 +2610,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
25872610
25882611 const ::Type *argType = nullptr ;
25892612 if (!typeTok->isStandardType ()) {
2590- argType = symbolDatabase->findVariableType (scope, typeTok);
2591- if (!argType) {
2592- // look for variable type in any using namespace in this scope or above
2593- const Scope *currentScope = scope;
2594- while (currentScope) {
2595- for (std::list<Scope::UsingInfo>::const_iterator ui = currentScope->usingList .begin ();
2596- ui != currentScope->usingList .end (); ++ui) {
2597- if (ui->scope ) {
2598- argType = symbolDatabase->findVariableType (ui->scope , typeTok);
2599- if (argType)
2600- break ;
2601- }
2602- }
2603- if (argType)
2604- break ;
2605- currentScope = currentScope->nestedIn ;
2606- }
2607- }
2613+ argType = findVariableTypeIncludingUsedNamespaces (symbolDatabase, scope, typeTok);
26082614 }
26092615
26102616 // skip default values
@@ -2956,24 +2962,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con
29562962 const Type *vType = nullptr ;
29572963
29582964 if (typetok) {
2959- vType = check->findVariableType (this , typetok);
2960- if (!vType) {
2961- // look for variable type in any using namespace in this scope or above
2962- const Scope *parent = this ;
2963- while (parent) {
2964- for (std::list<Scope::UsingInfo>::const_iterator ui = parent->usingList .begin ();
2965- ui != parent->usingList .end (); ++ui) {
2966- if (ui->scope ) {
2967- vType = check->findVariableType (ui->scope , typetok);
2968- if (vType)
2969- break ;
2970- }
2971- }
2972- if (vType)
2973- break ;
2974- parent = parent->nestedIn ;
2975- }
2976- }
2965+ vType = findVariableTypeIncludingUsedNamespaces (check, this , typetok);
29772966 }
29782967
29792968 addVariable (vartok, typestart, vartok->previous (), varaccess, vType, this , lib);
0 commit comments