From 26a11e20d09a6f3112d695e421044b8235e57172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 21 Feb 2020 09:35:01 +0100 Subject: [PATCH] Revert "Fix crash with garbage code (#2547)" This reverts commit b25709a492b5ff608241a2988b6298e9994399ec. The real problem was wrong AST for valid code, I want to fix that instead. --- lib/forwardanalyzer.cpp | 2 +- test/testgarbage.cpp | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/forwardanalyzer.cpp b/lib/forwardanalyzer.cpp index 3ba48ddfa..b7ec51f9c 100644 --- a/lib/forwardanalyzer.cpp +++ b/lib/forwardanalyzer.cpp @@ -68,7 +68,7 @@ struct ForwardTraversal { template)> Progress traverseConditional(T* tok, F f, bool traverseUnknown) { - if (Token::Match(tok, "?|&&|%oror%") && tok->astOperand1() && tok->astOperand2()) { + if (Token::Match(tok, "?|&&|%oror%")) { T* condTok = tok->astOperand1(); if (traverseRecursive(condTok, f, traverseUnknown) == Progress::Break) return Progress::Break; diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 7ddf19d09..178732ec2 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -245,7 +245,6 @@ private: TEST_CASE(garbageCode211); // #8764 TEST_CASE(garbageCode212); // #8765 TEST_CASE(garbageCode213); // #8758 - TEST_CASE(garbageCode214); TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1 @@ -1667,17 +1666,6 @@ private: ASSERT_THROW(checkCode("{\"\"[(1||)];}"), InternalError); } - void garbageCode214() { - checkCode("void\n" - "f(a, b, h)\n" - "struct g *a; {\n" - " long e;\n" - " if (e) {\n" - " (void) d((long) !b, c ? FALSE : TRUE);\n" - " }\n" - "}\n"); - } - void syntaxErrorFirstToken() { ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818 ASSERT_THROW(checkCode("*(*const<> (size_t); foo) { } *(*const (size_t)() ; foo) { }"), InternalError); // #6858