Skip to content

Commit e487517

Browse files
committed
Refactoring: Removed redundant settings parameter for Preprocessor::removeComments
1 parent 94d220e commit e487517

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎lib/preprocessor.cpp‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename)
164164
// ------------------------------------------------------------------------------------------
165165
//
166166
// Remove all comments..
167-
result = removeComments(result, filename, _settings);
167+
result = removeComments(result, filename);
168168

169169
// ------------------------------------------------------------------------------------------
170170
//
@@ -301,7 +301,7 @@ static bool isFallThroughComment(std::string comment)
301301
comment == "fall";
302302
}
303303

304-
std::string Preprocessor::removeComments(const std::string &str, const std::string &filename, Settings *settings)
304+
std::string Preprocessor::removeComments(const std::string &str, const std::string &filename)
305305
{
306306
// For the error report
307307
unsigned int lineno = 1;
@@ -371,7 +371,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
371371
break;
372372
std::string comment(str, commentStart, i - commentStart);
373373

374-
if (settings && settings->_inlineSuppressions) {
374+
if (_settings && _settings->_inlineSuppressions) {
375375
std::istringstream iss(comment);
376376
std::string word;
377377
iss >> word;
@@ -408,7 +408,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
408408
fallThroughComment = true;
409409
}
410410

411-
if (settings && settings->_inlineSuppressions) {
411+
if (_settings && _settings->_inlineSuppressions) {
412412
std::istringstream iss(comment);
413413
std::string word;
414414
iss >> word;
@@ -425,10 +425,10 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
425425

426426
// Add any pending inline suppressions that have accumulated.
427427
if (!suppressionIDs.empty()) {
428-
if (settings != NULL) {
428+
if (_settings != NULL) {
429429
// Add the suppressions.
430430
for (size_t j(0); j < suppressionIDs.size(); ++j) {
431-
const std::string errmsg(settings->nomsg.addSuppression(suppressionIDs[j], filename, lineno));
431+
const std::string errmsg(_settings->nomsg.addSuppression(suppressionIDs[j], filename, lineno));
432432
if (!errmsg.empty()) {
433433
writeError(filename, lineno, _errorLogger, "cppcheckError", errmsg);
434434
}
@@ -453,10 +453,10 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
453453

454454
// Add any pending inline suppressions that have accumulated.
455455
if (!suppressionIDs.empty()) {
456-
if (settings != NULL) {
456+
if (_settings != NULL) {
457457
// Add the suppressions.
458458
for (size_t j(0); j < suppressionIDs.size(); ++j) {
459-
const std::string errmsg(settings->nomsg.addSuppression(suppressionIDs[j], filename, lineno));
459+
const std::string errmsg(_settings->nomsg.addSuppression(suppressionIDs[j], filename, lineno));
460460
if (!errmsg.empty()) {
461461
writeError(filename, lineno, _errorLogger, "cppcheckError", errmsg);
462462
}

‎lib/preprocessor.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ class Preprocessor {
137137

138138
/**
139139
* Remove comments from code. This should only be called from read().
140+
* If there are inline suppressions, the _settings member is modified
140141
* @param str Code processed by read().
141142
* @param filename filename
142-
* @param settings Settings. If there are inline suppressions these will be added to the settings
143143
* @return code without comments
144144
*/
145-
std::string removeComments(const std::string &str, const std::string &filename, Settings *settings);
145+
std::string removeComments(const std::string &str, const std::string &filename);
146146

147147
/**
148148
* Cleanup 'if 0' from the code

0 commit comments

Comments
 (0)