https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/186385

The one at the top of visitExpr doesn't make sense (we *just* started visiting 
the expression, how can there be leaked allocations?) and the one at the bottom 
is already handled via maybeDestroyLocals.

>From 34b2a3ea1e4a398a5b17e35e1189727754071440 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Fri, 13 Mar 2026 14:03:38 +0100
Subject: [PATCH] [clang][bytecode] Remove useless emitCheckAllocations calls

The one at the top of visitExpr doesn't make sense (we *just* started
visiting the expression, how can there be leaked allocations?) and the
one at the bottom is already handled via maybeDestroyLocals.
---
 clang/lib/AST/ByteCode/Compiler.cpp | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 27ae2eeb1b99c..13d6dcc92356d 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -5056,12 +5056,6 @@ template <class Emitter>
 bool Compiler<Emitter>::visitExpr(const Expr *E, bool DestroyToplevelScope) {
   LocalScope<Emitter> RootScope(this, ScopeKind::FullExpression);
 
-  // If we won't destroy the toplevel scope, check for memory leaks first.
-  if (!DestroyToplevelScope) {
-    if (!this->emitCheckAllocations(E))
-      return false;
-  }
-
   auto maybeDestroyLocals = [&]() -> bool {
     if (DestroyToplevelScope)
       return RootScope.destroyLocals() && this->emitCheckAllocations(E);
@@ -5102,7 +5096,7 @@ bool Compiler<Emitter>::visitExpr(const Expr *E, bool 
DestroyToplevelScope) {
     return this->emitRetValue(E) && maybeDestroyLocals();
   }
 
-  return maybeDestroyLocals() && this->emitCheckAllocations(E) && false;
+  return maybeDestroyLocals() && false;
 }
 
 template <class Emitter>

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to