From 3042bbdc3deb32738b5100e557d9efe9bf9867b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 24 Apr 2020 18:51:54 +0200 Subject: [PATCH] Bug hunting: Handle early returns faster --- lib/exprengine.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index a001e0f30..c68e0ad7f 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -1531,7 +1531,12 @@ static void execute(const Token *start, const Token *end, Data &data) const Token *thenStart = tok->linkAt(1)->next(); const Token *thenEnd = thenStart->link(); - execute(thenStart->next(), end, ifData); + + if (Token::Match(thenStart, "{ return|throw|break|continue")) + execute(thenStart->next(), thenEnd, ifData); + else + execute(thenStart->next(), end, ifData); + if (Token::simpleMatch(thenEnd, "} else {")) { const Token *elseStart = thenEnd->tokAt(2); execute(elseStart->next(), end, elseData);