CheckClass::virtualDestructorError and a variation of CheckNullPointer::nullPointerError would print inconclusive,warning messages altough no --enable=warning was given. Fix.
This commit is contained in:
parent
0b3751520b
commit
01e5f14bf8
|
@ -1647,15 +1647,17 @@ void CheckClass::virtualDestructor()
|
||||||
|
|
||||||
void CheckClass::virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived, bool inconclusive)
|
void CheckClass::virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived, bool inconclusive)
|
||||||
{
|
{
|
||||||
if (inconclusive)
|
if (inconclusive) {
|
||||||
|
if (_settings->isEnabled("warning"))
|
||||||
reportError(tok, Severity::warning, "virtualDestructor", "Class '" + Base + "' which has virtual members does not have a virtual destructor.", CWE404, true);
|
reportError(tok, Severity::warning, "virtualDestructor", "Class '" + Base + "' which has virtual members does not have a virtual destructor.", CWE404, true);
|
||||||
else
|
} else {
|
||||||
reportError(tok, Severity::error, "virtualDestructor", "Class '" + Base + "' which is inherited by class '" + Derived + "' does not have a virtual destructor.\n"
|
reportError(tok, Severity::error, "virtualDestructor", "Class '" + Base + "' which is inherited by class '" + Derived + "' does not have a virtual destructor.\n"
|
||||||
"Class '" + Base + "' which is inherited by class '" + Derived + "' does not have a virtual destructor. "
|
"Class '" + Base + "' which is inherited by class '" + Derived + "' does not have a virtual destructor. "
|
||||||
"If you destroy instances of the derived class by deleting a pointer that points to the base class, only "
|
"If you destroy instances of the derived class by deleting a pointer that points to the base class, only "
|
||||||
"the destructor of the base class is executed. Thus, dynamic memory that is managed by the derived class "
|
"the destructor of the base class is executed. Thus, dynamic memory that is managed by the derived class "
|
||||||
"could leak. This can be avoided by adding a virtual destructor to the base class.", CWE404, false);
|
"could leak. This can be avoided by adding a virtual destructor to the base class.", CWE404, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// warn for "this-x". The indented code may be "this->x"
|
// warn for "this-x". The indented code may be "this->x"
|
||||||
|
|
|
@ -487,6 +487,8 @@ void CheckNullPointer::nullPointerError(const Token *tok, const std::string &var
|
||||||
|
|
||||||
void CheckNullPointer::nullPointerError(const Token *tok, const std::string &varname, const Token* nullCheck, bool inconclusive)
|
void CheckNullPointer::nullPointerError(const Token *tok, const std::string &varname, const Token* nullCheck, bool inconclusive)
|
||||||
{
|
{
|
||||||
|
if (! _settings->isEnabled("warning"))
|
||||||
|
return;
|
||||||
std::list<const Token*> callstack;
|
std::list<const Token*> callstack;
|
||||||
callstack.push_back(tok);
|
callstack.push_back(tok);
|
||||||
callstack.push_back(nullCheck);
|
callstack.push_back(nullCheck);
|
||||||
|
|
|
@ -1893,6 +1893,7 @@ private:
|
||||||
errout.str("");
|
errout.str("");
|
||||||
|
|
||||||
settings0.inconclusive = inconclusive;
|
settings0.inconclusive = inconclusive;
|
||||||
|
settings0.addEnabled("warning");
|
||||||
|
|
||||||
// Tokenize..
|
// Tokenize..
|
||||||
Tokenizer tokenizer(&settings0, this);
|
Tokenizer tokenizer(&settings0, this);
|
||||||
|
|
Loading…
Reference in New Issue