Avoiding emplace

This commit is contained in:
Daniel Marjamäki 2018-04-14 19:24:35 +02:00
parent e73fe49d3c
commit e95ff8c7b6
4 changed files with 8 additions and 8 deletions

View File

@ -1829,7 +1829,7 @@ void CheckOther::checkInvalidFree()
// Keep track of which variables were assigned addresses to newly-allocated memory
if (Token::Match(tok, "%var% = malloc|g_malloc|new")) {
allocatedVariables.emplace(tok->varId(), false);
allocatedVariables.insert(std::make_pair(tok->varId(), false));
}
// If a previously-allocated pointer is incremented or decremented, any subsequent

View File

@ -1069,16 +1069,16 @@ void CheckStl::string_c_str()
for (std::list<Scope>::const_iterator scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
if (c_strFuncParam.erase(func->tokenDef->str()) != 0) { // Check if function with this name was already found
c_strFuncParam.emplace(func->tokenDef->str(), 0); // Disable, because there are overloads. TODO: Handle overloads
c_strFuncParam.insert(std::make_pair(func->tokenDef->str(), 0)); // Disable, because there are overloads. TODO: Handle overloads
continue;
}
unsigned int numpar = 0;
c_strFuncParam.emplace(func->tokenDef->str(), numpar); // Insert function as dummy, to indicate that there is at least one function with that name
c_strFuncParam.insert(std::make_pair(func->tokenDef->str(), numpar)); // Insert function as dummy, to indicate that there is at least one function with that name
for (std::list<Variable>::const_iterator var = func->argumentList.cbegin(); var != func->argumentList.cend(); ++var) {
numpar++;
if (var->isStlStringType() && (!var->isReference() || var->isConst()))
c_strFuncParam.emplace(func->tokenDef->str(), numpar);
c_strFuncParam.insert(std::make_pair(func->tokenDef->str(), numpar));
}
}
}

View File

@ -247,7 +247,7 @@ void Variables::addVar(const Variable *var,
{
if (var->declarationId() > 0) {
_varAddedInScope.back().insert(var->declarationId());
_varUsage.emplace(var->declarationId(), VariableUsage(var, type, false, write_, false));
_varUsage.insert(std::make_pair(var->declarationId(), VariableUsage(var, type, false, write_, false)));
}
}

View File

@ -2602,7 +2602,7 @@ void Tokenizer::setVarIdPass1()
variableId.swap(scopeInfo.top());
scopeInfo.pop();
} else if (tok->str() == "{")
scopeStack.emplace(true, scopeStack.top().isStructInit || tok->strAt(-1) == "=", /*isEnum=*/false, _varId);
scopeStack.push(VarIdScopeInfo(true, scopeStack.top().isStructInit || tok->strAt(-1) == "=", /*isEnum=*/false, _varId));
} else if (!initlist && tok->str()=="(") {
const Token * newFunctionDeclEnd = nullptr;
if (!scopeStack.top().isExecutable)
@ -2638,7 +2638,7 @@ void Tokenizer::setVarIdPass1()
scopeInfo.push(variableId);
}
initlist = false;
scopeStack.emplace(isExecutable, scopeStack.top().isStructInit || tok->strAt(-1) == "=", isEnumStart(tok), _varId);
scopeStack.push(VarIdScopeInfo(isExecutable, scopeStack.top().isStructInit || tok->strAt(-1) == "=", isEnumStart(tok), _varId));
} else { /* if (tok->str() == "}") */
bool isNamespace = false;
for (const Token *tok1 = tok->link()->previous(); tok1 && tok1->isName(); tok1 = tok1->previous()) {
@ -9945,7 +9945,7 @@ void Tokenizer::printUnknownTypes() const
}
}
unknowns.emplace(name, nameTok);
unknowns.insert(std::pair<std::string, const Token *>(name, nameTok));
}
}