[PATCH] D137558: [clang][Interp] Reject reinterpret_casts

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 7 08:30:21 PST 2022


tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

An appropriate diagnostic has already been emitted when we get to the expression, so just return `false` here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137558

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h


Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -61,6 +61,7 @@
 
   // Expression visitors - result returned on interp stack.
   bool VisitCastExpr(const CastExpr *E);
+  bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E);
   bool VisitIntegerLiteral(const IntegerLiteral *E);
   bool VisitFloatingLiteral(const FloatingLiteral *E);
   bool VisitParenExpr(const ParenExpr *E);
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -192,6 +192,12 @@
   llvm_unreachable("Unhandled clang::CastKind enum");
 }
 
+
+template <class Emitter>
+bool ByteCodeExprGen<Emitter>::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E) {
+  return false;
+}
+
 template <class Emitter>
 bool ByteCodeExprGen<Emitter>::VisitIntegerLiteral(const IntegerLiteral *LE) {
   if (DiscardResult)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137558.473690.patch
Type: text/x-patch
Size: 1107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221107/907c9d1b/attachment.bin>


More information about the cfe-commits mailing list