Fix for-loops opening branches without a full header
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Erki 2021-03-07 19:55:54 +02:00
parent a88a57e2ec
commit 6ed38077c6
2 changed files with 2 additions and 2 deletions

View File

@ -121,7 +121,7 @@ bool OperationFinderAstVisitor::dataTraverseStmtPost(clang::Stmt* stmt)
clang::Stmt* OperationFinderAstVisitor::_isBranchEntry(clang::Stmt* stmt) clang::Stmt* OperationFinderAstVisitor::_isBranchEntry(clang::Stmt* stmt)
{ {
if (auto* loop = clang::dyn_cast<clang::ForStmt>(stmt); if (auto* loop = clang::dyn_cast<clang::ForStmt>(stmt);
loop && loop->getInit()) loop && loop->getInit() && (loop->getInc() || loop->getCond()))
{ {
_loop_header.init = loop->getInit(); _loop_header.init = loop->getInit();

View File

@ -27,7 +27,7 @@ TEST_CASE("For loop with init only.", "[branches][for_loops]")
const OperationLog& log = operations.front(); const OperationLog& log = operations.front();
REQUIRE(log.branch_number == 1); REQUIRE(log.branch_number == 0);
} }