]> granicus.if.org Git - clang/commitdiff
Fix for PR3150: obvious copy-paste bug in
authorEli Friedman <eli.friedman@gmail.com>
Tue, 2 Dec 2008 16:02:46 +0000 (16:02 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 2 Dec 2008 16:02:46 +0000 (16:02 +0000)
ScalarExprEmitter::VisitBinLOr.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60415 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprScalar.cpp
test/CodeGen/2008-12-02-logical-or-fold.c [new file with mode: 0644]

index 8c4303b467c668e5f449037432f9af4db1eb0971..7f417b374aa1669720f31a618c317bb8dd2f25de 100644 (file)
@@ -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 (file)
index 0000000..ba8f86c
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: clang -emit-llvm -o - %s | grep "store i32 1"
+// PR3150
+
+int a() {return 1||1;}