Refactorization: Fixed a couple of compiler warnings about reusing variable names

This commit is contained in:
Philipp Kloke 2020-05-10 22:16:58 +02:00 committed by PKEuS
parent 793ed68029
commit 32923b7ac5
4 changed files with 17 additions and 17 deletions

View File

@ -475,11 +475,11 @@ void clangimport::AstNode::setValueType(Token *tok)
Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, AstNodePtr astNode, const Token *def) Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, AstNodePtr astNode, const Token *def)
{ {
std::vector<AstNodePtr> children{astNode}; std::vector<AstNodePtr> children2{astNode};
return createScope(tokenList, scopeType, children, def); return createScope(tokenList, scopeType, children2, def);
} }
Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, const std::vector<AstNodePtr> &children, const Token *def) Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, const std::vector<AstNodePtr> & children2, const Token *def)
{ {
SymbolDatabase *symbolDatabase = mData->mSymbolDatabase; SymbolDatabase *symbolDatabase = mData->mSymbolDatabase;
@ -488,22 +488,22 @@ Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType
symbolDatabase->scopeList.push_back(Scope(nullptr, nullptr, nestedIn)); symbolDatabase->scopeList.push_back(Scope(nullptr, nullptr, nestedIn));
Scope *scope = &symbolDatabase->scopeList.back(); Scope *scope = &symbolDatabase->scopeList.back();
if (scopeType == Scope::ScopeType::eEnum) if (scopeType == Scope::ScopeType::eEnum)
scope->enumeratorList.reserve(children.size()); scope->enumeratorList.reserve(children2.size());
nestedIn->nestedList.push_back(scope); nestedIn->nestedList.push_back(scope);
scope->type = scopeType; scope->type = scopeType;
scope->classDef = def; scope->classDef = def;
scope->check = nestedIn->check; scope->check = nestedIn->check;
if (!children.empty()) { if (!children2.empty()) {
Token *bodyStart = children[0]->addtoken(tokenList, "{"); Token *bodyStart = children2[0]->addtoken(tokenList, "{");
tokenList->back()->scope(scope); tokenList->back()->scope(scope);
for (AstNodePtr astNode: children) { for (AstNodePtr astNode: children2) {
astNode->createTokens(tokenList); astNode->createTokens(tokenList);
if (scopeType == Scope::ScopeType::eEnum) if (scopeType == Scope::ScopeType::eEnum)
astNode->addtoken(tokenList, ","); astNode->addtoken(tokenList, ",");
else if (!Token::Match(tokenList->back(), "[;{}]")) else if (!Token::Match(tokenList->back(), "[;{}]"))
astNode->addtoken(tokenList, ";"); astNode->addtoken(tokenList, ";");
} }
Token *bodyEnd = children.back()->addtoken(tokenList, "}"); Token *bodyEnd = children2.back()->addtoken(tokenList, "}");
bodyStart->link(bodyEnd); bodyStart->link(bodyEnd);
bodyEnd->link(bodyStart); bodyEnd->link(bodyStart);
scope->bodyStart = bodyStart; scope->bodyStart = bodyStart;

View File

@ -282,8 +282,8 @@ std::string ErrorLogger::ErrorMessage::serialize() const
oss << Severity::toString(severity).length() << " " << Severity::toString(severity); oss << Severity::toString(severity).length() << " " << Severity::toString(severity);
oss << MathLib::toString(cwe.id).length() << " " << MathLib::toString(cwe.id); oss << MathLib::toString(cwe.id).length() << " " << MathLib::toString(cwe.id);
if (inconclusive) { if (inconclusive) {
const std::string inconclusive("inconclusive"); const std::string text("inconclusive");
oss << inconclusive.length() << " " << inconclusive; oss << text.length() << " " << text;
} }
const std::string saneShortMessage = fixInvalidChars(mShortMessage); const std::string saneShortMessage = fixInvalidChars(mShortMessage);

View File

@ -227,8 +227,8 @@ namespace ExprEngine {
std::string getSymbolicExpression() const OVERRIDE; std::string getSymbolicExpression() const OVERRIDE;
ValuePtr getValueOfMember(const std::string &name) const { ValuePtr getValueOfMember(const std::string &n) const {
auto it = member.find(name); auto it = member.find(n);
return (it == member.end()) ? ValuePtr() : it->second; return (it == member.end()) ? ValuePtr() : it->second;
} }
std::map<std::string, ValuePtr> member; std::map<std::string, ValuePtr> member;

View File

@ -1201,9 +1201,9 @@ void SymbolDatabase::createSymbolDatabaseSetVariablePointers()
} }
} else if (tok->valueType() && tok->valueType()->type == ValueType::CONTAINER) { } else if (tok->valueType() && tok->valueType()->type == ValueType::CONTAINER) {
if (Token::Match(var->typeStartToken(), "std :: %type% < %type% *| *| >")) { if (Token::Match(var->typeStartToken(), "std :: %type% < %type% *| *| >")) {
const Type * type = var->typeStartToken()->tokAt(4)->type(); const Type * type2 = var->typeStartToken()->tokAt(4)->type();
if (type && type->classScope && type->classScope->definedType) { if (type2 && type2->classScope && type2->classScope->definedType) {
const Variable *membervar = type->classScope->getVariable(membertok->str()); const Variable *membervar = type2->classScope->getVariable(membertok->str());
if (membervar) { if (membervar) {
membertok->variable(membervar); membertok->variable(membervar);
if (membertok->varId() == 0 || mVariableList[membertok->varId()] == nullptr) if (membertok->varId() == 0 || mVariableList[membertok->varId()] == nullptr)
@ -2165,8 +2165,8 @@ std::string Function::fullName() const
ret = s->className + "::" + ret; ret = s->className + "::" + ret;
} }
ret += "("; ret += "(";
for (const Variable &arg : argumentList) for (const Variable &a : argumentList)
ret += (arg.index() == 0 ? "" : ",") + arg.name(); ret += (a.index() == 0 ? "" : ",") + a.name();
return ret + ")"; return ret + ")";
} }