Fix rdar://6518463, increment of a bool is always true, due to
subtle and non-obvious promotion rules.  We already handle += 
and +1 correctly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64296 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index a94eef1..285f0f4 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -619,6 +619,13 @@
     // FIXME: This isn't right for VLAs.
     NextVal = llvm::ConstantInt::get(llvm::Type::Int32Ty, AmountVal);
     NextVal = Builder.CreateGEP(InVal, NextVal, "ptrincdec");
+  } else if (InVal->getType() == llvm::Type::Int1Ty && isInc) {
+    // Bool++ is an interesting case, due to promotion rules, we get:
+    // Bool++ -> Bool = Bool+1 -> Bool = (int)Bool+1 ->
+    // Bool = ((int)Bool+1) != 0
+    // An interesting aspect of this is that increment is always true.
+    // Decrement does not have this property.
+    NextVal = llvm::ConstantInt::getTrue();
   } else {
     // Add the inc/dec to the real part.
     if (isa<llvm::IntegerType>(InVal->getType()))