Fix some of the warnings that appear with -Wshadow

This commit is contained in:
Reijo Tomperi 2010-04-06 22:53:05 +03:00
parent a562430f3f
commit 7caaee3739
2 changed files with 30 additions and 30 deletions

View File

@ -973,17 +973,17 @@ void CheckClass::operatorEqRetRefThis()
nameLength += 2; nameLength += 2;
} }
const Token *name = tok1; const Token *className = tok1;
std::string nameString; std::string nameString;
nameStr(name, nameLength, nameString); nameStr(className, nameLength, nameString);
if (tok1->tokAt(-1) && tok1->tokAt(-1)->str() == "&") if (tok1->tokAt(-1) && tok1->tokAt(-1)->str() == "&")
{ {
// check class name // check class name
if (tok1->tokAt(-(1 + nameLength)) && nameMatch(name, tok1->tokAt(-(1 + nameLength)), nameLength)) if (tok1->tokAt(-(1 + nameLength)) && nameMatch(className, tok1->tokAt(-(1 + nameLength)), nameLength))
{ {
operatorEqRetRefThis_finderr(tok, name->str()); operatorEqRetRefThis_finderr(tok, className->str());
} }
} }
} }
@ -995,7 +995,7 @@ void CheckClass::operatorEqRetRefThis()
// check backwards for proper function signature // check backwards for proper function signature
if (tok1->tokAt(-1) && tok1->tokAt(-1)->str() == "&") if (tok1->tokAt(-1) && tok1->tokAt(-1)->str() == "&")
{ {
const Token *name = 0; const Token *className = 0;
bool isPublic = false; bool isPublic = false;
while (tok1 && !Token::Match(tok1, "class|struct %var%")) while (tok1 && !Token::Match(tok1, "class|struct %var%"))
{ {
@ -1012,12 +1012,12 @@ void CheckClass::operatorEqRetRefThis()
// data members in structs are public by default // data members in structs are public by default
isPublic = bool(tok1->str() == "struct"); isPublic = bool(tok1->str() == "struct");
name = tok1->tokAt(1); className = tok1->tokAt(1);
} }
if (tok->tokAt(-2) && tok->tokAt(-2)->str() == name->str()) if (tok->tokAt(-2) && tok->tokAt(-2)->str() == className->str())
{ {
operatorEqRetRefThis_finderr(tok, name->str()); operatorEqRetRefThis_finderr(tok, className->str());
} }
} }
} }
@ -1217,17 +1217,17 @@ void CheckClass::operatorEqToSelf()
nameLength += 2; nameLength += 2;
} }
const Token *name = tok1; const Token *className = tok1;
std::string nameString; std::string nameString;
nameStr(name, nameLength, nameString); nameStr(className, nameLength, nameString);
if (!hasMultipleInheritanceGlobal(_tokenizer->tokens(), nameString)) if (!hasMultipleInheritanceGlobal(_tokenizer->tokens(), nameString))
{ {
if (tok1->tokAt(-1) && tok1->tokAt(-1)->str() == "&") if (tok1->tokAt(-1) && tok1->tokAt(-1)->str() == "&")
{ {
// check returned class name // check returned class name
if (tok1->tokAt(-(1 + nameLength)) && nameMatch(name, tok1->tokAt(-(1 + nameLength)), nameLength)) if (tok1->tokAt(-(1 + nameLength)) && nameMatch(className, tok1->tokAt(-(1 + nameLength)), nameLength))
{ {
// check forward for proper function signature // check forward for proper function signature
std::string pattern = "const " + nameString + " & %var% )"; std::string pattern = "const " + nameString + " & %var% )";
@ -1235,7 +1235,7 @@ void CheckClass::operatorEqToSelf()
{ {
const Token * rhs = tok->tokAt(5 + nameLength); const Token * rhs = tok->tokAt(5 + nameLength);
if (nameMatch(name, tok->tokAt(4), nameLength)) if (nameMatch(className, tok->tokAt(4), nameLength))
{ {
tok1 = tok->tokAt(2)->link(); tok1 = tok->tokAt(2)->link();
@ -1263,23 +1263,23 @@ void CheckClass::operatorEqToSelf()
// check backwards for proper function signature // check backwards for proper function signature
if (tok1->tokAt(-1) && tok1->tokAt(-1)->str() == "&") if (tok1->tokAt(-1) && tok1->tokAt(-1)->str() == "&")
{ {
const Token *name = 0; const Token *className = 0;
while (tok1 && !Token::Match(tok1, "class|struct %var%")) while (tok1 && !Token::Match(tok1, "class|struct %var%"))
tok1 = tok1->previous(); tok1 = tok1->previous();
if (Token::Match(tok1, "struct|class %var%")) if (Token::Match(tok1, "struct|class %var%"))
name = tok1->tokAt(1); className = tok1->tokAt(1);
if (!hasMultipleInheritanceInline(tok1)) if (!hasMultipleInheritanceInline(tok1))
{ {
if (Token::simpleMatch(tok->tokAt(-2), name->str().c_str())) if (Token::simpleMatch(tok->tokAt(-2), className->str().c_str()))
{ {
// check forward for proper function signature // check forward for proper function signature
if (Token::Match(tok->tokAt(3), "const %type% & %var% )")) if (Token::Match(tok->tokAt(3), "const %type% & %var% )"))
{ {
const Token * rhs = tok->tokAt(6); const Token * rhs = tok->tokAt(6);
if (tok->tokAt(4)->str() == name->str()) if (tok->tokAt(4)->str() == className->str())
{ {
tok1 = tok->tokAt(2)->link(); tok1 = tok->tokAt(2)->link();
@ -1597,18 +1597,18 @@ void CheckClass::checkConst()
{ {
const Token *found = nestInfo[i].classEnd; const Token *found = nestInfo[i].classEnd;
std::string pattern(functionName + " ("); std::string pattern(functionName + " (");
int level = 0; int namespaceLevel = 0;
for (int j = nestInfo.size() - 1; j >= i; j--, level++) for (int j = nestInfo.size() - 1; j >= i; j--, namespaceLevel++)
pattern = std::string(nestInfo[j].className + " :: " + pattern); pattern = std::string(nestInfo[j].className + " :: " + pattern);
while ((found = Token::findmatch(found->next(), pattern.c_str())) != NULL) while ((found = Token::findmatch(found->next(), pattern.c_str())) != NULL)
{ {
const Token *paramEnd = found->tokAt(1 + (2 * level))->link(); const Token *paramEnd = found->tokAt(1 + (2 * namespaceLevel))->link();
if (!paramEnd) if (!paramEnd)
break; break;
if (paramEnd->next()->str() != "{") if (paramEnd->next()->str() != "{")
break; break;
if (sameFunc(level, tok2, paramEnd)) if (sameFunc(namespaceLevel, tok2, paramEnd))
{ {
// if nothing non-const was found. write error.. // if nothing non-const was found. write error..
if (checkConstFunc(classname, varlist, paramEnd)) if (checkConstFunc(classname, varlist, paramEnd))

View File

@ -196,18 +196,18 @@ public:
{ {
return _linenr; return _linenr;
} }
void linenr(unsigned int linenr) void linenr(unsigned int lineNumber)
{ {
_linenr = linenr; _linenr = lineNumber;
} }
unsigned int fileIndex() const unsigned int fileIndex() const
{ {
return _fileIndex; return _fileIndex;
} }
void fileIndex(unsigned int fileIndex) void fileIndex(unsigned int indexOfFile)
{ {
_fileIndex = fileIndex; _fileIndex = indexOfFile;
} }
Token *next() const Token *next() const
@ -290,9 +290,9 @@ public:
* @param link The token where this token should link * @param link The token where this token should link
* to. * to.
*/ */
void link(Token *link) void link(Token *linkToToken)
{ {
_link = link; _link = linkToToken;
} }
/** /**
@ -330,13 +330,13 @@ public:
static void move(Token *srcStart, Token *srcEnd, Token *newLocation); static void move(Token *srcStart, Token *srcEnd, Token *newLocation);
private: private:
void next(Token *next) void next(Token *nextToken)
{ {
_next = next; _next = nextToken;
} }
void previous(Token *previous) void previous(Token *previousToken)
{ {
_previous = previous; _previous = previousToken;
} }
/** /**