This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Convert logical binop operands to bool
ClosedPublic

Authored by tbaeder on Aug 4 2023, 10:59 PM.

Details

Summary

Move the logic for this into visitBool, where it belongs. Then convert the logical binary operator operands to bool using visitBool() and the result back to int, if needed (which it is in C).

Diff Detail

Event Timeline

tbaeder created this revision.Aug 4 2023, 10:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 10:59 PM
tbaeder requested review of this revision.Aug 4 2023, 10:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 10:59 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tbaeder updated this revision to Diff 547495.Aug 5 2023, 9:27 AM
aaron.ballman added inline comments.Aug 7 2023, 6:18 AM
clang/lib/AST/Interp/ByteCodeExprGen.cpp
531–534

This is casting to boolean type, not integer type -- shouldn't that be emitting an int?

tbaeder added inline comments.Aug 7 2023, 6:26 AM
clang/lib/AST/Interp/ByteCodeExprGen.cpp
531–534

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.

aaron.ballman accepted this revision.Aug 7 2023, 6:31 AM

LGTM

clang/lib/AST/Interp/ByteCodeExprGen.cpp
531–534

Ah!! That makes more sense, thank you.

This revision is now accepted and ready to land.Aug 7 2023, 6:31 AM
This revision was landed with ongoing or failed builds.Sep 15 2023, 12:54 AM
This revision was automatically updated to reflect the committed changes.