diff --git a/lib/check.h b/lib/check.h index 7d0c35776..6bb711a11 100644 --- a/lib/check.h +++ b/lib/check.h @@ -30,6 +30,13 @@ #include #include +/** + * 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 /// @{ diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index d325e8fa0..364bf919a 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -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()); } }