| 883 | } |
| 884 | |
| 885 | bool CheckUninitVarImpl::checkIfForWhileHead(const Token *startparentheses, const Variable& var, bool suppressErrors, bool isuninit, Alloc alloc, const std::string &membervar) |
| 886 | { |
| 887 | const Token * const endpar = startparentheses->link(); |
| 888 | if (Token::Match(startparentheses, "( ! %name% %oror%") && startparentheses->tokAt(2)->getValue(0)) |
| 889 | suppressErrors = true; |
| 890 | for (const Token *tok = startparentheses->next(); tok && tok != endpar; tok = tok->next()) { |
| 891 | if (tok->varId() == var.declarationId()) { |
| 892 | if (Token::Match(tok, "%name% . %name%")) { |
| 893 | if (membervar.empty()) |
| 894 | return true; |
| 895 | if (tok->strAt(2) == membervar) { |
| 896 | if (isMemberVariableAssignment(tok, membervar)) |
| 897 | return true; |
| 898 | |
| 899 | if (!suppressErrors && isMemberVariableUsage(tok, var.isPointer(), alloc, membervar)) |
| 900 | uninitStructMemberError(tok, tok->str() + "." + membervar); |
| 901 | } |
| 902 | continue; |
| 903 | } |
| 904 | |
| 905 | if (const Token *errorToken = isVariableUsage(tok, var.isPointer(), alloc)) { |
| 906 | if (suppressErrors) |
| 907 | continue; |
| 908 | uninitvarError(errorToken, errorToken->expressionString(), alloc); |
| 909 | } |
| 910 | return !Token::Match(tok->astParent(), "!|%comp%"); |
| 911 | } |
| 912 | // skip sizeof / offsetof |
| 913 | if (isUnevaluated(tok)) |
| 914 | tok = tok->linkAt(1); |
| 915 | if ((!isuninit || !membervar.empty()) && tok->str() == "&&") |
| 916 | suppressErrors = true; |
| 917 | } |
| 918 | return false; |
| 919 | } |
| 920 | |
| 921 | /** recursively check loop, return error token */ |
| 922 | const Token* CheckUninitVarImpl::checkLoopBodyRecursive(const Token *start, const Variable& var, const Alloc alloc, const std::string &membervar, bool &bailout, bool &alwaysReturns) const |
nothing calls this directly
no test coverage detected