Preprocessor: Tweak parseCommentToken
This commit is contained in:
parent
5ed5bf935f
commit
bba340da3d
|
@ -78,9 +78,23 @@ namespace {
|
||||||
|
|
||||||
static void parseCommentToken(const simplecpp::Token *tok, std::list<Suppressions::Suppression> &inlineSuppressions, std::list<BadInlineSuppression> *bad)
|
static void parseCommentToken(const simplecpp::Token *tok, std::list<Suppressions::Suppression> &inlineSuppressions, std::list<BadInlineSuppression> *bad)
|
||||||
{
|
{
|
||||||
const std::size_t position=tok->str().find("cppcheck-suppress");
|
if (tok->str().size() < 19)
|
||||||
if (position != std::string::npos) {
|
return;
|
||||||
if ((tok->str().length() > position+17) && (tok->str()[position+17] == '[')) { //multi suppress format
|
const std::string::size_type pos1 = tok->str().find_first_not_of("/* \t");
|
||||||
|
if (pos1 == std::string::npos)
|
||||||
|
return;
|
||||||
|
if (pos1 + 17 >= tok->str().size())
|
||||||
|
return;
|
||||||
|
if (tok->str().compare(pos1, 17, "cppcheck-suppress") != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// skip spaces after "cppcheck-suppress"
|
||||||
|
const std::string::size_type pos2 = tok->str().find_first_not_of(" ", pos1+17);
|
||||||
|
if (pos2 == std::string::npos)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (tok->str()[pos2] == '[') {
|
||||||
|
// multi suppress format
|
||||||
std::string errmsg;
|
std::string errmsg;
|
||||||
std::vector<Suppressions::Suppression> ss;
|
std::vector<Suppressions::Suppression> ss;
|
||||||
ss = Suppressions::parseMultiSuppressComment(tok->str(), &errmsg);
|
ss = Suppressions::parseMultiSuppressComment(tok->str(), &errmsg);
|
||||||
|
@ -92,7 +106,8 @@ static void parseCommentToken(const simplecpp::Token *tok, std::list<Suppression
|
||||||
if (!(*iter).errorId.empty())
|
if (!(*iter).errorId.empty())
|
||||||
inlineSuppressions.push_back(*iter);
|
inlineSuppressions.push_back(*iter);
|
||||||
}
|
}
|
||||||
} else { //single suppress format
|
} else {
|
||||||
|
//single suppress format
|
||||||
std::string errmsg;
|
std::string errmsg;
|
||||||
Suppressions::Suppression s;
|
Suppressions::Suppression s;
|
||||||
if (!s.parseComment(tok->str(), &errmsg))
|
if (!s.parseComment(tok->str(), &errmsg))
|
||||||
|
@ -104,9 +119,6 @@ static void parseCommentToken(const simplecpp::Token *tok, std::list<Suppression
|
||||||
if (!errmsg.empty())
|
if (!errmsg.empty())
|
||||||
bad->push_back(BadInlineSuppression(tok->location, errmsg));
|
bad->push_back(BadInlineSuppression(tok->location, errmsg));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void inlineSuppressions(const simplecpp::TokenList &tokens, Settings &mSettings, std::list<BadInlineSuppression> *bad)
|
static void inlineSuppressions(const simplecpp::TokenList &tokens, Settings &mSettings, std::list<BadInlineSuppression> *bad)
|
||||||
|
|
Loading…
Reference in New Issue