[PATCH] D132829: [clang][Interp] Handle ImplictValueInitExprs
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 29 00:46:36 PDT 2022
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, shafik, erichkeane, tahonermann.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
I don't have a test case handy for them since I'm not sure how to trigger them reliably, but they are easy enough to implement and I ran into them while working on array fillers.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D132829
Files:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/lib/AST/Interp/Opcodes.td
Index: clang/lib/AST/Interp/Opcodes.td
===================================================================
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -203,6 +203,7 @@
// [] -> [Integer]
def Zero : Opcode {
let Types = [AluTypeClass];
+ let HasGroup = 1;
}
// [] -> [Pointer]
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -67,6 +67,7 @@
bool VisitDeclRefExpr(const DeclRefExpr *E);
bool VisitArraySubscriptExpr(const ArraySubscriptExpr *E);
bool VisitInitListExpr(const InitListExpr *E);
+ bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E);
protected:
bool visitExpr(const Expr *E) override;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -259,6 +259,14 @@
return true;
}
+template <class Emitter>
+bool ByteCodeExprGen<Emitter>::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E) {
+ if (Optional<PrimType> T = classify(E))
+ return this->emitZero(*T, E);
+
+ return false;
+}
+
template <class Emitter>
bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
OptionScope<Emitter> Scope(this, /*NewDiscardResult=*/true);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132829.456275.patch
Type: text/x-patch
Size: 1436 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220829/ba20ccda/attachment.bin>
More information about the cfe-commits
mailing list