[PATCH] D149645: [clang][Interp] Optionally cast comparison result to non-bool
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 2 06:31:21 PDT 2023
tbaeder added a comment.
In D149645#4312162 <https://reviews.llvm.org/D149645#4312162>, @erichkeane wrote:
> For C, should we instead be teaching our boolean operations to understand it might be int? I fear this will end up causing conversion problems later, such as with:
>
> `int F = 1 > 2;`. We won't end up having a conversion operation there, since the RHS is already `int`, for the LHS.
The result of `1 > 2` is int, yes. That's what this patch does - it converts the `Boolean` we create to the `int` the AST (and thus all the intepreter code inspecting it) expects.
The AST has no `IntegralToBool` cast in the example, but that doesn't matter for this patch; it just fixes the types on the stack to correspond to what the later code expects. I'm not opposed to adding a target type to the comparison ops, but I'm not sure if the additional complexity is worth it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149645/new/
https://reviews.llvm.org/D149645
More information about the cfe-commits
mailing list