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)
{
std::vector<AstNodePtr> children{astNode};
return createScope(tokenList, scopeType, children, def);
std::vector<AstNodePtr> children2{astNode};
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;
@ -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;

View File

@ -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);

View File

@ -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<std::string, ValuePtr> member;

View File

@ -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 + ")";
}