[PATCH] D154474: [clang][Interp] Fix ignoring Integral- and IntegralToBoolean casts

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 4 23:33:44 PDT 2023


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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154474

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/literals.cpp


Index: clang/test/AST/Interp/literals.cpp
===================================================================
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -917,6 +917,9 @@
     sizeof(int);
     alignof(int);
 
+    (short)5;
+    (bool)1;
+
     return 0;
   }
   static_assert(ignoredExprs() == 0, "");
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -161,6 +161,8 @@
 
   case CK_IntegralToBoolean:
   case CK_IntegralCast: {
+      if (DiscardResult)
+        return this->discard(SubExpr);
     std::optional<PrimType> FromT = classify(SubExpr->getType());
     std::optional<PrimType> ToT = classify(CE->getType());
     if (!FromT || !ToT)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154474.537229.patch
Type: text/x-patch
Size: 844 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230705/48f159e7/attachment.bin>


More information about the cfe-commits mailing list