Avoiding emplace
This commit is contained in:
parent
e73fe49d3c
commit
e95ff8c7b6
|
@ -1829,7 +1829,7 @@ void CheckOther::checkInvalidFree()
|
||||||
|
|
||||||
// Keep track of which variables were assigned addresses to newly-allocated memory
|
// Keep track of which variables were assigned addresses to newly-allocated memory
|
||||||
if (Token::Match(tok, "%var% = malloc|g_malloc|new")) {
|
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
|
// If a previously-allocated pointer is incremented or decremented, any subsequent
|
||||||
|
|
|
@ -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<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) {
|
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
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int numpar = 0;
|
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) {
|
for (std::list<Variable>::const_iterator var = func->argumentList.cbegin(); var != func->argumentList.cend(); ++var) {
|
||||||
numpar++;
|
numpar++;
|
||||||
if (var->isStlStringType() && (!var->isReference() || var->isConst()))
|
if (var->isStlStringType() && (!var->isReference() || var->isConst()))
|
||||||
c_strFuncParam.emplace(func->tokenDef->str(), numpar);
|
c_strFuncParam.insert(std::make_pair(func->tokenDef->str(), numpar));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,7 @@ void Variables::addVar(const Variable *var,
|
||||||
{
|
{
|
||||||
if (var->declarationId() > 0) {
|
if (var->declarationId() > 0) {
|
||||||
_varAddedInScope.back().insert(var->declarationId());
|
_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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2602,7 +2602,7 @@ void Tokenizer::setVarIdPass1()
|
||||||
variableId.swap(scopeInfo.top());
|
variableId.swap(scopeInfo.top());
|
||||||
scopeInfo.pop();
|
scopeInfo.pop();
|
||||||
} else if (tok->str() == "{")
|
} 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()=="(") {
|
} else if (!initlist && tok->str()=="(") {
|
||||||
const Token * newFunctionDeclEnd = nullptr;
|
const Token * newFunctionDeclEnd = nullptr;
|
||||||
if (!scopeStack.top().isExecutable)
|
if (!scopeStack.top().isExecutable)
|
||||||
|
@ -2638,7 +2638,7 @@ void Tokenizer::setVarIdPass1()
|
||||||
scopeInfo.push(variableId);
|
scopeInfo.push(variableId);
|
||||||
}
|
}
|
||||||
initlist = false;
|
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() == "}") */
|
} else { /* if (tok->str() == "}") */
|
||||||
bool isNamespace = false;
|
bool isNamespace = false;
|
||||||
for (const Token *tok1 = tok->link()->previous(); tok1 && tok1->isName(); tok1 = tok1->previous()) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue