[clang] d27278a - [clang][bytecode] Discard NullToPointer cast SubExpr (#104782)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 19 08:51:31 PDT 2024
Author: Timm Baeder
Date: 2024-08-19T17:51:27+02:00
New Revision: d27278a835ba9110b5bf775852b1a407d1c2bc62
URL: https://github.com/llvm/llvm-project/commit/d27278a835ba9110b5bf775852b1a407d1c2bc62
DIFF: https://github.com/llvm/llvm-project/commit/d27278a835ba9110b5bf775852b1a407d1c2bc62.diff
LOG: [clang][bytecode] Discard NullToPointer cast SubExpr (#104782)
So we still properly abort if they fail.
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/codegen.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 53144a50ccf4a..c839364d4c8d2 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 920a5ad7ba3e8..9fac28a52d315 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