Fixed #4210 (Unmatched suppression warning emitted from disabled check)
This commit is contained in:
parent
c9c04f9691
commit
865c0205e3
|
@ -264,6 +264,9 @@ std::list<Suppressions::SuppressionEntry> Suppressions::getUnmatchedLocalSuppres
|
||||||
{
|
{
|
||||||
std::list<SuppressionEntry> r;
|
std::list<SuppressionEntry> r;
|
||||||
for (std::map<std::string, FileMatcher>::const_iterator i = _suppressions.begin(); i != _suppressions.end(); ++i) {
|
for (std::map<std::string, FileMatcher>::const_iterator i = _suppressions.begin(); i != _suppressions.end(); ++i) {
|
||||||
|
if (i->first == "unusedFunction")
|
||||||
|
continue; // unusedFunction is not a "local" suppression
|
||||||
|
|
||||||
std::map<std::string, std::map<unsigned int, bool> >::const_iterator f = i->second._files.find(file);
|
std::map<std::string, std::map<unsigned int, bool> >::const_iterator f = i->second._files.find(file);
|
||||||
if (f != i->second._files.end()) {
|
if (f != i->second._files.end()) {
|
||||||
for (std::map<unsigned int, bool>::const_iterator l = f->second.begin(); l != f->second.end(); ++l) {
|
for (std::map<unsigned int, bool>::const_iterator l = f->second.begin(); l != f->second.end(); ++l) {
|
||||||
|
@ -280,6 +283,7 @@ std::list<Suppressions::SuppressionEntry> Suppressions::getUnmatchedGlobalSuppre
|
||||||
{
|
{
|
||||||
std::list<SuppressionEntry> r;
|
std::list<SuppressionEntry> r;
|
||||||
for (std::map<std::string, FileMatcher>::const_iterator i = _suppressions.begin(); i != _suppressions.end(); ++i) {
|
for (std::map<std::string, FileMatcher>::const_iterator i = _suppressions.begin(); i != _suppressions.end(); ++i) {
|
||||||
|
// global suppressions..
|
||||||
for (std::map<std::string, std::map<unsigned int, bool> >::const_iterator g = i->second._globs.begin(); g != i->second._globs.end(); ++g) {
|
for (std::map<std::string, std::map<unsigned int, bool> >::const_iterator g = i->second._globs.begin(); g != i->second._globs.end(); ++g) {
|
||||||
for (std::map<unsigned int, bool>::const_iterator l = g->second.begin(); l != g->second.end(); ++l) {
|
for (std::map<unsigned int, bool>::const_iterator l = g->second.begin(); l != g->second.end(); ++l) {
|
||||||
if (!l->second) {
|
if (!l->second) {
|
||||||
|
@ -287,6 +291,17 @@ std::list<Suppressions::SuppressionEntry> Suppressions::getUnmatchedGlobalSuppre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unusedFunction..
|
||||||
|
if (i->first == "unusedFunction") {
|
||||||
|
for (std::map<std::string, std::map<unsigned int, bool> >::const_iterator f = i->second._files.begin(); f != i->second._files.end(); ++f) {
|
||||||
|
for (std::map<unsigned int, bool>::const_iterator l = f->second.begin(); l != f->second.end(); ++l) {
|
||||||
|
if (!l->second) {
|
||||||
|
r.push_back(SuppressionEntry(i->first, f->first, l->first));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ private:
|
||||||
TEST_CASE(suppressionsFileNameWithExtraPath);
|
TEST_CASE(suppressionsFileNameWithExtraPath);
|
||||||
TEST_CASE(suppressionsSettings);
|
TEST_CASE(suppressionsSettings);
|
||||||
TEST_CASE(suppressionsMultiFile);
|
TEST_CASE(suppressionsMultiFile);
|
||||||
|
|
||||||
|
TEST_CASE(inlinesuppress_unusedFunction); // #4210 - unusedFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
void suppressionsBadId1() {
|
void suppressionsBadId1() {
|
||||||
|
@ -311,6 +313,12 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void inlinesuppress_unusedFunction() { // #4210 - wrong report of "unmatchedSuppression" for "unusedFunction"
|
||||||
|
Suppressions suppressions;
|
||||||
|
suppressions.addSuppression("unusedFunction", "test.c", 3U);
|
||||||
|
ASSERT_EQUALS(true, suppressions.getUnmatchedLocalSuppressions("test.c").empty());
|
||||||
|
ASSERT_EQUALS(false, suppressions.getUnmatchedGlobalSuppressions().empty());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestSuppressions)
|
REGISTER_TEST(TestSuppressions)
|
||||||
|
|
Loading…
Reference in New Issue