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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clangir

Author: Amr Hesham (AmrDeveloper)

<details>
<summary>Changes</summary>

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

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


1 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+3-5) 


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

``````````

</details>


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


More information about the cfe-commits mailing list