Skip to content

Commit 05acc13

Browse files
Shadow variables, const, rename function (#3456)
1 parent a9a093e commit 05acc13

5 files changed

Lines changed: 26 additions & 26 deletions

File tree

lib/checkother.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,8 +2988,8 @@ void CheckOther::checkAccessOfMovedVariable()
29882988
else
29892989
inconclusive = true;
29902990
} else {
2991-
const bool isVariableChanged = isVariableChangedByFunctionCall(tok, 0, mSettings, &inconclusive);
2992-
accessOfMoved = !isVariableChanged && checkUninitVar.isVariableUsage(tok, false, CheckUninitVar::NO_ALLOC);
2991+
const bool variableChanged = isVariableChangedByFunctionCall(tok, 0, mSettings, &inconclusive);
2992+
accessOfMoved = !variableChanged && checkUninitVar.isVariableUsage(tok, false, CheckUninitVar::NO_ALLOC);
29932993
if (inconclusive) {
29942994
accessOfMoved = !isMovedParameterAllowedForInconclusiveFunction(tok);
29952995
if (accessOfMoved)

lib/exprengine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ namespace {
303303
}
304304
}
305305

306-
void report(std::ostream &out, const Scope *functionScope) {
306+
void report(std::ostream &out, const Scope *functionScope) const {
307307
int linenr = -1;
308308
std::string code;
309309
for (const Token *tok = functionScope->bodyStart->next(); tok != functionScope->bodyEnd; tok = tok->next()) {

lib/preprocessor.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::Token *tok, std:
127127
return true;
128128
}
129129

130-
static void inlineSuppressions(const simplecpp::TokenList &tokens, Settings &mSettings, std::list<BadInlineSuppression> *bad)
130+
static void addinlineSuppressions(const simplecpp::TokenList &tokens, Settings &mSettings, std::list<BadInlineSuppression> *bad)
131131
{
132132
for (const simplecpp::Token *tok = tokens.cfront(); tok; tok = tok->next) {
133133
if (!tok->comment)
@@ -187,10 +187,10 @@ void Preprocessor::inlineSuppressions(const simplecpp::TokenList &tokens)
187187
if (!mSettings.inlineSuppressions)
188188
return;
189189
std::list<BadInlineSuppression> err;
190-
::inlineSuppressions(tokens, mSettings, &err);
190+
::addinlineSuppressions(tokens, mSettings, &err);
191191
for (std::map<std::string,simplecpp::TokenList*>::const_iterator it = mTokenLists.begin(); it != mTokenLists.end(); ++it) {
192192
if (it->second)
193-
::inlineSuppressions(*it->second, mSettings, &err);
193+
::addinlineSuppressions(*it->second, mSettings, &err);
194194
}
195195
for (const BadInlineSuppression &bad : err) {
196196
error(bad.location.file(), bad.location.line, bad.errmsg);
@@ -292,13 +292,13 @@ static std::string readcondition(const simplecpp::Token *iftok, const std::set<s
292292
if (sameline(iftok,dtok) && dtok->name && defined.find(dtok->str()) == defined.end() && undefined.find(dtok->str()) == undefined.end())
293293
configset.insert(dtok->str());
294294
}
295-
std::string cfg;
295+
std::string cfgStr;
296296
for (const std::string &s : configset) {
297-
if (!cfg.empty())
298-
cfg += ';';
299-
cfg += s;
297+
if (!cfgStr.empty())
298+
cfgStr += ';';
299+
cfgStr += s;
300300
}
301-
return cfg;
301+
return cfgStr;
302302
}
303303

304304
static bool hasDefine(const std::string &userDefines, const std::string &cfg)
@@ -324,16 +324,16 @@ static std::string cfg(const std::vector<std::string> &configs, const std::strin
324324
{
325325
std::set<std::string> configs2(configs.begin(), configs.end());
326326
std::string ret;
327-
for (const std::string &cfg : configs2) {
328-
if (cfg.empty())
327+
for (const std::string &c : configs2) {
328+
if (c.empty())
329329
continue;
330-
if (cfg == "0")
330+
if (c == "0")
331331
return "";
332-
if (hasDefine(userDefines, cfg))
332+
if (hasDefine(userDefines, c))
333333
continue;
334334
if (!ret.empty())
335335
ret += ';';
336-
ret += cfg;
336+
ret += c;
337337
}
338338
return ret;
339339
}
@@ -552,9 +552,9 @@ void Preprocessor::preprocess(std::istream &istr, std::map<std::string, std::str
552552

553553
const std::set<std::string> configs = getConfigs(tokens1);
554554

555-
for (const std::string &cfg : configs) {
556-
if (mSettings.userUndefs.find(cfg) == mSettings.userUndefs.end()) {
557-
result[cfg] = getcode(tokens1, cfg, files, false);
555+
for (const std::string &c : configs) {
556+
if (mSettings.userUndefs.find(c) == mSettings.userUndefs.end()) {
557+
result[c] = getcode(tokens1, c, files, false);
558558
}
559559
}
560560
}

lib/templatesimplifier.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,9 +1680,9 @@ void TemplateSimplifier::expandTemplate(
16801680
const bool isVariadicTemplateArg = templateDeclaration.isVariadic() && itype + 1 == typeParametersInDeclaration.size();
16811681
if (isVariadicTemplateArg && Token::Match(start, "%name% ... %name%"))
16821682
start = start->tokAt(2);
1683-
const std::string endsWith(isVariadicTemplateArg ? ">" : ",>");
1683+
const std::string endStr(isVariadicTemplateArg ? ">" : ",>");
16841684
for (const Token *typetok = mTypesUsedInTemplateInstantiation[itype].token();
1685-
typetok && (typeindentlevel > 0 || endsWith.find(typetok->str()[0]) == std::string::npos);
1685+
typetok && (typeindentlevel > 0 || endStr.find(typetok->str()[0]) == std::string::npos);
16861686
typetok = typetok->next()) {
16871687
if (typeindentlevel == 0 && typetok->str() == "*")
16881688
pointerType = true;
@@ -2041,9 +2041,9 @@ void TemplateSimplifier::expandTemplate(
20412041
const bool isVariadicTemplateArg = templateDeclaration.isVariadic() && itype + 1 == typeParametersInDeclaration.size();
20422042
if (isVariadicTemplateArg && Token::Match(tok3, "%name% ... %name%"))
20432043
tok3 = tok3->tokAt(2);
2044-
const std::string endsWith(isVariadicTemplateArg ? ">" : ",>");
2044+
const std::string endStr(isVariadicTemplateArg ? ">" : ",>");
20452045
for (const Token *typetok = mTypesUsedInTemplateInstantiation[itype].token();
2046-
typetok && (typeindentlevel > 0 || endsWith.find(typetok->str()[0]) == std::string::npos);
2046+
typetok && (typeindentlevel > 0 || endStr.find(typetok->str()[0]) == std::string::npos);
20472047
typetok = typetok->next()) {
20482048
if (typeindentlevel == 0 && typetok->str() == "*")
20492049
pointerType = true;

test/testnullpointer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,9 +3928,9 @@ class TestNullPointer : public TestFixture {
39283928

39293929
// Check code..
39303930
std::list<Check::FileInfo*> fileInfo;
3931-
CheckNullPointer check(&tokenizer, &settings, this);
3932-
fileInfo.push_back(check.getFileInfo(&tokenizer, &settings));
3933-
check.analyseWholeProgram(ctu, fileInfo, settings, *this);
3931+
CheckNullPointer checkNullPointer(&tokenizer, &settings, this);
3932+
fileInfo.push_back(checkNullPointer.getFileInfo(&tokenizer, &settings));
3933+
checkNullPointer.analyseWholeProgram(ctu, fileInfo, settings, *this);
39343934
while (!fileInfo.empty()) {
39353935
delete fileInfo.back();
39363936
fileInfo.pop_back();

0 commit comments

Comments
 (0)