[clang] [clang][bytecode] Return failure for dead non-temporary pointers (PR #125247)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 31 08:40:15 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

... even when we're not performing a lvalue-to-rvalue conversion.

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


1 Files Affected:

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


``````````diff
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 9763fe89b73742..8134bbf270363e 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -174,6 +174,9 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(const SourceInfo &Info) {
       return false;
     }
   } else {
+    if (!Ptr.isLive() && !Ptr.isTemporary())
+      return false;
+
     EvalResult.setValue(Ptr.toAPValue(Ctx.getASTContext()));
   }
 

``````````

</details>


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


More information about the cfe-commits mailing list