[clang] [clang][bytecode][NFC] Add an additional assertion (PR #105927)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 23 23:50:49 PDT 2024


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

Since this must be true, add an assertion instead of just documenting it via the comment.

>From 65ac59cb18b097251c7e6083f785562ba6278d82 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Sat, 24 Aug 2024 08:49:16 +0200
Subject: [PATCH] [clang][bytecode][NFC] Add an additional assertion

Since this must be true, add an assertion instead of just documenting it
via the comment.
---
 clang/lib/AST/ByteCode/Interp.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 7ba51f737db491..81c547991c3d7d 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2608,9 +2608,11 @@ inline bool Call(InterpState &S, CodePtr OpPC, const Function *Func,
     // the function we're about to call is a lambda call operator,
     // skip the CheckInvoke, since the ThisPtr is a null pointer
     // anyway.
-    if (!(S.Current->getFunction() &&
-          S.Current->getFunction()->isLambdaStaticInvoker() &&
-          Func->isLambdaCallOperator())) {
+    if (S.Current->getFunction() &&
+        S.Current->getFunction()->isLambdaStaticInvoker() &&
+        Func->isLambdaCallOperator()) {
+      assert(ThisPtr.isZero());
+    } else {
       if (!CheckInvoke(S, OpPC, ThisPtr))
         return false;
     }



More information about the cfe-commits mailing list