[PATCH] D149834: [clang][Interp] Fix ignoring TypeTraitExprs

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 4 02:57:08 PDT 2023


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.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149834

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
@@ -872,6 +872,8 @@
     (void)5, (void)6;
 
     1 ? 0 : 1;
+    sizeof(A);
+    alignof(A);
 
     return 0;
   }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1038,6 +1038,8 @@
 
 template <class Emitter>
 bool ByteCodeExprGen<Emitter>::VisitTypeTraitExpr(const TypeTraitExpr *E) {
+  if (DiscardResult)
+    return true;
   return this->emitConstBool(E->getValue(), E);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149834.519409.patch
Type: text/x-patch
Size: 731 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230504/7d570a02/attachment.bin>


More information about the cfe-commits mailing list