Merge branch 'master' of https://github.com/danmar/cppcheck
This commit is contained in:
commit
6c43cb2e28
|
@ -365,22 +365,22 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
// copy/move constructor?
|
// copy/move constructor?
|
||||||
else if (Token::Match(function.tokenDef, "%name% ( const| %name% &|&& &| %name%| )") ||
|
else if (Token::Match(function.tokenDef, "%name% ( const| %name% &|&& &| %name%| )") ||
|
||||||
Token::Match(function.tokenDef, "%name% ( const| %name% <")) {
|
Token::Match(function.tokenDef, "%name% ( const| %name% <")) {
|
||||||
const Token* typTok = function.tokenDef->tokAt(2);
|
const Token* typeTok = function.tokenDef->tokAt(2);
|
||||||
if (typTok->str() == "const")
|
if (typeTok->str() == "const")
|
||||||
typTok = typTok->next();
|
typeTok = typeTok->next();
|
||||||
if (typTok->strAt(1) == "<") { // TODO: Remove this branch (#4710)
|
if (typeTok->strAt(1) == "<") { // TODO: Remove this branch (#4710)
|
||||||
if (Token::Match(typTok->linkAt(1), "> & %name%| )"))
|
if (Token::Match(typeTok->linkAt(1), "> & %name%| )"))
|
||||||
function.type = Function::eCopyConstructor;
|
function.type = Function::eCopyConstructor;
|
||||||
else if (Token::Match(typTok->linkAt(1), "> &&|& & %name%| )"))
|
else if (Token::Match(typeTok->linkAt(1), "> &&|& & %name%| )"))
|
||||||
function.type = Function::eMoveConstructor;
|
function.type = Function::eMoveConstructor;
|
||||||
else
|
else
|
||||||
function.type = Function::eConstructor;
|
function.type = Function::eConstructor;
|
||||||
} else if (typTok->strAt(1) == "&&" || typTok->strAt(2) == "&")
|
} else if (typeTok->strAt(1) == "&&" || typeTok->strAt(2) == "&")
|
||||||
function.type = Function::eMoveConstructor;
|
function.type = Function::eMoveConstructor;
|
||||||
else
|
else
|
||||||
function.type = Function::eCopyConstructor;
|
function.type = Function::eCopyConstructor;
|
||||||
|
|
||||||
if (typTok->str() != function.tokenDef->str())
|
if (typeTok->str() != function.tokenDef->str())
|
||||||
function.type = Function::eConstructor; // Overwrite, if types are not identical
|
function.type = Function::eConstructor; // Overwrite, if types are not identical
|
||||||
}
|
}
|
||||||
// regular constructor
|
// regular constructor
|
||||||
|
@ -2528,6 +2528,29 @@ void SymbolDatabase::printXml(std::ostream &out) const
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static const Type* findVariableTypeIncludingUsedNamespaces(const SymbolDatabase* symbolDatabase, const Scope* scope, const Token* typeTok)
|
||||||
|
{
|
||||||
|
const Type* argType = symbolDatabase->findVariableType(scope, typeTok);
|
||||||
|
if (argType)
|
||||||
|
return argType;
|
||||||
|
|
||||||
|
// look for variable type in any using namespace in this scope or above
|
||||||
|
while (scope) {
|
||||||
|
for (std::list<Scope::UsingInfo>::const_iterator ui = scope->usingList.begin();
|
||||||
|
ui != scope->usingList.end(); ++ui) {
|
||||||
|
if (ui->scope) {
|
||||||
|
argType = symbolDatabase->findVariableType(ui->scope, typeTok);
|
||||||
|
if (argType)
|
||||||
|
return argType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scope = scope->nestedIn;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *scope)
|
void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *scope)
|
||||||
{
|
{
|
||||||
// check for non-empty argument list "( ... )"
|
// check for non-empty argument list "( ... )"
|
||||||
|
@ -2587,24 +2610,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
|
||||||
|
|
||||||
const ::Type *argType = nullptr;
|
const ::Type *argType = nullptr;
|
||||||
if (!typeTok->isStandardType()) {
|
if (!typeTok->isStandardType()) {
|
||||||
argType = symbolDatabase->findVariableType(scope, typeTok);
|
argType = findVariableTypeIncludingUsedNamespaces(symbolDatabase, scope, typeTok);
|
||||||
if (!argType) {
|
|
||||||
// look for variable type in any using namespace in this scope or above
|
|
||||||
const Scope *currentScope = scope;
|
|
||||||
while (currentScope) {
|
|
||||||
for (std::list<Scope::UsingInfo>::const_iterator ui = currentScope->usingList.begin();
|
|
||||||
ui != currentScope->usingList.end(); ++ui) {
|
|
||||||
if (ui->scope) {
|
|
||||||
argType = symbolDatabase->findVariableType(ui->scope, typeTok);
|
|
||||||
if (argType)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (argType)
|
|
||||||
break;
|
|
||||||
currentScope = currentScope->nestedIn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip default values
|
// skip default values
|
||||||
|
@ -2956,24 +2962,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con
|
||||||
const Type *vType = nullptr;
|
const Type *vType = nullptr;
|
||||||
|
|
||||||
if (typetok) {
|
if (typetok) {
|
||||||
vType = check->findVariableType(this, typetok);
|
vType = findVariableTypeIncludingUsedNamespaces(check, this, typetok);
|
||||||
if (!vType) {
|
|
||||||
// look for variable type in any using namespace in this scope or above
|
|
||||||
const Scope *parent = this;
|
|
||||||
while (parent) {
|
|
||||||
for (std::list<Scope::UsingInfo>::const_iterator ui = parent->usingList.begin();
|
|
||||||
ui != parent->usingList.end(); ++ui) {
|
|
||||||
if (ui->scope) {
|
|
||||||
vType = check->findVariableType(ui->scope, typetok);
|
|
||||||
if (vType)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vType)
|
|
||||||
break;
|
|
||||||
parent = parent->nestedIn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addVariable(vartok, typestart, vartok->previous(), varaccess, vType, this, lib);
|
addVariable(vartok, typestart, vartok->previous(), varaccess, vType, this, lib);
|
||||||
|
|
Loading…
Reference in New Issue