removed 'empty catch block' check. to avoid false positives we'll need to check if it is bad with an empty catch block (dead pointer/undefined behaviour/etc)

This commit is contained in:
Daniel Marjamäki 2010-09-05 13:27:58 +02:00
parent b32534b722
commit cfbc06c8b6
3 changed files with 0 additions and 98 deletions

View File

@ -4040,25 +4040,6 @@ void CheckOther::postIncrement()
}
}
void CheckOther::checkEmptyCatchBlock()
{
if (!_settings->_checkCodingStyle)
return;
const char pattern[] = "} catch (";
for (const Token *tok = Token::findmatch(_tokenizer->tokens(), pattern); tok;
tok = Token::findmatch(tok, pattern))
{
tok = tok->tokAt(2);
if (Token::simpleMatch(tok->link(), ") { }"))
{
emptyCatchBlockError(tok);
}
}
}
void CheckOther::cstyleCastError(const Token *tok)
{
reportError(tok, Severity::style, "cstyleCast", "C-style pointer casting");
@ -4221,11 +4202,6 @@ void CheckOther::fflushOnInputStreamError(const Token *tok, const std::string &v
"fflushOnInputStream", "fflush() called on input stream \"" + varname + "\" may result in undefined behaviour");
}
void CheckOther::emptyCatchBlockError(const Token *tok)
{
reportError(tok, Severity::style, "emptyCatchBlock", "Empty catch block");
}
void CheckOther::sizeofsizeof()
{
if (!_settings->_checkCodingStyle)

View File

@ -62,7 +62,6 @@ public:
checkOther.strPlusChar();
checkOther.sizeofsizeof();
checkOther.sizeofCalculation();
checkOther.checkEmptyCatchBlock();
checkOther.checkRedundantAssignmentInSwitch();
}
@ -175,9 +174,6 @@ public:
/** @brief %Check for using fflush() on an input stream*/
void checkFflushOnInputStream();
/** @brief %Check for empty catch() blocks*/
void checkEmptyCatchBlock();
/** @brief %Check for 'sizeof sizeof ..' */
void sizeofsizeof();
void sizeofsizeofError(const Token *tok);
@ -222,7 +218,6 @@ public:
void postIncrementError(const Token *tok, const std::string &var_name, const bool isIncrement);
void emptyStringTestError(const Token *tok, const std::string &var_name, const bool isTestForEmpty);
void fflushOnInputStreamError(const Token *tok, const std::string &varname);
void emptyCatchBlockError(const Token *tok);
void redundantAssignmentInSwitchError(const Token *tok, const std::string &varname);
void selfAssignmentError(const Token *tok, const std::string &varname);
@ -254,7 +249,6 @@ public:
strPlusChar(0);
sizeofsizeofError(0);
sizeofCalculationError(0);
emptyCatchBlockError(0);
redundantAssignmentInSwitchError(0, "varname");
selfAssignmentError(0, "varname");
invalidScanfError(0);
@ -293,7 +287,6 @@ public:
"* variable scope can be limited\n"
"* condition that is always true/false\n"
"* unusal pointer arithmetic. For example: \"abc\" + 'd'\n"
"* empty catch() block\n"
"* redundant assignment in a switch statement\n"
"* look for 'sizeof sizeof ..'\n"
"* look for calculations inside sizeof()\n"

View File

@ -101,8 +101,6 @@ private:
TEST_CASE(sizeofsizeof);
TEST_CASE(sizeofCalculation);
TEST_CASE(emptyCatchBlock);
TEST_CASE(switchRedundantAssignmentTest);
TEST_CASE(selfAssignment);
@ -127,7 +125,6 @@ private:
checkOther.sizeofsizeof();
checkOther.sizeofCalculation();
checkOther.checkEmptyCatchBlock();
checkOther.checkRedundantAssignmentInSwitch();
// Simplify token list..
@ -2853,70 +2850,6 @@ private:
ASSERT_EQUALS("", errout.str());
}
void emptyCatchBlock()
{
check("void Open(String name)\n"
"{\n"
" try\n"
" {\n"
" foo();\n"
" }\n"
" catch (FileNotFoundException e)\n"
" {\n"
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (style) Empty catch block\n", errout.str());
check("void Open(String name)\n"
"{\n"
" try\n"
" {\n"
" foo();\n"
" }\n"
" catch (char *errorMsg)\n"
" {\n"
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (style) Empty catch block\n", errout.str());
check("void Open(String name)\n"
"{\n"
" try\n"
" {\n"
" foo();\n"
" }\n"
" catch (const FileNotFoundException& e)\n"
" {\n"
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (style) Empty catch block\n", errout.str());
check("void Open(String name)\n"
"{\n"
" try\n"
" {\n"
" foo();\n"
" }\n"
" catch (...)\n"
" {\n"
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (style) Empty catch block\n", errout.str());
check("void Open(String name)\n"
"{\n"
" try\n"
" {\n"
" foo();\n"
" }\n"
" catch (const FileNotFoundException& e)\n"
" {\n"
" prinf(\"File not found\");\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void switchRedundantAssignmentTest()
{
check("void foo()\n"