Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/check.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class Settings;
class ErrorLogger;
class Tokenizer;

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean that wrongData is never used and can be removed also?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is getting removed, see below.


/// @addtogroup Core
/// @{

Expand Down
2 changes: 1 addition & 1 deletion lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ void CheckClassImpl::initializationListUsage()
continue;
if (var->isPointer() || var->isReference() || var->isEnumType())
continue;
if (!WRONG_DATA(!var->valueType(), tok) && var->valueType()->type > ValueType::Type::ITERATOR)
if (!var->valueType() || var->valueType()->type > ValueType::Type::ITERATOR)
continue;

// bailout: multi line lambda in rhs => do not warn
Expand Down
4 changes: 2 additions & 2 deletions lib/checkfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,9 @@ void CheckFunctionsImpl::memsetZeroBytes()
const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
for (const Scope *scope : symbolDatabase->functionScopes) {
for (const Token* tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) {
if (Token::Match(tok, "memset|wmemset (") && (numberOfArguments(tok)==3)) {
if (Token::Match(tok, "memset|wmemset (")) {
const std::vector<const Token *> &arguments = getArguments(tok);
if (WRONG_DATA(arguments.size() != 3U, tok))
if (arguments.size() != 3U)
continue;
const Token* lastParamTok = arguments[2];
if (MathLib::isNullValue(lastParamTok->str()))
Expand Down
7 changes: 0 additions & 7 deletions lib/checkimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ void CheckImpl::reportError(ErrorPath errorPath, Severity severity, const char i
mErrorLogger.reportErr(errmsg);
}

bool CheckImpl::wrongData(const Token *tok, const char *str)
{
if (mSettings.daca)
reportError(tok, Severity::debug, "DacaWrongData", "Wrong data detected by condition " + std::string(str));
return true;
}

ErrorPath CheckImpl::getErrorPath(const Token* errtok, const ValueFlow::Value* value, std::string bug) const
{
ErrorPath errorPath;
Expand Down
6 changes: 0 additions & 6 deletions lib/checkimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ class CPPCHECKLIB CheckImpl

ErrorPath getErrorPath(const Token* errtok, const ValueFlow::Value* value, std::string bug) const;

/**
* Use WRONG_DATA in checkers when you check for wrong data. That
* will call this method
*/
bool wrongData(const Token *tok, const char *str);

public: // TODO: should be protected
void logChecker(const char id[]);
};
Expand Down
Loading