[clang] [clang][bytecode] Avoid classifying the same expression three times (PR #218403)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 24 06:04:48 PDT 2026


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

None

>From ae0c0fcfb6a4c0a8707531ad9c592ef75c865550 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Mon, 24 Aug 2026 14:44:50 +0200
Subject: [PATCH] VisitPointerArithBinOp classify

---
 clang/lib/AST/ByteCode/Compiler.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 87d23bf5df0c8..99e6d3d1d35ad 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -1534,13 +1534,14 @@ bool Compiler<Emitter>::VisitPointerArithBinOp(const BinaryOperator *E) {
     return false;
   }
 
-  if (classifyPrim(E) != PT_Ptr) {
-    if (!this->emitDecayPtr(PT_Ptr, classifyPrim(E), E))
+  PrimType ExprT = classifyPrim(E);
+  if (ExprT != PT_Ptr) {
+    if (!this->emitDecayPtr(PT_Ptr, ExprT, E))
       return false;
   }
 
   if (DiscardResult)
-    return this->emitPop(classifyPrim(E), E);
+    return this->emitPop(ExprT, E);
   return true;
 }
 



More information about the cfe-commits mailing list