From e95ff8c7b6768c07d277225dbfd5842ce64832a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 14 Apr 2018 19:24:35 +0200 Subject: [PATCH] Avoiding emplace --- lib/checkother.cpp | 2 +- lib/checkstl.cpp | 6 +++--- lib/checkunusedvar.cpp | 2 +- lib/tokenize.cpp | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index cd269709a..28eabc05e 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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 diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index b5cae2a8f..f013c2cfc 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -1069,16 +1069,16 @@ void CheckStl::string_c_str() for (std::list::const_iterator scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) { for (std::list::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::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)); } } } diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index 4735474a9..3f00311ed 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -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))); } } diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 2ef761997..9bbf87424 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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(name, nameTok)); } }