[clang] [CIR][NFS] Fix missing return statement warning (PR #142591)

Amr Hesham via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 3 05:11:06 PDT 2025


https://github.com/AmrDeveloper created https://github.com/llvm/llvm-project/pull/142591

Fix the warning related to the missing return statement and multiple return statements

>From 5a47507bc7f091bd6032b455972095cc95ebbccc Mon Sep 17 00:00:00 2001
From: AmrDeveloper <amr96 at programmer.net>
Date: Tue, 3 Jun 2025 14:09:37 +0200
Subject: [PATCH] [CIR][NFS] Fix missing return statement warning

---
 clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
index 77287ec45972d..9404d6d66cf20 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -102,8 +102,9 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
                                      mlir::Type dstTy) const {
     if (mlir::isa<cir::IntType>(dstTy))
       return builder.createBoolToInt(value, dstTy);
-    if (mlir::isa<cir::BoolType>(dstTy))
-      return value;
+
+    assert(mlir::isa<cir::BoolType>(dstTy) && "Expect bool type");
+    return value;
   }
 
   //===--------------------------------------------------------------------===//
@@ -1857,9 +1858,6 @@ mlir::Value ScalarExprEmitter::VisitUnaryLNot(const UnaryOperator *e) {
 
   // ZExt result to the expr type.
   return maybePromoteBoolResult(boolVal, cgf.convertType(e->getType()));
-
-  cgf.cgm.errorNYI("destination type for logical-not unary operator is NYI");
-  return {};
 }
 
 /// Return the size or alignment of the type of argument of the sizeof



More information about the cfe-commits mailing list