[clang] [Clang][CodeGen] Fix clang codegen eh cleanup (PR #226743)

via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 26 18:57:23 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-codegen

Author: rdong8

<details>
<summary>Changes</summary>

Current code is incorrectly trying to `&` two enumerators from different enums together. This patch fixes it to call `needsEHCleanup`, matching the surrounding code.

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


2 Files Affected:

- (modified) clang/lib/CodeGen/CGExpr.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGExprAgg.cpp (+1-1) 


``````````diff
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 4a481c01f6a68..a555e8e851819 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -6175,7 +6175,7 @@ LValue CodeGenFunction::EmitCompoundLiteralLValue(const CompoundLiteralExpr *E){
     if (QualType::DestructionKind DtorKind = E->getType().isDestructedType())
       pushLifetimeExtendedDestroy(getCleanupKind(DtorKind), DeclPtr,
                                   E->getType(), getDestroyer(DtorKind),
-                                  DtorKind & EHCleanup);
+                                  needsEHCleanup(DtorKind));
 
   return Result;
 }
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index ff0ed1473d7df..f393e75ead1d6 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -794,7 +794,7 @@ void AggExprEmitter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
     if (QualType::DestructionKind DtorKind = E->getType().isDestructedType())
       CGF.pushLifetimeExtendedDestroy(
           CGF.getCleanupKind(DtorKind), Slot.getAddress(), E->getType(),
-          CGF.getDestroyer(DtorKind), DtorKind & EHCleanup);
+          CGF.getDestroyer(DtorKind), CGF.needsEHCleanup(DtorKind));
 }
 
 /// Attempt to look through various unimportant expressions to find a

``````````

</details>


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


More information about the cfe-commits mailing list