Skip to content

Commit a005907

Browse files
committed
Update existing code to avoid shadow argument warnings
1 parent 3dc4c60 commit a005907

19 files changed

+104
-104
lines changed

gui/mainwindow.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ void MainWindow::saveSettings() const
566566
mUI->mResults->saveSettings(mSettings);
567567
}
568568

569-
void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, const bool checkConfiguration)
569+
void MainWindow::doAnalyzeProject(ImportProject p, const bool doCheckLibrary, const bool doCheckConfiguration)
570570
{
571571
Settings checkSettings;
572572
auto supprs = std::make_shared<Suppressions>();
@@ -610,8 +610,8 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons
610610

611611
mUI->mResults->setCheckDirectory(checkPath);
612612
checkSettings.force = false;
613-
checkSettings.checkLibrary = checkLibrary;
614-
checkSettings.checkConfiguration = checkConfiguration;
613+
checkSettings.checkLibrary = doCheckLibrary;
614+
checkSettings.checkConfiguration = doCheckConfiguration;
615615

616616
if (mProjectFile)
617617
qDebug() << "Checking project file" << mProjectFile->getFilename();
@@ -638,7 +638,7 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons
638638
mUI->mResults->setCheckSettings(checkSettings);
639639
}
640640

641-
void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrary, const bool checkConfiguration)
641+
void MainWindow::doAnalyzeFiles(const QStringList &files, const bool doCheckLibrary, const bool doCheckConfiguration)
642642
{
643643
if (files.isEmpty())
644644
return;
@@ -679,7 +679,7 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar
679679
// TODO: lock UI here?
680680
mUI->mResults->checkingStarted(fdetails.size());
681681
mThread->setFiles(std::move(fdetails));
682-
if (mProjectFile && !checkConfiguration)
682+
if (mProjectFile && !doCheckConfiguration)
683683
mThread->setAddonsAndTools(mProjectFile->getAddonsAndTools());
684684
mThread->setSuppressions(mProjectFile ? mProjectFile->getCheckingSuppressions() : QList<SuppressionList::Suppression>());
685685
QDir inf(mCurrentDirectory);
@@ -689,8 +689,8 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar
689689
checkLockDownUI(); // lock UI while checking
690690

691691
mUI->mResults->setCheckDirectory(checkPath);
692-
checkSettings.checkLibrary = checkLibrary;
693-
checkSettings.checkConfiguration = checkConfiguration;
692+
checkSettings.checkLibrary = doCheckLibrary;
693+
checkSettings.checkConfiguration = doCheckConfiguration;
694694

695695
if (mProjectFile)
696696
qDebug() << "Checking project file" << mProjectFile->getFilename();
@@ -1883,7 +1883,7 @@ bool MainWindow::loadLastResults()
18831883
return true;
18841884
}
18851885

1886-
void MainWindow::analyzeProject(const ProjectFile *projectFile, const QStringList& recheckFiles, const bool checkLibrary, const bool checkConfiguration)
1886+
void MainWindow::analyzeProject(const ProjectFile *projectFile, const QStringList& recheckFiles, const bool doCheckLibrary, const bool doCheckConfiguration)
18871887
{
18881888
Settings::terminate(false);
18891889

@@ -2011,7 +2011,7 @@ void MainWindow::analyzeProject(const ProjectFile *projectFile, const QStringLis
20112011
msg.exec();
20122012
return;
20132013
}
2014-
doAnalyzeProject(p, checkLibrary, checkConfiguration); // TODO: avoid copy
2014+
doAnalyzeProject(p, doCheckLibrary, doCheckConfiguration); // TODO: avoid copy
20152015
return;
20162016
}
20172017

@@ -2024,7 +2024,7 @@ void MainWindow::analyzeProject(const ProjectFile *projectFile, const QStringLis
20242024
if (paths.isEmpty()) {
20252025
paths << mCurrentDirectory;
20262026
}
2027-
doAnalyzeFiles(paths, checkLibrary, checkConfiguration);
2027+
doAnalyzeFiles(paths, doCheckLibrary, doCheckConfiguration);
20282028
}
20292029

20302030
void MainWindow::newProjectFile()

gui/mainwindow.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private slots:
273273
* @param checkLibrary Flag to indicate if the library should be checked.
274274
* @param checkConfiguration Flag to indicate if the configuration should be checked.
275275
*/
276-
void analyzeProject(const ProjectFile *projectFile, const QStringList& recheckFiles, bool checkLibrary = false, bool checkConfiguration = false);
276+
void analyzeProject(const ProjectFile *projectFile, const QStringList& recheckFiles, bool doCheckLibrary = false, bool doCheckConfiguration = false);
277277

278278
/**
279279
* @brief Set current language
@@ -312,7 +312,7 @@ private slots:
312312
* @param checkLibrary Flag to indicate if library should be checked
313313
* @param checkConfiguration Flag to indicate if the configuration should be checked.
314314
*/
315-
void doAnalyzeProject(ImportProject p, bool checkLibrary = false, bool checkConfiguration = false);
315+
void doAnalyzeProject(ImportProject p, bool doCheckLibrary = false, bool doCheckConfiguration = false);
316316

317317
/**
318318
* @brief Analyze all files specified in parameter files
@@ -321,7 +321,7 @@ private slots:
321321
* @param checkLibrary Flag to indicate if library should be checked
322322
* @param checkConfiguration Flag to indicate if the configuration should be checked.
323323
*/
324-
void doAnalyzeFiles(const QStringList &files, bool checkLibrary = false, bool checkConfiguration = false);
324+
void doAnalyzeFiles(const QStringList &files, bool doCheckLibrary = false, bool doCheckConfiguration = false);
325325

326326
/**
327327
* @brief Get our default cppcheck settings and read project file.

lib/checkcondition.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,10 +2071,10 @@ void CheckCondition::checkCompareValueOutOfTypeRange()
20712071
}
20722072
}
20732073

2074-
void CheckCondition::compareValueOutOfTypeRangeError(const Token *comparison, const std::string &type, MathLib::bigint value, bool result)
2074+
void CheckCondition::compareValueOutOfTypeRangeError(const Token *comp, const std::string &type, MathLib::bigint value, bool result)
20752075
{
20762076
reportError(
2077-
comparison,
2077+
comp,
20782078
Severity::style,
20792079
"compareValueOutOfTypeRangeError",
20802080
"Comparing expression of type '" + type + "' against value " + MathLib::toString(value) + ". Condition is always " + bool_to_string(result) + ".",

lib/checkcondition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class CPPCHECKLIB CheckCondition : public Check {
155155
void assignmentInCondition(const Token *eq);
156156

157157
void checkCompareValueOutOfTypeRange();
158-
void compareValueOutOfTypeRangeError(const Token *comparison, const std::string &type, MathLib::bigint value, bool result);
158+
void compareValueOutOfTypeRangeError(const Token *comp, const std::string &type, MathLib::bigint value, bool result);
159159

160160
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override;
161161

lib/checkunusedfunctions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,9 @@ void CheckUnusedFunctions::analyseWholeProgram(const Settings &settings, ErrorLo
502502
}
503503
}
504504

505-
void CheckUnusedFunctions::updateFunctionData(const CheckUnusedFunctions& check)
505+
void CheckUnusedFunctions::updateFunctionData(const CheckUnusedFunctions& checkUnusedFunctions)
506506
{
507-
for (const auto& entry : check.mFunctions)
507+
for (const auto& entry : checkUnusedFunctions.mFunctions)
508508
{
509509
FunctionUsage &usage = mFunctions[entry.first];
510510
if (!usage.lineNumber) {
@@ -518,6 +518,6 @@ void CheckUnusedFunctions::updateFunctionData(const CheckUnusedFunctions& check)
518518
usage.usedOtherFile |= entry.second.usedOtherFile;
519519
usage.usedSameFile |= entry.second.usedSameFile;
520520
}
521-
mFunctionDecl.insert(mFunctionDecl.cend(), check.mFunctionDecl.cbegin(), check.mFunctionDecl.cend());
522-
mFunctionCalls.insert(check.mFunctionCalls.cbegin(), check.mFunctionCalls.cend());
521+
mFunctionDecl.insert(mFunctionDecl.cend(), checkUnusedFunctions.mFunctionDecl.cbegin(), checkUnusedFunctions.mFunctionDecl.cend());
522+
mFunctionCalls.insert(checkUnusedFunctions.mFunctionCalls.cbegin(), checkUnusedFunctions.mFunctionCalls.cend());
523523
}

lib/checkunusedfunctions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class CPPCHECKLIB CheckUnusedFunctions {
5858
// Return true if an error is reported.
5959
bool check(const Settings& settings, ErrorLogger& errorLogger) const;
6060

61-
void updateFunctionData(const CheckUnusedFunctions& check);
61+
void updateFunctionData(const CheckUnusedFunctions& checkUnusedFunctions);
6262

6363
private:
6464
static void unusedFunctionError(ErrorLogger& errorLogger,

lib/filesettings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ class FileWithDetails
9191
return mFsFileId;
9292
}
9393

94-
void setFsFileId(std::size_t fsFileId)
94+
void setFsFileId(std::size_t id)
9595
{
96-
mFsFileId = fsFileId;
96+
mFsFileId = id;
9797
}
9898
private:
9999
std::string mPath;

lib/preprocessor.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -512,14 +512,14 @@ static std::string readcondition(const simplecpp::Token *iftok, const std::set<s
512512
return cfgStr;
513513
}
514514

515-
static bool hasDefine(const std::string &userDefines, const std::string &cfg)
515+
static bool hasDefine(const std::string &userDefines, const std::string &cfgStr)
516516
{
517-
if (cfg.empty()) {
517+
if (cfgStr.empty()) {
518518
return false;
519519
}
520520

521521
std::string::size_type pos = 0;
522-
const std::string cfgname = cfg.substr(0, cfg.find('='));
522+
const std::string cfgname = cfgStr.substr(0, cfgStr.find('='));
523523
while (pos < userDefines.size()) {
524524
pos = userDefines.find(cfgname, pos);
525525
if (pos == std::string::npos)
@@ -550,11 +550,11 @@ static std::string cfg(const std::vector<std::string> &configs, const std::strin
550550
return ret;
551551
}
552552

553-
static bool isUndefined(const std::string &cfg, const std::set<std::string> &undefined)
553+
static bool isUndefined(const std::string &cfgStr, const std::set<std::string> &undefined)
554554
{
555-
for (std::string::size_type pos1 = 0U; pos1 < cfg.size();) {
556-
const std::string::size_type pos2 = cfg.find(';',pos1);
557-
const std::string def = (pos2 == std::string::npos) ? cfg.substr(pos1) : cfg.substr(pos1, pos2 - pos1);
555+
for (std::string::size_type pos1 = 0U; pos1 < cfgStr.size();) {
556+
const std::string::size_type pos2 = cfgStr.find(';',pos1);
557+
const std::string def = (pos2 == std::string::npos) ? cfgStr.substr(pos1) : cfgStr.substr(pos1, pos2 - pos1);
558558

559559
const std::string::size_type eq = def.find('=');
560560
if (eq == std::string::npos && undefined.find(def) != undefined.end())
@@ -797,11 +797,11 @@ std::set<std::string> Preprocessor::getConfigs() const
797797
return ret;
798798
}
799799

800-
static void splitcfg(const std::string &cfg, std::list<std::string> &defines, const std::string &defaultValue)
800+
static void splitcfg(const std::string &cfgStr, std::list<std::string> &defines, const std::string &defaultValue)
801801
{
802-
for (std::string::size_type defineStartPos = 0U; defineStartPos < cfg.size();) {
803-
const std::string::size_type defineEndPos = cfg.find(';', defineStartPos);
804-
std::string def = (defineEndPos == std::string::npos) ? cfg.substr(defineStartPos) : cfg.substr(defineStartPos, defineEndPos - defineStartPos);
802+
for (std::string::size_type defineStartPos = 0U; defineStartPos < cfgStr.size();) {
803+
const std::string::size_type defineEndPos = cfgStr.find(';', defineStartPos);
804+
std::string def = (defineEndPos == std::string::npos) ? cfgStr.substr(defineStartPos) : cfgStr.substr(defineStartPos, defineEndPos - defineStartPos);
805805
if (!defaultValue.empty() && def.find('=') == std::string::npos)
806806
def += '=' + defaultValue;
807807
defines.push_back(std::move(def));
@@ -811,14 +811,14 @@ static void splitcfg(const std::string &cfg, std::list<std::string> &defines, co
811811
}
812812
}
813813

814-
static simplecpp::DUI createDUI(const Settings &mSettings, const std::string &cfg, Standards::Language lang)
814+
static simplecpp::DUI createDUI(const Settings &mSettings, const std::string &cfgStr, Standards::Language lang)
815815
{
816816
// TODO: make it possible to specify platform-dependent sizes
817817
simplecpp::DUI dui;
818818

819819
splitcfg(mSettings.userDefines, dui.defines, "1");
820-
if (!cfg.empty())
821-
splitcfg(cfg, dui.defines, "");
820+
if (!cfgStr.empty())
821+
splitcfg(cfgStr, dui.defines, "");
822822

823823
for (const std::string &def : mSettings.library.defines()) {
824824
const std::string::size_type pos = def.find_first_of(" (");
@@ -899,9 +899,9 @@ void Preprocessor::setPlatformInfo()
899899
mTokens.sizeOfType["long double *"] = mSettings.platform.sizeof_pointer;
900900
}
901901

902-
simplecpp::TokenList Preprocessor::preprocess(const std::string &cfg, std::vector<std::string> &files, simplecpp::OutputList& outputList)
902+
simplecpp::TokenList Preprocessor::preprocess(const std::string &cfgStr, std::vector<std::string> &files, simplecpp::OutputList& outputList)
903903
{
904-
const simplecpp::DUI dui = createDUI(mSettings, cfg, mLang);
904+
const simplecpp::DUI dui = createDUI(mSettings, cfgStr, mLang);
905905

906906
std::list<simplecpp::MacroUsage> macroUsage;
907907
std::list<simplecpp::IfCond> ifCond;
@@ -915,10 +915,10 @@ simplecpp::TokenList Preprocessor::preprocess(const std::string &cfg, std::vecto
915915
return tokens2;
916916
}
917917

918-
std::string Preprocessor::getcode(const std::string &cfg, std::vector<std::string> &files, const bool writeLocations)
918+
std::string Preprocessor::getcode(const std::string &cfgStr, std::vector<std::string> &files, const bool writeLocations)
919919
{
920920
simplecpp::OutputList outputList;
921-
simplecpp::TokenList tokens2 = preprocess(cfg, files, outputList);
921+
simplecpp::TokenList tokens2 = preprocess(cfgStr, files, outputList);
922922
handleErrors(outputList);
923923
unsigned int prevfile = 0;
924924
unsigned int line = 1;

lib/preprocessor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ class CPPCHECKLIB WARN_UNUSED Preprocessor {
118118

119119
void setPlatformInfo();
120120

121-
simplecpp::TokenList preprocess(const std::string &cfg, std::vector<std::string> &files, simplecpp::OutputList& outputList);
121+
simplecpp::TokenList preprocess(const std::string &cfgStr, std::vector<std::string> &files, simplecpp::OutputList& outputList);
122122

123-
std::string getcode(const std::string &cfg, std::vector<std::string> &files, bool writeLocations);
123+
std::string getcode(const std::string &cfgStr, std::vector<std::string> &files, bool writeLocations);
124124

125125
/**
126126
* Calculate HASH. Using toolinfo, tokens1, filedata.

lib/programmemory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ bool ProgramMemory::getContainerEmptyValue(nonneg int exprid, MathLib::bigint& r
150150
return false;
151151
}
152152

153-
void ProgramMemory::setContainerSizeValue(const Token* expr, MathLib::bigint value, bool isEqual)
153+
void ProgramMemory::setContainerSizeValue(const Token* expr, MathLib::bigint value, bool equal)
154154
{
155155
ValueFlow::Value v(value);
156156
v.valueType = ValueFlow::Value::ValueType::CONTAINER_SIZE;
157-
if (!isEqual)
157+
if (!equal)
158158
v.valueKind = ValueFlow::Value::ValueKind::Impossible;
159159
setValue(expr, v);
160160
}

0 commit comments

Comments
 (0)