From 524db1c756957181244d14219dc9ca2533b1c6de Mon Sep 17 00:00:00 2001 From: Paul Fultz II Date: Mon, 23 Aug 2021 04:12:42 -0500 Subject: [PATCH] Fix 10420: assertion error when analysing juce (#3413) --- lib/valueflow.cpp | 2 +- test/testvalueflow.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 37afc347e..28cee8873 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -3271,7 +3271,7 @@ static void valueFlowForwardLifetime(Token * tok, TokenList *tokenlist, ErrorLog // Skip RHS const Token *nextExpression = nextAfterAstRightmostLeaf(parent); - if (Token::Match(parent->astOperand1(), ".|[|(")) { + if (Token::Match(parent->astOperand1(), ".|[|(") && parent->astOperand1()->exprId() > 0) { valueFlowForwardExpression( const_cast(nextExpression), endOfVarScope, parent->astOperand1(), values, tokenlist, settings); diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 41e3393c2..546d0e872 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -5659,6 +5659,16 @@ private: " };\n" "}\n"; valueOfTok(code, "0"); + + code = "namespace juce {\n" + "PopupMenu::Item& PopupMenu::Item::operator= (Item&&) = default;\n" + "PopupMenu::Options withDeletionCheck (Component& comp) const {\n" + " Options o (*this);\n" + " o.componentToWatchForDeletion = ∁\n" + " o.isWatchingForDeletion = true;\n" + " return o;\n" + "}}\n"; + valueOfTok(code, "return"); } void valueFlowCrash() {