[clang] [clang][bytecode][NFC] Use an early return in CheckLoad (PR #157105)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 5 06:29:45 PDT 2025
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/157105
If the block is not accessible, one of the check has to fail.
>From 8967d0f2ff9ef43999bc3e574c0d6b345bd4c692 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Fri, 5 Sep 2025 15:28:22 +0200
Subject: [PATCH] [clang][bytecode][NFC] Use an early return in CheckLoad
If the block is not accessible, one of the check has to fail.
---
clang/lib/AST/ByteCode/Interp.cpp | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index f1b9104c04feb..b64ed8c2fb497 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -792,6 +792,7 @@ bool CheckLocalLoad(InterpState &S, CodePtr OpPC, const Block *B) {
bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
AccessKinds AK) {
+ // Block pointers are the only ones we can actually read from.
if (!Ptr.isBlockPointer()) {
if (Ptr.isZero()) {
const auto &Src = S.Current->getSource(OpPC);
@@ -804,7 +805,6 @@ bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
return false;
}
- // Block pointers are the only ones we can actually read from.
if (!Ptr.block()->isAccessible()) {
if (!CheckLive(S, OpPC, Ptr, AK))
return false;
@@ -812,8 +812,7 @@ bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
return false;
if (!CheckDummy(S, OpPC, Ptr.block(), AK))
return false;
- if (!CheckWeak(S, OpPC, Ptr.block()))
- return false;
+ return CheckWeak(S, OpPC, Ptr.block());
}
if (!CheckConstant(S, OpPC, Ptr))
More information about the cfe-commits
mailing list