[clang] [clang][bytecode] Discard NullToPointer cast SubExpr (PR #104782)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 19 07:15:21 PDT 2024
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/104782
So we still properly abort if they fail.
>From 0485b480347f69565c9d494365bce65c4f9a7a50 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Mon, 19 Aug 2024 16:13:04 +0200
Subject: [PATCH] [clang][bytecode] Discard NullToPointer cast SubExpr
So we still properly abort if they fail.
---
clang/lib/AST/ByteCode/Compiler.cpp | 2 ++
clang/test/AST/ByteCode/codegen.cpp | 9 +++++++++
2 files changed, 11 insertions(+)
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 53144a50ccf4a9..c839364d4c8d25 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -327,6 +327,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
case CK_NullToPointer:
case CK_NullToMemberPointer: {
+ if (!this->discard(SubExpr))
+ return false;
if (DiscardResult)
return true;
diff --git a/clang/test/AST/ByteCode/codegen.cpp b/clang/test/AST/ByteCode/codegen.cpp
index 920a5ad7ba3e8f..9fac28a52d3150 100644
--- a/clang/test/AST/ByteCode/codegen.cpp
+++ b/clang/test/AST/ByteCode/codegen.cpp
@@ -64,3 +64,12 @@ namespace Bitfield {
// CHECK: store ptr @_ZGRN8Bitfield1rE_, ptr @_ZN8Bitfield1rE, align 8
int &&r = S().a;
}
+
+namespace Null {
+ decltype(nullptr) null();
+ // CHECK: call {{.*}} @_ZN4Null4nullEv(
+ int *p = null();
+ struct S {};
+ // CHECK: call {{.*}} @_ZN4Null4nullEv(
+ int S::*q = null();
+}
More information about the cfe-commits
mailing list