From 32923b7ac54a3bab9b18445d36c16bec75d12d98 Mon Sep 17 00:00:00 2001 From: Philipp Kloke Date: Sun, 10 May 2020 22:16:58 +0200 Subject: [PATCH] Refactorization: Fixed a couple of compiler warnings about reusing variable names --- lib/clangimport.cpp | 16 ++++++++-------- lib/errorlogger.cpp | 4 ++-- lib/exprengine.h | 4 ++-- lib/symboldatabase.cpp | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index cb27aa041..82ccbf671 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -475,11 +475,11 @@ void clangimport::AstNode::setValueType(Token *tok) Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, AstNodePtr astNode, const Token *def) { - std::vector children{astNode}; - return createScope(tokenList, scopeType, children, def); + std::vector children2{astNode}; + return createScope(tokenList, scopeType, children2, def); } -Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, const std::vector &children, const Token *def) +Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, const std::vector & children2, const Token *def) { SymbolDatabase *symbolDatabase = mData->mSymbolDatabase; @@ -488,22 +488,22 @@ Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType symbolDatabase->scopeList.push_back(Scope(nullptr, nullptr, nestedIn)); Scope *scope = &symbolDatabase->scopeList.back(); if (scopeType == Scope::ScopeType::eEnum) - scope->enumeratorList.reserve(children.size()); + scope->enumeratorList.reserve(children2.size()); nestedIn->nestedList.push_back(scope); scope->type = scopeType; scope->classDef = def; scope->check = nestedIn->check; - if (!children.empty()) { - Token *bodyStart = children[0]->addtoken(tokenList, "{"); + if (!children2.empty()) { + Token *bodyStart = children2[0]->addtoken(tokenList, "{"); tokenList->back()->scope(scope); - for (AstNodePtr astNode: children) { + for (AstNodePtr astNode: children2) { astNode->createTokens(tokenList); if (scopeType == Scope::ScopeType::eEnum) astNode->addtoken(tokenList, ","); else if (!Token::Match(tokenList->back(), "[;{}]")) astNode->addtoken(tokenList, ";"); } - Token *bodyEnd = children.back()->addtoken(tokenList, "}"); + Token *bodyEnd = children2.back()->addtoken(tokenList, "}"); bodyStart->link(bodyEnd); bodyEnd->link(bodyStart); scope->bodyStart = bodyStart; diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 70b9c56e6..7c6c22536 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -282,8 +282,8 @@ std::string ErrorLogger::ErrorMessage::serialize() const oss << Severity::toString(severity).length() << " " << Severity::toString(severity); oss << MathLib::toString(cwe.id).length() << " " << MathLib::toString(cwe.id); if (inconclusive) { - const std::string inconclusive("inconclusive"); - oss << inconclusive.length() << " " << inconclusive; + const std::string text("inconclusive"); + oss << text.length() << " " << text; } const std::string saneShortMessage = fixInvalidChars(mShortMessage); diff --git a/lib/exprengine.h b/lib/exprengine.h index 3ad783df1..45e6db036 100644 --- a/lib/exprengine.h +++ b/lib/exprengine.h @@ -227,8 +227,8 @@ namespace ExprEngine { std::string getSymbolicExpression() const OVERRIDE; - ValuePtr getValueOfMember(const std::string &name) const { - auto it = member.find(name); + ValuePtr getValueOfMember(const std::string &n) const { + auto it = member.find(n); return (it == member.end()) ? ValuePtr() : it->second; } std::map member; diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 79cd52441..ca5c4b4e6 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1201,9 +1201,9 @@ void SymbolDatabase::createSymbolDatabaseSetVariablePointers() } } else if (tok->valueType() && tok->valueType()->type == ValueType::CONTAINER) { if (Token::Match(var->typeStartToken(), "std :: %type% < %type% *| *| >")) { - const Type * type = var->typeStartToken()->tokAt(4)->type(); - if (type && type->classScope && type->classScope->definedType) { - const Variable *membervar = type->classScope->getVariable(membertok->str()); + const Type * type2 = var->typeStartToken()->tokAt(4)->type(); + if (type2 && type2->classScope && type2->classScope->definedType) { + const Variable *membervar = type2->classScope->getVariable(membertok->str()); if (membervar) { membertok->variable(membervar); if (membertok->varId() == 0 || mVariableList[membertok->varId()] == nullptr) @@ -2165,8 +2165,8 @@ std::string Function::fullName() const ret = s->className + "::" + ret; } ret += "("; - for (const Variable &arg : argumentList) - ret += (arg.index() == 0 ? "" : ",") + arg.name(); + for (const Variable &a : argumentList) + ret += (a.index() == 0 ? "" : ",") + a.name(); return ret + ")"; }