diff --git a/op-finder-lib/src/OperationFinderAstVisitor.cpp b/op-finder-lib/src/OperationFinderAstVisitor.cpp index 2421c05..eb93195 100644 --- a/op-finder-lib/src/OperationFinderAstVisitor.cpp +++ b/op-finder-lib/src/OperationFinderAstVisitor.cpp @@ -121,7 +121,7 @@ bool OperationFinderAstVisitor::dataTraverseStmtPost(clang::Stmt* stmt) clang::Stmt* OperationFinderAstVisitor::_isBranchEntry(clang::Stmt* stmt) { if (auto* loop = clang::dyn_cast(stmt); - loop && loop->getInit()) + loop && loop->getInit() && (loop->getInc() || loop->getCond())) { _loop_header.init = loop->getInit(); diff --git a/op-finder-tests/branches.cpp b/op-finder-tests/branches.cpp index 08dddf4..ce92e28 100644 --- a/op-finder-tests/branches.cpp +++ b/op-finder-tests/branches.cpp @@ -27,7 +27,7 @@ TEST_CASE("For loop with init only.", "[branches][for_loops]") const OperationLog& log = operations.front(); - REQUIRE(log.branch_number == 1); + REQUIRE(log.branch_number == 0); }