Skip to content

Commit 0e32e19

Browse files
committed
daca: update WRONG_DATA interface
1 parent 2bb61b3 commit 0e32e19

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

lib/check.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,11 @@ void Check::reportError(const ErrorPath &errorPath, Severity::SeverityType sever
6464
reportError(errmsg);
6565
}
6666

67-
bool Check::wrongData(const Token *tok, bool condition, const char *str)
67+
bool Check::wrongData(const Token *tok, const char *str)
6868
{
69-
#if defined(DACA2) || defined(UNSTABLE)
70-
if (condition) {
69+
if (mSettings->daca)
7170
reportError(tok, Severity::debug, "DacaWrongData", "Wrong data detected by condition " + std::string(str));
72-
}
73-
#else
74-
(void)tok;
75-
(void)str;
76-
#endif
77-
return condition;
71+
return true;
7872
}
7973

8074
std::list<Check *> &Check::instances()
@@ -115,4 +109,4 @@ ErrorPath Check::getErrorPath(const Token* errtok, const ValueFlow::Value* value
115109
errorPath.emplace_back(errtok, bug);
116110
}
117111
return errorPath;
118-
}
112+
}

lib/check.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ErrorMessage;
4646
class Tokenizer;
4747

4848
/** Use WRONG_DATA in checkers to mark conditions that check that data is correct */
49-
#define WRONG_DATA(COND, TOK) (wrongData((TOK), (COND), #COND))
49+
#define WRONG_DATA(COND, TOK) ((COND) && wrongData((TOK), #COND))
5050

5151
/// @addtogroup Core
5252
/// @{
@@ -158,7 +158,7 @@ class CPPCHECKLIB Check {
158158
* Use WRONG_DATA in checkers when you check for wrong data. That
159159
* will call this method
160160
*/
161-
bool wrongData(const Token *tok, bool condition, const char *str);
161+
bool wrongData(const Token *tok, const char *str);
162162

163163
/** disabled assignment operator and copy constructor */
164164
void operator=(const Check &) = delete;

0 commit comments

Comments
 (0)