Fix crash in valueflow when using local classes (#2575)

This commit is contained in:
Paul Fultz II 2020-03-22 04:12:53 -05:00 committed by GitHub
parent a171f524cf
commit b68d6f9471
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -46,6 +46,10 @@ struct ForwardTraversal {
return Progress::Break; return Progress::Break;
if (out) if (out)
*out = lambdaEndToken; *out = lambdaEndToken;
// Skip class scope
} else if (Token::simpleMatch(tok, "{") && tok->scope() && tok->scope()->isClassOrStruct()) {
if (out)
*out = tok->link();
} else { } else {
if (f(tok) == Progress::Break) if (f(tok) == Progress::Break)
return Progress::Break; return Progress::Break;

View File

@ -4453,6 +4453,14 @@ private:
" dostuff(1);\n" " dostuff(1);\n"
"}\n"; "}\n";
valueOfTok(code, "x"); valueOfTok(code, "x");
code = "void a() {\n"
" static int x = 0;\n"
" struct c {\n"
" c(c &&) { ++x; }\n"
" };\n"
"}\n";
valueOfTok(code, "x");
} }
void valueFlowHang() { void valueFlowHang() {