Fix more -Wshadow compile warnings

This commit is contained in:
Reijo Tomperi 2010-04-09 22:40:37 +03:00
parent f77dbbb14b
commit 6dc3860ae9
8 changed files with 85 additions and 85 deletions

View File

@ -156,9 +156,9 @@ unsigned int ThreadExecutor::check()
CppCheck fileChecker(*this);
fileChecker.settings(_settings);
fileChecker.addFile(_filenames[i]);
unsigned int result = fileChecker.check();
unsigned int resultOfCheck = fileChecker.check();
std::ostringstream oss;
oss << result;
oss << resultOfCheck;
writeToPipe('3', oss.str());
exit(0);
}

View File

@ -533,9 +533,9 @@ std::string Preprocessor::replaceIfDefined(const std::string &str)
return ret;
}
void Preprocessor::preprocess(std::istream &istr, std::string &processedFile, std::list<std::string> &resultConfigurations, const std::string &filename, const std::list<std::string> &includePaths)
void Preprocessor::preprocess(std::istream &srcCodeStream, std::string &processedFile, std::list<std::string> &resultConfigurations, const std::string &filename, const std::list<std::string> &includePaths)
{
processedFile = read(istr, filename, _settings);
processedFile = read(srcCodeStream, filename, _settings);
// Replace all tabs with spaces..
std::replace(processedFile.begin(), processedFile.end(), '\t', ' ');
@ -707,8 +707,8 @@ std::list<std::string> Preprocessor::getcfgs(const std::string &filedata, const
}
if (par != 0)
{
std::ostringstream line;
line << __LINE__;
std::ostringstream lineStream;
lineStream << __LINE__;
ErrorLogger::ErrorMessage errmsg;
ErrorLogger::ErrorMessage::FileLocation loc;
@ -717,7 +717,7 @@ std::list<std::string> Preprocessor::getcfgs(const std::string &filedata, const
errmsg._callStack.push_back(loc);
errmsg._severity = "error";
errmsg._msg = "mismatching number of '(' and ')' in this line: " + def;
errmsg._id = "preprocessor" + line.str();
errmsg._id = "preprocessor" + lineStream.str();
_errorLogger->reportErr(errmsg);
ret.clear();
return ret;
@ -783,9 +783,9 @@ std::list<std::string> Preprocessor::getcfgs(const std::string &filedata, const
}
else
{
std::string def((deflist.back() == "1") ? "0" : "1");
std::string tempDef((deflist.back() == "1") ? "0" : "1");
deflist.pop_back();
deflist.push_back(def);
deflist.push_back(tempDef);
}
}
@ -848,11 +848,11 @@ std::list<std::string> Preprocessor::getcfgs(const std::string &filedata, const
if (s.find("&&") != std::string::npos)
{
Tokenizer tokenizer(_settings, _errorLogger);
std::istringstream istr(s.c_str());
if (!tokenizer.tokenize(istr, filename.c_str()))
std::istringstream tempIstr(s.c_str());
if (!tokenizer.tokenize(tempIstr, filename.c_str()))
{
std::ostringstream line;
line << __LINE__;
std::ostringstream lineStream;
lineStream << __LINE__;
ErrorLogger::ErrorMessage errmsg;
ErrorLogger::ErrorMessage::FileLocation loc;
@ -861,7 +861,7 @@ std::list<std::string> Preprocessor::getcfgs(const std::string &filedata, const
errmsg._callStack.push_back(loc);
errmsg._severity = "error";
errmsg._msg = "Error parsing this: " + s;
errmsg._id = "preprocessor" + line.str();
errmsg._id = "preprocessor" + lineStream.str();
_errorLogger->reportErr(errmsg);
}
@ -1148,8 +1148,8 @@ std::string Preprocessor::getcode(const std::string &filedata, std::string cfg,
{
Tokenizer tokenizer;
line.erase(0, sizeof("#pragma endasm"));
std::istringstream istr(line.c_str());
tokenizer.tokenize(istr, "");
std::istringstream tempIstr(line.c_str());
tokenizer.tokenize(tempIstr, "");
if (Token::Match(tokenizer.tokens(), "( %var% = %any% )"))
{
ret << "asm(" << tokenizer.tokens()->strAt(1) << ");";
@ -1291,11 +1291,11 @@ static int tolowerWrapper(int c)
}
void Preprocessor::handleIncludes(std::string &code, const std::string &filename, const std::list<std::string> &includePaths)
void Preprocessor::handleIncludes(std::string &code, const std::string &filePath, const std::list<std::string> &includePaths)
{
std::list<std::string> paths;
std::string path;
path = filename;
path = filePath;
path.erase(1 + path.find_last_of("\\/"));
paths.push_back(path);
std::string::size_type pos = 0;
@ -1623,11 +1623,11 @@ public:
const std::string &s(params2[i]);
std::ostringstream ostr;
ostr << "\"";
for (std::string::size_type i = 0; i < s.size(); ++i)
for (std::string::size_type j = 0; j < s.size(); ++j)
{
if (s[i] == '\\' || s[i] == '\"')
if (s[j] == '\\' || s[j] == '\"')
ostr << '\\';
ostr << s[i];
ostr << s[j];
}
str = ostr.str() + "\"";
}
@ -2027,9 +2027,9 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file
"syntaxError",
std::string("Syntax error. Not enough parameters for macro '") + macro->name() + "'.");
std::map<std::string, PreprocessorMacro *>::iterator it;
for (it = macros.begin(); it != macros.end(); ++it)
delete it->second;
std::map<std::string, PreprocessorMacro *>::iterator iter;
for (iter = macros.begin(); iter != macros.end(); ++iter)
delete iter->second;
return "";
}

View File

@ -54,7 +54,7 @@ public:
* Extract the code for each configuration. Use this with getcode() to get the
* file data for each individual configuration.
*
* @param istr The (file/string) stream to read from.
* @param srcCodeStream The (file/string) stream to read from.
* @param processedFile Give reference to empty string as a parameter,
* function will fill processed file here. Use this also as a filedata parameter
* to getcode() if you recieved more than once configurations.
@ -67,7 +67,7 @@ public:
* Note that if path from given filename is also extracted and that is used as
* a last include path if include file was not found from earlier paths.
*/
void preprocess(std::istream &istr, std::string &processedFile, std::list<std::string> &resultConfigurations, const std::string &filename, const std::list<std::string> &includePaths);
void preprocess(std::istream &srcCodeStream, std::string &processedFile, std::list<std::string> &resultConfigurations, const std::string &filename, const std::list<std::string> &includePaths);
/** Just read the code into a string. Perform simple cleanup of the code */
static std::string read(std::istream &istr, const std::string &filename, Settings *settings);
@ -185,7 +185,7 @@ private:
* Search includes from code and append code from the included
* file
* @param code The source code to modify
* @param filename The name of the file to check e.g. "src/main.cpp"
* @param filePath Relative path to file to check e.g. "src/main.cpp"
* @param includePaths List of paths where incude files should be searched from,
* single path can be e.g. in format "include/".
* There must be a path separator at the end. Default parameter is empty list.
@ -193,7 +193,7 @@ private:
* a last include path if include file was not found from earlier paths.
* @return modified source code
*/
void handleIncludes(std::string &code, const std::string &filename, const std::list<std::string> &includePaths);
void handleIncludes(std::string &code, const std::string &filePath, const std::list<std::string> &includePaths);
Settings *_settings;
ErrorLogger *_errorLogger;

View File

@ -595,10 +595,10 @@ const Token *Token::findmatch(const Token *tok, const char pattern[], unsigned i
return 0;
}
void Token::insertToken(const std::string &str)
void Token::insertToken(const std::string &tokenStr)
{
Token *newToken = new Token(tokensBack);
newToken->str(str);
newToken->str(tokenStr);
newToken->_linenr = _linenr;
newToken->_fileIndex = _fileIndex;
if (this->next())
@ -658,38 +658,38 @@ std::string Token::stringifyList(bool varid, const char *title, const std::vecto
if (title)
ret << "\n### " << title << " ###\n";
unsigned int linenr = 0;
int fileIndex = -1;
unsigned int lineNumber = 0;
int fileInd = -1;
std::map<unsigned int, unsigned int> lineNumbers;
for (const Token *tok = this; tok; tok = tok->next())
{
bool fileChange = false;
if (static_cast<int>(tok->_fileIndex) != fileIndex)
if (static_cast<int>(tok->_fileIndex) != fileInd)
{
if (fileIndex != -1)
if (fileInd != -1)
{
lineNumbers[fileIndex] = tok->_fileIndex;
lineNumbers[fileInd] = tok->_fileIndex;
}
fileIndex = static_cast<int>(tok->_fileIndex);
fileInd = static_cast<int>(tok->_fileIndex);
ret << "\n\n##file ";
if (fileNames.size() > static_cast<unsigned int>(fileIndex))
ret << fileNames.at(fileIndex);
if (fileNames.size() > static_cast<unsigned int>(fileInd))
ret << fileNames.at(fileInd);
else
ret << fileIndex;
ret << fileInd;
linenr = lineNumbers[fileIndex];
lineNumber = lineNumbers[fileInd];
fileChange = true;
}
if (linenr != tok->linenr() || fileChange)
if (lineNumber != tok->linenr() || fileChange)
{
while (linenr < tok->linenr())
while (lineNumber < tok->linenr())
{
++linenr;
ret << "\n" << linenr << ":";
++lineNumber;
ret << "\n" << lineNumber << ":";
}
linenr = tok->linenr();
lineNumber = tok->linenr();
}
ret << " " << tok->str();

View File

@ -228,9 +228,9 @@ public:
/**
* Insert new token after this token. This function will handle
* relations between next and previous token also.
* @param str String for the new token.
* @param tokenStr String for the new token.
*/
void insertToken(const std::string &str);
void insertToken(const std::string &tokenStr);
Token *previous() const
{

View File

@ -126,35 +126,35 @@ private:
void xml()
{
// Test the errorlogger..
ErrorLogger::ErrorMessage errmsg;
errmsg._msg = "ab<cd>ef";
ASSERT_EQUALS("<error id=\"\" severity=\"\" msg=\"ab&lt;cd&gt;ef\"/>", errmsg.toXML());
ErrorLogger::ErrorMessage errorMessage;
errorMessage._msg = "ab<cd>ef";
ASSERT_EQUALS("<error id=\"\" severity=\"\" msg=\"ab&lt;cd&gt;ef\"/>", errorMessage.toXML());
}
void include()
{
ErrorLogger::ErrorMessage errmsg;
ErrorLogger::ErrorMessage errorMessage;
ErrorLogger::ErrorMessage::FileLocation loc;
loc.file = "ab/cd/../ef.h";
errmsg._callStack.push_back(loc);
ASSERT_EQUALS("<error file=\"ab/ef.h\" line=\"0\" id=\"\" severity=\"\" msg=\"\"/>", errmsg.toXML());
ASSERT_EQUALS("[ab/ef.h:0]: ", errmsg.toText());
errorMessage._callStack.push_back(loc);
ASSERT_EQUALS("<error file=\"ab/ef.h\" line=\"0\" id=\"\" severity=\"\" msg=\"\"/>", errorMessage.toXML());
ASSERT_EQUALS("[ab/ef.h:0]: ", errorMessage.toText());
}
void templateFormat()
{
ErrorLogger::ErrorMessage errmsg;
ErrorLogger::ErrorMessage errorMessage;
ErrorLogger::ErrorMessage::FileLocation loc;
loc.file = "some/{file}file.cpp";
loc.line = 10;
errmsg._callStack.push_back(loc);
errmsg._id = "testId";
errmsg._severity = "testSeverity";
errmsg._msg = "long testMessage";
ASSERT_EQUALS("<error file=\"some/{file}file.cpp\" line=\"10\" id=\"testId\" severity=\"testSeverity\" msg=\"long testMessage\"/>", errmsg.toXML());
ASSERT_EQUALS("[some/{file}file.cpp:10]: (testSeverity) long testMessage", errmsg.toText());
ASSERT_EQUALS("testId-some/{file}file.cpp,testSeverity.10?{long testMessage}", errmsg.toText("{id}-{file},{severity}.{line}?{{message}}"));
errorMessage._callStack.push_back(loc);
errorMessage._id = "testId";
errorMessage._severity = "testSeverity";
errorMessage._msg = "long testMessage";
ASSERT_EQUALS("<error file=\"some/{file}file.cpp\" line=\"10\" id=\"testId\" severity=\"testSeverity\" msg=\"long testMessage\"/>", errorMessage.toXML());
ASSERT_EQUALS("[some/{file}file.cpp:10]: (testSeverity) long testMessage", errorMessage.toText());
ASSERT_EQUALS("testId-some/{file}file.cpp,testSeverity.10?{long testMessage}", errorMessage.toText("{id}-{file},{severity}.{line}?{{message}}"));
}
void getErrorMessages()

View File

@ -393,7 +393,7 @@ private:
tokenizer.tokenize(istr, "test.cpp");
tokenizer.simplifyTokenList();
const unsigned int varid(Token::findmatch(tokenizer.tokens(), varname)->varId());
const unsigned int varId(Token::findmatch(tokenizer.tokens(), varname)->varId());
// getcode..
CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, 0, 0);
@ -403,7 +403,7 @@ private:
CheckMemoryLeak::AllocType allocType, deallocType;
allocType = deallocType = CheckMemoryLeak::No;
bool all = false;
Token *tokens = checkMemoryLeak.getcode(tokenizer.tokens(), callstack, varid, allocType, deallocType, false, all, 1);
Token *tokens = checkMemoryLeak.getcode(tokenizer.tokens(), callstack, varId, allocType, deallocType, false, all, 1);
// stringify..
std::ostringstream ret;

View File

@ -246,20 +246,20 @@ private:
tokenizer.validate();
std::string ret;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
for (const Token *tok1 = tokenizer.tokens(); tok1; tok1 = tok1->next())
{
if (tok != tokenizer.tokens())
if (tok1 != tokenizer.tokens())
ret += " ";
if (!simplify)
{
if (tok->isUnsigned())
if (tok1->isUnsigned())
ret += "unsigned ";
else if (tok->isSigned())
else if (tok1->isSigned())
ret += "signed ";
}
if (tok->isLong())
if (tok1->isLong())
ret += "long ";
ret += tok->str();
ret += tok1->str();
}
return ret;
@ -701,13 +701,13 @@ private:
tokenizer.simplifyTokenList();
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
for (const Token *tok1 = tokenizer.tokens(); tok1; tok1 = tok1->next())
{
if (tok->previous())
if (tok1->previous())
{
ostr << " ";
}
ostr << tok->str();
ostr << tok1->str();
}
return ostr.str();
@ -719,9 +719,9 @@ private:
std::istringstream istr("");
tokenizer.tokenize(istr, "test.cpp");
tokenizer.simplifyTokenList();
Token tok(0);
tok.str(type);
return tokenizer.sizeOfType(&tok);
Token tok1(0);
tok1.str(type);
return tokenizer.sizeOfType(&tok1);
}
void sizeof1()
@ -1839,8 +1839,8 @@ private:
tokenizer.simplifyIfAssign();
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << (tok->previous() ? " " : "") << tok->str();
for (const Token *tok1 = tokenizer.tokens(); tok1; tok1 = tok1->next())
ostr << (tok1->previous() ? " " : "") << tok1->str();
return ostr.str();
}
@ -1883,8 +1883,8 @@ private:
tokenizer.simplifyIfNot();
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << (tok->previous() ? " " : "") << tok->str();
for (const Token *tok1 = tokenizer.tokens(); tok1; tok1 = tok1->next())
ostr << (tok1->previous() ? " " : "") << tok1->str();
return ostr.str();
}
@ -1916,8 +1916,8 @@ private:
tokenizer.simplifyLogicalOperators();
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << (tok->previous() ? " " : "") << tok->str();
for (const Token *tok1 = tokenizer.tokens(); tok1; tok1 = tok1->next())
ostr << (tok1->previous() ? " " : "") << tok1->str();
return ostr.str();
}
@ -2478,11 +2478,11 @@ private:
tokenizer.simplifyTypedef();
std::string ret;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
for (const Token *tok1 = tokenizer.tokens(); tok1; tok1 = tok1->next())
{
if (tok != tokenizer.tokens())
if (tok1 != tokenizer.tokens())
ret += " ";
ret += tok->str();
ret += tok1->str();
}
return ret;