daca: update WRONG_DATA interface

This commit is contained in:
Daniel Marjamäki 2020-10-03 15:35:00 +02:00
parent 2bb61b331a
commit 0e32e19184
2 changed files with 6 additions and 12 deletions

View File

@ -64,17 +64,11 @@ void Check::reportError(const ErrorPath &errorPath, Severity::SeverityType sever
reportError(errmsg);
}
bool Check::wrongData(const Token *tok, bool condition, const char *str)
bool Check::wrongData(const Token *tok, const char *str)
{
#if defined(DACA2) || defined(UNSTABLE)
if (condition) {
if (mSettings->daca)
reportError(tok, Severity::debug, "DacaWrongData", "Wrong data detected by condition " + std::string(str));
}
#else
(void)tok;
(void)str;
#endif
return condition;
return true;
}
std::list<Check *> &Check::instances()
@ -115,4 +109,4 @@ ErrorPath Check::getErrorPath(const Token* errtok, const ValueFlow::Value* value
errorPath.emplace_back(errtok, bug);
}
return errorPath;
}
}

View File

@ -46,7 +46,7 @@ class ErrorMessage;
class Tokenizer;
/** Use WRONG_DATA in checkers to mark conditions that check that data is correct */
#define WRONG_DATA(COND, TOK) (wrongData((TOK), (COND), #COND))
#define WRONG_DATA(COND, TOK) ((COND) && wrongData((TOK), #COND))
/// @addtogroup Core
/// @{
@ -158,7 +158,7 @@ protected:
* Use WRONG_DATA in checkers when you check for wrong data. That
* will call this method
*/
bool wrongData(const Token *tok, bool condition, const char *str);
bool wrongData(const Token *tok, const char *str);
/** disabled assignment operator and copy constructor */
void operator=(const Check &) = delete;