Skip to content

Commit d0db0f1

Browse files
committed
cleaned up SuppressionList changes
1 parent db4a490 commit d0db0f1

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

cli/processexecutor.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,11 @@ bool ProcessExecutor::handleRead(int rpipe, unsigned int &result, const std::str
240240
std::cerr << "#### ThreadExecutor::handleRead(" << filename << ") adding of inline suppression failed - insufficient data" << std::endl;
241241
std::exit(EXIT_FAILURE);
242242
}
243-
const std::string err = mSuppressions.addSuppressionLine(parts[0], true, parts[1] == "1", parts[2] == "1");
243+
auto suppr = SuppressionList::parseLine(parts[0]);
244+
suppr.isInline = true;
245+
suppr.checked = parts[1] == "1";
246+
suppr.matched = parts[2] == "1";
247+
const std::string err = mSuppressions.addSuppression(std::move(suppr));
244248
if (!err.empty()) {
245249
// TODO: make this non-fatal
246250
std::cerr << "#### ThreadExecutor::handleRead(" << filename << ") adding of inline suppression failed - " << err << std::endl;

lib/suppressions.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ std::vector<SuppressionList::Suppression> SuppressionList::parseMultiSuppressCom
204204
return suppressions;
205205
}
206206

207-
std::string SuppressionList::addSuppressionLine(const std::string &line, bool isInline, bool checked, bool matched)
207+
SuppressionList::Suppression SuppressionList::parseLine(const std::string &line)
208208
{
209209
std::istringstream lineStream;
210210
SuppressionList::Suppression suppression;
@@ -248,11 +248,13 @@ std::string SuppressionList::addSuppressionLine(const std::string &line, bool is
248248
}
249249

250250
suppression.fileName = Path::simplifyPath(suppression.fileName);
251-
suppression.isInline = isInline;
252-
suppression.checked = checked;
253-
suppression.matched = matched;
254251

255-
return addSuppression(std::move(suppression));
252+
return suppression;
253+
}
254+
255+
std::string SuppressionList::addSuppressionLine(const std::string &line)
256+
{
257+
return addSuppression(parseLine(line));
256258
}
257259

258260
std::string SuppressionList::addSuppression(SuppressionList::Suppression suppression)

lib/suppressions.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,19 @@ class CPPCHECKLIB SuppressionList {
177177
*/
178178
static std::vector<Suppression> parseMultiSuppressComment(const std::string &comment, std::string *errorMessage);
179179

180+
/**
181+
* Create a Suppression object from a suppression line
182+
* @param line The line to parse.
183+
* @return a suppression object
184+
*/
185+
static Suppression parseLine(const std::string &line);
186+
180187
/**
181188
* @brief Don't show the given error.
182189
* @param line Description of error to suppress (in id:file:line format).
183-
* @param isInline Indicates if it is an inline suppression.
184-
* @param checked The initial checked state.
185-
* @param matched The initial matched state.
186190
* @return error message. empty upon success
187191
*/
188-
std::string addSuppressionLine(const std::string &line, bool isInline = false, bool checked = false, bool matched = false);
192+
std::string addSuppressionLine(const std::string &line);
189193

190194
/**
191195
* @brief Don't show this error. File and/or line are optional. In which case

0 commit comments

Comments
 (0)