[PATCH] D157174: [clang][Interp] Convert logical binop operands to bool

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 7 06:31:50 PDT 2023


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:531-534
+  // For C, cast back to integer type.
+  assert(T);
+  if (T != PT_Bool)
+    return this->emitCast(PT_Bool, *T, E);
----------------
tbaeder wrote:
> aaron.ballman wrote:
> > This is casting to boolean type, not integer type -- shouldn't that be emitting an int?
> That line is casting from `PT_Bool` to `T`, because we visited the operands as bool and now we need to convert back to whatever type we should have.
Ah!! That makes more sense, thank you.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157174/new/

https://reviews.llvm.org/D157174



More information about the cfe-commits mailing list