From e4875178fa4f409e3fff9d25f38c2e5cf27e46dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 6 Jan 2012 08:09:53 +0100 Subject: [PATCH] Refactoring: Removed redundant settings parameter for Preprocessor::removeComments --- lib/preprocessor.cpp | 16 ++++++++-------- lib/preprocessor.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index c9621f5af..022fbd767 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -164,7 +164,7 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename) // ------------------------------------------------------------------------------------------ // // Remove all comments.. - result = removeComments(result, filename, _settings); + result = removeComments(result, filename); // ------------------------------------------------------------------------------------------ // @@ -301,7 +301,7 @@ static bool isFallThroughComment(std::string comment) comment == "fall"; } -std::string Preprocessor::removeComments(const std::string &str, const std::string &filename, Settings *settings) +std::string Preprocessor::removeComments(const std::string &str, const std::string &filename) { // For the error report unsigned int lineno = 1; @@ -371,7 +371,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri break; std::string comment(str, commentStart, i - commentStart); - if (settings && settings->_inlineSuppressions) { + if (_settings && _settings->_inlineSuppressions) { std::istringstream iss(comment); std::string word; iss >> word; @@ -408,7 +408,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri fallThroughComment = true; } - if (settings && settings->_inlineSuppressions) { + if (_settings && _settings->_inlineSuppressions) { std::istringstream iss(comment); std::string word; iss >> word; @@ -425,10 +425,10 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri // Add any pending inline suppressions that have accumulated. if (!suppressionIDs.empty()) { - if (settings != NULL) { + if (_settings != NULL) { // Add the suppressions. for (size_t j(0); j < suppressionIDs.size(); ++j) { - const std::string errmsg(settings->nomsg.addSuppression(suppressionIDs[j], filename, lineno)); + const std::string errmsg(_settings->nomsg.addSuppression(suppressionIDs[j], filename, lineno)); if (!errmsg.empty()) { writeError(filename, lineno, _errorLogger, "cppcheckError", errmsg); } @@ -453,10 +453,10 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri // Add any pending inline suppressions that have accumulated. if (!suppressionIDs.empty()) { - if (settings != NULL) { + if (_settings != NULL) { // Add the suppressions. for (size_t j(0); j < suppressionIDs.size(); ++j) { - const std::string errmsg(settings->nomsg.addSuppression(suppressionIDs[j], filename, lineno)); + const std::string errmsg(_settings->nomsg.addSuppression(suppressionIDs[j], filename, lineno)); if (!errmsg.empty()) { writeError(filename, lineno, _errorLogger, "cppcheckError", errmsg); } diff --git a/lib/preprocessor.h b/lib/preprocessor.h index 7601c1f07..738e4c218 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -137,12 +137,12 @@ protected: /** * Remove comments from code. This should only be called from read(). + * If there are inline suppressions, the _settings member is modified * @param str Code processed by read(). * @param filename filename - * @param settings Settings. If there are inline suppressions these will be added to the settings * @return code without comments */ - std::string removeComments(const std::string &str, const std::string &filename, Settings *settings); + std::string removeComments(const std::string &str, const std::string &filename); /** * Cleanup 'if 0' from the code