Skip to content

Commit

Permalink
fixed bug in shortcircuited AND and OR
Browse files Browse the repository at this point in the history
  • Loading branch information
lapotolo authored and lapotolo committed Mar 1, 2020
1 parent 1010fde commit 3631fab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ LLVMValueRef codegen_expr(

// in the case left is true we need to evaluate the right hand side
LLVMPositionBuilderAtEnd(builder, left_true_bb);
LLVMValueRef right_val = codegen_expr(e->binop.rhs, env, module, builder);
LLVMValueRef right_val = LLVMBuildAnd(builder, left_val, codegen_expr(e->binop.rhs, env, module, builder), "");
LLVMBuildBr(builder, cont_bb);
left_true_bb = LLVMGetInsertBlock(builder);

Expand Down Expand Up @@ -509,7 +509,7 @@ LLVMValueRef codegen_expr(
LLVMBuildCondBr(builder, left_val, left_true_bb, left_false_bb);

LLVMPositionBuilderAtEnd(builder, left_false_bb);
LLVMValueRef right_val = codegen_expr(e->binop.rhs, env, module, builder);
LLVMValueRef right_val = LLVMBuildOr(builder, left_val, codegen_expr(e->binop.rhs, env, module, builder), "");
LLVMBuildBr(builder, cont_bb);
left_false_bb = LLVMGetInsertBlock(builder);

Expand Down

0 comments on commit 3631fab

Please sign in to comment.