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

We emit these diagnostics a lot, but we almost never see them. Try to 
short-circuit these functions if nobody will see the diagnostics anyway.

>From 4ce68afb4b6005b5239e1a319f163ab9a68a1d67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Thu, 17 Sep 2026 17:00:08 +0200
Subject: [PATCH] [clang][bytecode] Avoid some unnecessary diagnostic work

We emit these diagnostics a lot, but we almost never see them. Try to
short-circuit these functions if nobody will see the diagnostics anyway.
---
 clang/lib/AST/ByteCode/Interp.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index cf0f0d0d337df..b6975f250b3c1 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1095,6 +1095,8 @@ bool CheckInit(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr) {
 
 static bool diagnoseCallableDecl(InterpState &S, CodePtr OpPC,
                                  const FunctionDecl *DiagDecl) {
+  if (!S.diagnosing())
+    return false;
   // Bail out if the function declaration itself is invalid.  We will
   // have produced a relevant diagnostic while parsing it, so just
   // note the problematic sub-expression.
@@ -1212,6 +1214,9 @@ bool CheckThis(InterpState &S, CodePtr OpPC) {
   if (S.Current->hasThisPointer())
     return true;
 
+  if (!S.diagnosing())
+    return false;
+
   const Expr *E = S.Current->getExpr(OpPC);
   if (S.getLangOpts().CPlusPlus11) {
     bool IsImplicit = false;

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

Reply via email to