[clang] [NFC] Fix the unreachable 'return' in OpenACC Stmt handling (PR #181153)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 12 06:35:53 PST 2026
https://github.com/erichkeane created https://github.com/llvm/llvm-project/pull/181153
A result of various cleanups, reimplementations/etc, I ended up with a return after an if/else branch where each returned in #168422.
This patch removes the 'else' after a return, and removes the unreachable return.
>From 132a2da89eb5b2298b4ef6e55449c92c10e0c67d Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Thu, 12 Feb 2026 06:34:18 -0800
Subject: [PATCH] [NFC] Fix the unreachable 'return' in OpenACC Stmt handling
A result of various cleanups, reimplementations/etc, I ended up with a
return after an if/else branch where each returned in #168422.
This patch removes the 'else' after a return, and removes the
unreachable return.
---
clang/lib/AST/StmtOpenACC.cpp | 41 +++++++++++++++++------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/clang/lib/AST/StmtOpenACC.cpp b/clang/lib/AST/StmtOpenACC.cpp
index ec8ceb949c6c0..2191c6a072264 100644
--- a/clang/lib/AST/StmtOpenACC.cpp
+++ b/clang/lib/AST/StmtOpenACC.cpp
@@ -513,32 +513,31 @@ getCaptureStmtInfo(const Stmt *AssocStmt) {
Read = getReadStmtInfo(Stmt2);
return OpenACCAtomicConstruct::StmtInfo::createUpdateRead(*Update, *Read);
- } else {
- // All of the forms that can be done in a single line fall into 2
- // categories: update/read, or read/update. The special cases are the
- // postfix unary operators, which we have to make sure we do the 'read'
- // first. However, we still parse these as the RHS first, so we have a
- // 'reversing' step. READ: UPDATE v = x++; v = x--; UPDATE: READ v = ++x; v
- // = --x; v = x binop=expr v = x = x binop expr v = x = expr binop x
+ }
- const Expr *E = cast<const Expr>(AssocStmt);
+ // All of the forms that can be done in a single line fall into 2
+ // categories: update/read, or read/update. The special cases are the
+ // postfix unary operators, which we have to make sure we do the 'read'
+ // first. However, we still parse these as the RHS first, so we have a
+ // 'reversing' step. READ: UPDATE v = x++; v = x--; UPDATE: READ v = ++x; v
+ // = --x; v = x binop=expr v = x = x binop expr v = x = expr binop x
- std::optional<OpenACCAtomicConstruct::SingleStmtInfo> Read =
- getReadStmtInfo(E, /*ForAtomicComputeSingleStmt=*/true);
- std::optional<OpenACCAtomicConstruct::SingleStmtInfo> Update =
- getUpdateStmtInfo(Read->X);
+ const Expr *E = cast<const Expr>(AssocStmt);
- // Fixup this, since the 'X' for the read is the result after write, but is
- // the same value as the LHS-most variable of the update(its X).
- Read->X = Update->X;
+ std::optional<OpenACCAtomicConstruct::SingleStmtInfo> Read =
+ getReadStmtInfo(E, /*ForAtomicComputeSingleStmt=*/true);
+ std::optional<OpenACCAtomicConstruct::SingleStmtInfo> Update =
+ getUpdateStmtInfo(Read->X);
- // Postfix is a read FIRST, then an update.
- if (Update->IsPostfixIncDec)
- return OpenACCAtomicConstruct::StmtInfo::createReadUpdate(*Read, *Update);
+ // Fixup this, since the 'X' for the read is the result after write, but is
+ // the same value as the LHS-most variable of the update(its X).
+ Read->X = Update->X;
- return OpenACCAtomicConstruct::StmtInfo::createUpdateRead(*Update, *Read);
- }
- return {};
+ // Postfix is a read FIRST, then an update.
+ if (Update->IsPostfixIncDec)
+ return OpenACCAtomicConstruct::StmtInfo::createReadUpdate(*Read, *Update);
+
+ return OpenACCAtomicConstruct::StmtInfo::createUpdateRead(*Update, *Read);
}
const OpenACCAtomicConstruct::StmtInfo
More information about the cfe-commits
mailing list