[clang] [clang][bytecode][NFC] Use an early return in CheckLoad (PR #157105)

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 5 06:30:23 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

If the block is not accessible, one of the check has to fail.

---
Full diff: https://github.com/llvm/llvm-project/pull/157105.diff


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (+2-3) 


``````````diff
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))

``````````

</details>


https://github.com/llvm/llvm-project/pull/157105


More information about the cfe-commits mailing list