Added CHECK_WRONG_DATA() that can be used to avoid crashes/hangs in release binaries

This commit is contained in:
Daniel Marjamäki 2017-03-26 11:23:39 +02:00
parent 4a1c04cb33
commit 6874f27e73
2 changed files with 8 additions and 1 deletions

View File

@ -30,6 +30,13 @@
#include <list>
#include <set>
/**
* Use this macro Cppcheck data can be wrong and you need a to check if that happens to avoid crash/hang
* Using this macro we can make sure that released binaries don't crash/hang but the problem is not hidden
* in debug builds.
*/
#define CHECK_WRONG_DATA(X) (X)
/// @addtogroup Core
/// @{

View File

@ -175,7 +175,7 @@ void CheckFunctions::checkIgnoredReturnValue()
while (parent->astParent() && parent->astParent()->str() == "::")
parent = parent->astParent();
if (!tok->next()->astParent() && (!tok->function() || !Token::Match(tok->function()->retDef, "void %name%")) && _settings->library.isUseRetVal(tok))
if (CHECK_WRONG_DATA(tok->next()->astOperand1()) && !tok->next()->astParent() && (!tok->function() || !Token::Match(tok->function()->retDef, "void %name%")) && _settings->library.isUseRetVal(tok))
ignoredReturnValueError(tok, tok->next()->astOperand1()->expressionString());
}
}