refactoring: enable the 'suspicious pointer subtraction' checking
This commit is contained in:
parent
6eb16e0f16
commit
ae576be088
|
@ -1474,12 +1474,12 @@ void CheckClass::virtualDestructor()
|
||||||
|
|
||||||
void CheckClass::thisSubtractionError(const Token *tok)
|
void CheckClass::thisSubtractionError(const Token *tok)
|
||||||
{
|
{
|
||||||
reportError(tok, Severity::possibleStyle, "thisSubtraction", "Suspicious pointer subtraction");
|
reportError(tok, Severity::style, "thisSubtraction", "Suspicious pointer subtraction");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckClass::thisSubtraction()
|
void CheckClass::thisSubtraction()
|
||||||
{
|
{
|
||||||
if (!_settings->_checkCodingStyle || !_settings->inconclusive)
|
if (!_settings->_checkCodingStyle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Token *tok = _tokenizer->tokens();
|
const Token *tok = _tokenizer->tokens();
|
||||||
|
|
|
@ -2123,20 +2123,20 @@ private:
|
||||||
void this_subtraction()
|
void this_subtraction()
|
||||||
{
|
{
|
||||||
checkThisSubtraction("; this-x ;");
|
checkThisSubtraction("; this-x ;");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (possible style) Suspicious pointer subtraction\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (style) Suspicious pointer subtraction\n", errout.str());
|
||||||
|
|
||||||
checkThisSubtraction("; *this = *this-x ;");
|
checkThisSubtraction("; *this = *this-x ;");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
checkThisSubtraction("; *this = *this-x ;\n"
|
checkThisSubtraction("; *this = *this-x ;\n"
|
||||||
"this-x ;");
|
"this-x ;");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (possible style) Suspicious pointer subtraction\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious pointer subtraction\n", errout.str());
|
||||||
|
|
||||||
checkThisSubtraction("; *this = *this-x ;\n"
|
checkThisSubtraction("; *this = *this-x ;\n"
|
||||||
"this-x ;\n"
|
"this-x ;\n"
|
||||||
"this-x ;\n");
|
"this-x ;\n");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (possible style) Suspicious pointer subtraction\n"
|
ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious pointer subtraction\n"
|
||||||
"[test.cpp:3]: (possible style) Suspicious pointer subtraction\n", errout.str());
|
"[test.cpp:3]: (style) Suspicious pointer subtraction\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkConst(const char code[])
|
void checkConst(const char code[])
|
||||||
|
|
Loading…
Reference in New Issue