Symboldatabase: improved look up of delegate constructors
This commit is contained in:
parent
189dfd64f7
commit
67385cfc4b
|
@ -444,7 +444,7 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
|
|||
if (ftok->str() != func.name()) {
|
||||
initVar(ftok->str(), scope, usage);
|
||||
} else { // c++11 delegate constructor
|
||||
const Function *member = scope->findFunction(ftok);
|
||||
const Function *member = ftok->function();
|
||||
// member function found
|
||||
if (member) {
|
||||
// recursive call
|
||||
|
|
|
@ -1125,6 +1125,27 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
}
|
||||
}
|
||||
|
||||
// Set C++ 11 delegate constructor function call pointers
|
||||
for (std::list<Scope>::iterator it = scopeList.begin(); it != scopeList.end(); ++it) {
|
||||
for (std::list<Function>::const_iterator func = it->functionList.begin(); func != it->functionList.end(); ++func) {
|
||||
// look for initializer list
|
||||
if (func->type == Function::eConstructor && func->functionScope &&
|
||||
func->functionScope->functionOf && func->arg && func->arg->link()->strAt(1) == ":") {
|
||||
const Token * tok = func->arg->link()->tokAt(2);
|
||||
while (tok && tok != func->functionScope->classStart) {
|
||||
if (Token::Match(tok, "%var% {")) {
|
||||
if (tok->str() == func->tokenDef->str()) {
|
||||
const_cast<Token *>(tok)->function(func->functionScope->functionOf->findFunction(tok));
|
||||
break;
|
||||
}
|
||||
tok = tok->linkAt(1);
|
||||
}
|
||||
tok = tok->next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set variable pointers
|
||||
for (const Token* tok = _tokenizer->list.front(); tok != _tokenizer->list.back(); tok = tok->next()) {
|
||||
if (tok->varId())
|
||||
|
@ -2926,12 +2947,12 @@ const Function* Scope::findFunction(const Token *tok) const
|
|||
for (it = functionList.begin(); it != functionList.end(); ++it) {
|
||||
if (it->tokenDef->str() == tok->str()) {
|
||||
const Function *func = &*it;
|
||||
if ((tok->strAt(1) == "(" || (func->name() == tok->str() && tok->strAt(1) == "{" && func->type == Function::eConstructor)) && tok->tokAt(2)) {
|
||||
std::string end(tok->strAt(1) == "{" ? "}" : ")");
|
||||
const Token *end = tok->linkAt(1);
|
||||
if (end) {
|
||||
// check the arguments
|
||||
unsigned int args = 0;
|
||||
const Token *arg = tok->tokAt(2);
|
||||
while (arg && arg->str() != end) {
|
||||
while (arg && arg != end) {
|
||||
/** @todo check argument type for match */
|
||||
|
||||
// mismatch parameter: passing parameter by address to function, argument is reference
|
||||
|
|
Loading…
Reference in New Issue