diff --git a/lib/clangastdump.cpp b/lib/clangastdump.cpp index 2d8c5eb9a..7b9e9ebbf 100644 --- a/lib/clangastdump.cpp +++ b/lib/clangastdump.cpp @@ -427,7 +427,8 @@ Token *clangastdump::AstNode::createTokens(TokenList *tokenList) sep1->astOperand2(sep2); sep2->astOperand1(expr2); sep2->astOperand2(expr3); - createScope(tokenList, Scope::ScopeType::eFor, children[4]); + Scope *scope = createScope(tokenList, Scope::ScopeType::eFor, children[4]); + scope->classDef = forToken; return nullptr; } if (nodeType == FunctionDecl) { diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index bfe5df30d..7c5f904ad 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -4144,7 +4144,7 @@ static void valueFlowForwardAssign(Token * const tok, ErrorLogger * const errorLogger, const Settings * const settings) { - const Token * const endOfVarScope = var->typeStartToken()->scope()->bodyEnd; + const Token * const endOfVarScope = var->nameToken()->scope()->bodyEnd; if (std::any_of(values.begin(), values.end(), std::mem_fn(&ValueFlow::Value::isLifetimeValue))) { valueFlowForwardLifetime(tok, tokenlist, errorLogger, settings); values.remove_if(std::mem_fn(&ValueFlow::Value::isLifetimeValue));