Merge pull request #2700 from pfultz2/afterConditionFunction
Extend scope of afterCondition until end of function
This commit is contained in:
commit
1567ccf97b
|
@ -37,6 +37,15 @@
|
||||||
# define NOEXCEPT
|
# define NOEXCEPT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// C++11 noreturn
|
||||||
|
#if (defined(__GNUC__) && (__GNUC__ >= 5)) \
|
||||||
|
|| (defined(__clang__) && (defined (__cplusplus)) && (__cplusplus >= 201103L)) \
|
||||||
|
|| defined(__CPPCHECK__)
|
||||||
|
# define NORETURN [[noreturn]]
|
||||||
|
#else
|
||||||
|
# define NORETURN
|
||||||
|
#endif
|
||||||
|
|
||||||
#define REQUIRES(msg, ...) class=typename std::enable_if<__VA_ARGS__::value>::type
|
#define REQUIRES(msg, ...) class=typename std::enable_if<__VA_ARGS__::value>::type
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
@ -3560,7 +3560,6 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
|
||||||
typeTok = typeTok->next();
|
typeTok = typeTok->next();
|
||||||
if (Token::Match(typeTok, ",|)")) { // #8333
|
if (Token::Match(typeTok, ",|)")) { // #8333
|
||||||
symbolDatabase->mTokenizer->syntaxError(typeTok);
|
symbolDatabase->mTokenizer->syntaxError(typeTok);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
// skip over qualification
|
// skip over qualification
|
||||||
while (Token::Match(typeTok, "%type% ::"))
|
while (Token::Match(typeTok, "%type% ::"))
|
||||||
|
|
|
@ -1352,7 +1352,7 @@ bool TemplateSimplifier::getTemplateNamePositionTemplateFunction(const Token *to
|
||||||
// skip decltype(...)
|
// skip decltype(...)
|
||||||
else if (Token::simpleMatch(tok->next(), "decltype (")) {
|
else if (Token::simpleMatch(tok->next(), "decltype (")) {
|
||||||
const Token * end = tok->linkAt(2)->previous();
|
const Token * end = tok->linkAt(2)->previous();
|
||||||
while (tok && tok->next() && tok != end) {
|
while (tok->next() && tok != end) {
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
namepos++;
|
namepos++;
|
||||||
}
|
}
|
||||||
|
@ -1361,7 +1361,7 @@ bool TemplateSimplifier::getTemplateNamePositionTemplateFunction(const Token *to
|
||||||
if (closing) {
|
if (closing) {
|
||||||
if (closing->strAt(1) == "(" && Tokenizer::isFunctionHead(closing->next(), ";|{|:", true))
|
if (closing->strAt(1) == "(" && Tokenizer::isFunctionHead(closing->next(), ";|{|:", true))
|
||||||
return true;
|
return true;
|
||||||
while (tok && tok->next() && tok->next() != closing) {
|
while (tok->next() && tok->next() != closing) {
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
namepos++;
|
namepos++;
|
||||||
}
|
}
|
||||||
|
@ -1384,7 +1384,7 @@ bool TemplateSimplifier::getTemplateNamePositionTemplateVariable(const Token *to
|
||||||
// skip decltype(...)
|
// skip decltype(...)
|
||||||
else if (Token::simpleMatch(tok->next(), "decltype (")) {
|
else if (Token::simpleMatch(tok->next(), "decltype (")) {
|
||||||
const Token * end = tok->linkAt(2);
|
const Token * end = tok->linkAt(2);
|
||||||
while (tok && tok->next() && tok != end) {
|
while (tok->next() && tok != end) {
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
namepos++;
|
namepos++;
|
||||||
}
|
}
|
||||||
|
@ -1393,7 +1393,7 @@ bool TemplateSimplifier::getTemplateNamePositionTemplateVariable(const Token *to
|
||||||
if (closing) {
|
if (closing) {
|
||||||
if (Token::Match(closing->next(), "=|;"))
|
if (Token::Match(closing->next(), "=|;"))
|
||||||
return true;
|
return true;
|
||||||
while (tok && tok->next() && tok->next() != closing) {
|
while (tok->next() && tok->next() != closing) {
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
namepos++;
|
namepos++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -607,16 +607,16 @@ private:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Syntax error */
|
/** Syntax error */
|
||||||
void syntaxError(const Token *tok, const std::string &code = "") const;
|
NORETURN void syntaxError(const Token *tok, const std::string &code = "") const;
|
||||||
|
|
||||||
/** Syntax error. Unmatched character. */
|
/** Syntax error. Unmatched character. */
|
||||||
void unmatchedToken(const Token *tok) const;
|
NORETURN void unmatchedToken(const Token *tok) const;
|
||||||
|
|
||||||
/** Syntax error. C++ code in C file. */
|
/** Syntax error. C++ code in C file. */
|
||||||
void syntaxErrorC(const Token *tok, const std::string &what) const;
|
NORETURN void syntaxErrorC(const Token *tok, const std::string &what) const;
|
||||||
|
|
||||||
/** Warn about unknown macro(s), configuration is recommended */
|
/** Warn about unknown macro(s), configuration is recommended */
|
||||||
void unknownMacroError(const Token *tok1) const;
|
NORETURN void unknownMacroError(const Token *tok1) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -4232,7 +4232,7 @@ struct ValueFlowConditionHandler {
|
||||||
// TODO: constValue could be true if there are no assignments in the conditional blocks and
|
// TODO: constValue could be true if there are no assignments in the conditional blocks and
|
||||||
// perhaps if there are no && and no || in the condition
|
// perhaps if there are no && and no || in the condition
|
||||||
bool constValue = false;
|
bool constValue = false;
|
||||||
forward(after, top->scope()->bodyEnd, cond.vartok, values, constValue);
|
forward(after, scope->bodyEnd, cond.vartok, values, constValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,7 +262,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
" tok->str();\n"
|
" tok->str();\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
TODO_ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (warning, inconclusive) Possible null pointer dereference: tok - otherwise it is redundant to check it against null.\n", "", errout.str());
|
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (warning) Either the condition 'tok' is redundant or there is possible null pointer dereference: tok.\n", errout.str());
|
||||||
|
|
||||||
check("int foo(const Token *tok)\n"
|
check("int foo(const Token *tok)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue