[clang] [clang][bytecode][NFC] Only do CheckConstant checks for global pointers (PR #113786)

via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 26 20:12:49 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

We can check isStatic() early here and save ourselves some work.

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


1 Files Affected:

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


``````````diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index fdc4b38b8aa6dc..9763cabab3cd7d 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -394,7 +394,7 @@ bool CheckConstant(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
 }
 
 static bool CheckConstant(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
-  if (!Ptr.isBlockPointer())
+  if (!Ptr.isStatic() || !Ptr.isBlockPointer())
     return true;
   return CheckConstant(S, OpPC, Ptr.getDeclDesc());
 }

``````````

</details>


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


More information about the cfe-commits mailing list