Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/checkio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ void CheckIO::checkFileUsage()

if (var->isLocal()) {
if (var->nameToken()->strAt(1) == "(") // initialize by calling "ctor"
filepointers.insert(std::make_pair(var->declarationId(), Filepointer(OpenMode::UNKNOWN_OM)));
filepointers.emplace(var->declarationId(), Filepointer(OpenMode::UNKNOWN_OM));
else
filepointers.insert(std::make_pair(var->declarationId(), Filepointer(OpenMode::CLOSED)));
filepointers.emplace(var->declarationId(), Filepointer(OpenMode::CLOSED));
} else {
filepointers.insert(std::make_pair(var->declarationId(), Filepointer(OpenMode::UNKNOWN_OM)));
filepointers.emplace(var->declarationId(), Filepointer(OpenMode::UNKNOWN_OM));
// TODO: If all fopen calls we find open the file in the same type, we can set Filepointer::mode
}
}
Expand Down Expand Up @@ -281,9 +281,8 @@ void CheckIO::checkFileUsage()
if (!fileTok || !fileTok->varId() || fileTok->strAt(1) == "[")
continue;

if (filepointers.find(fileTok->varId()) == filepointers.end()) { // function call indicates: Its a File
filepointers.insert(std::make_pair(fileTok->varId(), Filepointer(OpenMode::UNKNOWN_OM)));
}
// function call indicates: Its a File
filepointers.emplace(fileTok->varId(), Filepointer(OpenMode::UNKNOWN_OM));

Filepointer& f = filepointers[fileTok->varId()];

Expand Down
4 changes: 2 additions & 2 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2472,8 +2472,8 @@ void CheckOther::checkInvalidFree()
// Keep track of which variables were assigned addresses to newly-allocated memory
if ((tok->isCpp() && Token::Match(tok, "%var% = new")) ||
(Token::Match(tok, "%var% = %name% (") && mSettings->library.getAllocFuncInfo(tok->tokAt(2)))) {
allocation.insert(std::make_pair(tok->varId(), tok->strAt(2)));
inconclusive.insert(std::make_pair(tok->varId(), false));
allocation.emplace(tok->varId(), tok->strAt(2));
inconclusive.emplace(tok->varId(), false);
}

// If a previously-allocated pointer is incremented or decremented, any subsequent
Expand Down
2 changes: 1 addition & 1 deletion lib/checkstl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ namespace {
void add(const Reference& r) {
if (!r.tok)
return;
expressions.insert(std::make_pair(r.tok->exprId(), r));
expressions.emplace(r.tok->exprId(), r);
}

std::vector<Reference> invalidTokens() const {
Expand Down
2 changes: 1 addition & 1 deletion lib/checkunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void Variables::addVar(const Variable *var,
bool write_)
{
if (var->declarationId() > 0) {
mVarUsage.insert(std::make_pair(var->declarationId(), VariableUsage(var, type, false, write_, false)));
mVarUsage.emplace(var->declarationId(), VariableUsage(var, type, false, write_, false));
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/clangimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,26 +234,26 @@ namespace clangimport {

void enumDecl(const std::string &addr, Token *nameToken, Enumerator *enumerator) {
Decl decl(nameToken, enumerator);
mDeclMap.insert(std::pair<std::string, Decl>(addr, decl));
mDeclMap.emplace(addr, decl);
nameToken->enumerator(enumerator);
notFound(addr);
}

void funcDecl(const std::string &addr, Token *nameToken, Function *function) {
Decl decl(nameToken, function);
mDeclMap.insert(std::pair<std::string, Decl>(addr, decl));
mDeclMap.emplace(addr, decl);
nameToken->function(function);
notFound(addr);
}

void scopeDecl(const std::string &addr, Scope *scope) {
Decl decl(scope);
mDeclMap.insert(std::pair<std::string, Decl>(addr, decl));
mDeclMap.emplace(addr, decl);
}

void varDecl(const std::string &addr, Token *def, Variable *var) {
Decl decl(def, var);
mDeclMap.insert(std::pair<std::string, Decl>(addr, decl));
mDeclMap.emplace(addr, decl);
def->varId(++mVarId);
def->variable(var);
if (def->valueType())
Expand Down
4 changes: 2 additions & 2 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1250,13 +1250,13 @@ void SymbolDatabase::fixVarId(VarIdMap & varIds, const Token * vartok, Token * m
mVariableList.push_back(membervar);
} else
mVariableList[membertok->varId()] = membervar;
varIds.insert(std::make_pair(vartok->varId(), memberId));
varIds.emplace(vartok->varId(), memberId);
varId = varIds.find(vartok->varId());
}
MemberIdMap::const_iterator memberId = varId->second.find(membervar->nameToken()->varId());
if (memberId == varId->second.cend()) {
if (membertok->varId() == 0) {
varId->second.insert(std::make_pair(membervar->nameToken()->varId(), mTokenizer.newVarId()));
varId->second.emplace(membervar->nameToken()->varId(), mTokenizer.newVarId());
mVariableList.push_back(membervar);
memberId = varId->second.find(membervar->nameToken()->varId());
} else
Expand Down
2 changes: 1 addition & 1 deletion lib/symboldatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ class CPPCHECKLIB Scope {

const Function * back = &functionList.back();

functionMap.insert(make_pair(back->tokenDef->str(), back));
functionMap.emplace(back->tokenDef->str(), back);
}

AccessControl defaultAccess() const;
Expand Down
4 changes: 2 additions & 2 deletions lib/templatesimplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,12 +780,12 @@ void TemplateSimplifier::getTemplateInstantiations()

for (const auto & decl : mTemplateDeclarations) {
if (decl.isFunction())
functionNameMap.insert(std::make_pair(decl.name(), &decl));
functionNameMap.emplace(decl.name(), &decl);
}

for (const auto & decl : mTemplateForwardDeclarations) {
if (decl.isFunction())
functionNameMap.insert(std::make_pair(decl.name(), &decl));
functionNameMap.emplace(decl.name(), &decl);
}

const Token *skip = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5933,7 +5933,7 @@ static void valueFlowUninit(TokenList& tokenlist, ErrorLogger& errorLogger, cons
Token* tok2 = p.first;
const ValueFlow::Value& v = p.second;
// Try to insert into map
auto pp = partialReads.insert(std::make_pair(tok2, v));
auto pp = partialReads.emplace(tok2, v);
ValueFlow::Value& v2 = pp.first->second;
const bool inserted = pp.second;
// Merge the two values if it is already in map
Expand Down
Loading