From: Eli Friedman Date: Tue, 2 Dec 2008 16:02:46 +0000 (+0000) Subject: Fix for PR3150: obvious copy-paste bug in X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8de8d1d3f2e21e4a72ac294276930ad293a3a765;p=clang Fix for PR3150: obvious copy-paste bug in ScalarExprEmitter::VisitBinLOr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60415 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 8c4303b467..7f417b374a 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -1077,9 +1077,9 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) { return Builder.CreateZExt(RHSCond, CGF.LLVMIntTy, "lor.ext"); } - // 1 || RHS: If it is safe, just elide the RHS, and return 0. + // 1 || RHS: If it is safe, just elide the RHS, and return 1. if (!CGF.ContainsLabel(E->getRHS())) - return llvm::Constant::getNullValue(CGF.LLVMIntTy); + return llvm::ConstantInt::get(CGF.LLVMIntTy, 1); } llvm::BasicBlock *ContBlock = CGF.createBasicBlock("lor.end"); diff --git a/test/CodeGen/2008-12-02-logical-or-fold.c b/test/CodeGen/2008-12-02-logical-or-fold.c new file mode 100644 index 0000000000..ba8f86c4fc --- /dev/null +++ b/test/CodeGen/2008-12-02-logical-or-fold.c @@ -0,0 +1,4 @@ +// RUN: clang -emit-llvm -o - %s | grep "store i32 1" +// PR3150 + +int a() {return 1||1;}