[clang] [NFC] Fix the unreachable 'return' in OpenACC Stmt handling (PR #181153)

via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 12 06:36:33 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Erich Keane (erichkeane)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/181153.diff


1 Files Affected:

- (modified) clang/lib/AST/StmtOpenACC.cpp (+20-21) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/181153


More information about the cfe-commits mailing list