Refactoring: Removed redundant settings parameter for Preprocessor::removeComments
This commit is contained in:
parent
94d220e370
commit
e4875178fa
|
@ -164,7 +164,7 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename)
|
||||||
// ------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Remove all comments..
|
// Remove all comments..
|
||||||
result = removeComments(result, filename, _settings);
|
result = removeComments(result, filename);
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -301,7 +301,7 @@ static bool isFallThroughComment(std::string comment)
|
||||||
comment == "fall";
|
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
|
// For the error report
|
||||||
unsigned int lineno = 1;
|
unsigned int lineno = 1;
|
||||||
|
@ -371,7 +371,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
|
||||||
break;
|
break;
|
||||||
std::string comment(str, commentStart, i - commentStart);
|
std::string comment(str, commentStart, i - commentStart);
|
||||||
|
|
||||||
if (settings && settings->_inlineSuppressions) {
|
if (_settings && _settings->_inlineSuppressions) {
|
||||||
std::istringstream iss(comment);
|
std::istringstream iss(comment);
|
||||||
std::string word;
|
std::string word;
|
||||||
iss >> word;
|
iss >> word;
|
||||||
|
@ -408,7 +408,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
|
||||||
fallThroughComment = true;
|
fallThroughComment = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings && settings->_inlineSuppressions) {
|
if (_settings && _settings->_inlineSuppressions) {
|
||||||
std::istringstream iss(comment);
|
std::istringstream iss(comment);
|
||||||
std::string word;
|
std::string word;
|
||||||
iss >> 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.
|
// Add any pending inline suppressions that have accumulated.
|
||||||
if (!suppressionIDs.empty()) {
|
if (!suppressionIDs.empty()) {
|
||||||
if (settings != NULL) {
|
if (_settings != NULL) {
|
||||||
// Add the suppressions.
|
// Add the suppressions.
|
||||||
for (size_t j(0); j < suppressionIDs.size(); ++j) {
|
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()) {
|
if (!errmsg.empty()) {
|
||||||
writeError(filename, lineno, _errorLogger, "cppcheckError", errmsg);
|
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.
|
// Add any pending inline suppressions that have accumulated.
|
||||||
if (!suppressionIDs.empty()) {
|
if (!suppressionIDs.empty()) {
|
||||||
if (settings != NULL) {
|
if (_settings != NULL) {
|
||||||
// Add the suppressions.
|
// Add the suppressions.
|
||||||
for (size_t j(0); j < suppressionIDs.size(); ++j) {
|
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()) {
|
if (!errmsg.empty()) {
|
||||||
writeError(filename, lineno, _errorLogger, "cppcheckError", errmsg);
|
writeError(filename, lineno, _errorLogger, "cppcheckError", errmsg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,12 +137,12 @@ protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove comments from code. This should only be called from read().
|
* 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 str Code processed by read().
|
||||||
* @param filename filename
|
* @param filename filename
|
||||||
* @param settings Settings. If there are inline suppressions these will be added to the settings
|
|
||||||
* @return code without comments
|
* @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
|
* Cleanup 'if 0' from the code
|
||||||
|
|
Loading…
Reference in New Issue