Skip to content

Commit ddd4b6c

Browse files
authored
do not call ErrorLogger::reportProgress() in case it is disabled (danmar#7364)
1 parent 5050327 commit ddd4b6c

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

lib/symboldatabase.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,15 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
169169
// Store current access in each scope (depends on evaluation progress)
170170
std::map<const Scope*, AccessControl> access;
171171

172+
const bool doProgress = (mSettings.reportProgress != -1);
173+
172174
// find all scopes
173175
for (const Token *tok = mTokenizer.tokens(); tok; tok = tok ? tok->next() : nullptr) {
174176
// #5593 suggested to add here:
175-
mErrorLogger.reportProgress(mTokenizer.list.getSourceFilePath(),
176-
"SymbolDatabase",
177-
tok->progressValue());
177+
if (doProgress)
178+
mErrorLogger.reportProgress(mTokenizer.list.getSourceFilePath(),
179+
"SymbolDatabase",
180+
tok->progressValue());
178181
// Locate next class
179182
if ((tok->isCpp() && tok->isKeyword() &&
180183
((Token::Match(tok, "class|struct|union|namespace ::| %name% final| {|:|::|<") &&

lib/templatesimplifier.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,7 +3186,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
31863186
continue;
31873187

31883188
Token * const tok2 = instantiation.token();
3189-
if (!mTokenList.getFiles().empty())
3189+
if ((mSettings.reportProgress != -1) && !mTokenList.getFiles().empty())
31903190
mErrorLogger.reportProgress(mTokenList.getFiles()[0], "TemplateSimplifier::simplifyTemplateInstantiations()", tok2->progressValue());
31913191

31923192
if (maxtime > 0 && std::time(nullptr) > maxtime) {
@@ -3262,7 +3262,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
32623262
// TODO: remove the specialized check and handle all uninstantiated templates someday.
32633263
if (!instantiated && specialized) {
32643264
auto * tok2 = const_cast<Token *>(templateDeclaration.nameToken());
3265-
if (!mTokenList.getFiles().empty())
3265+
if ((mSettings.reportProgress != -1) && !mTokenList.getFiles().empty())
32663266
mErrorLogger.reportProgress(mTokenList.getFiles()[0], "TemplateSimplifier::simplifyTemplateInstantiations()", tok2->progressValue());
32673267

32683268
if (maxtime > 0 && std::time(nullptr) > maxtime) {

lib/tokenize.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,9 +1161,10 @@ void Tokenizer::simplifyTypedefCpp()
11611161
simplifyUsingToTypedef();
11621162

11631163
const std::time_t maxTime = mSettings.typedefMaxTime > 0 ? std::time(nullptr) + mSettings.typedefMaxTime: 0;
1164+
const bool doProgress = (mSettings.reportProgress != -1) && !list.getFiles().empty();
11641165

11651166
for (Token *tok = list.front(); tok; tok = tok->next()) {
1166-
if (!list.getFiles().empty())
1167+
if (doProgress)
11671168
mErrorLogger.reportProgress(list.getFiles()[0], "Tokenize (typedef)", tok->progressValue());
11681169

11691170
if (Settings::terminated())
@@ -2879,8 +2880,10 @@ bool Tokenizer::simplifyUsing()
28792880
};
28802881
std::list<Using> usingList;
28812882

2883+
const bool doProgress = (mSettings.reportProgress != -1) && !list.getFiles().empty();
2884+
28822885
for (Token *tok = list.front(); tok; tok = tok->next()) {
2883-
if (!list.getFiles().empty())
2886+
if (doProgress)
28842887
mErrorLogger.reportProgress(list.getFiles()[0], "Tokenize (using)", tok->progressValue());
28852888

28862889
if (Settings::terminated())

0 commit comments

Comments
 (0)