[clang] [clang][bytecode] Avoid some unnecessary diagnostic work (PR #224333)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 17 08:05:29 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/224333.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/Interp.cpp (+5)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/224333
More information about the cfe-commits
mailing list