objective-c modern translator: buildit objc bool
type for rewriter project will be BoolTy.
// rdar://11231426. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154861 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index acf5e0b..887beac 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -481,7 +481,8 @@
   InitBuiltinType(ObjCBuiltinSelTy, BuiltinType::ObjCSel);
   
   // Builtin type for __objc_yes and __objc_no
-  ObjCBuiltinBoolTy = SignedCharTy;
+  ObjCBuiltinBoolTy = (Target.useSignedCharForObjCBool() ?
+                       SignedCharTy : BoolTy);
   
   ObjCConstantStringType = QualType();
 
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp
index f938b5a..8c49486 100644
--- a/lib/Basic/TargetInfo.cpp
+++ b/lib/Basic/TargetInfo.cpp
@@ -58,6 +58,7 @@
   Char32Type = UnsignedInt;
   Int64Type = SignedLongLong;
   SigAtomicType = SignedInt;
+  UseSignedCharForObjCBool = true;
   UseBitFieldTypeAlignment = true;
   UseZeroLengthBitfieldAlignment = false;
   ZeroLengthBitfieldBoundary = 0;
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index cab6b90..803e418 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -651,6 +651,10 @@
   // created. This complexity should be lifted elsewhere.
   getTarget().setForcedLangOptions(getLangOpts());
 
+  // rewriter project will change target built-in bool type from its default. 
+  if (getFrontendOpts().ProgramAction == frontend::RewriteObjC)
+    getTarget().noSignedCharForObjCBool();
+
   // Validate/process some options.
   if (getHeaderSearchOpts().Verbose)
     OS << "clang -cc1 version " CLANG_VERSION_STRING
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 0d0f2f5..3e368a3 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -11268,22 +11268,6 @@
 Sema::ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind) {
   assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
          "Unknown Objective-C Boolean value!");
-  QualType ObjCBoolLiteralQT = Context.ObjCBuiltinBoolTy;
-  // signed char is the default type for boolean literals. Use 'BOOL'
-  // instead, if BOOL typedef is visible in its scope instead.
-  Decl *TD = 
-    LookupSingleName(TUScope, &Context.Idents.get("BOOL"), 
-                     SourceLocation(), LookupOrdinaryName);
-  if (TypedefDecl *BoolTD = dyn_cast_or_null<TypedefDecl>(TD)) {
-    QualType QT = BoolTD->getUnderlyingType();
-    if (!QT->isIntegralOrUnscopedEnumerationType()) {
-      Diag(OpLoc, diag::warn_bool_for_boolean_literal) << QT;
-      Diag(BoolTD->getLocation(), diag::note_previous_declaration);
-    }
-    else
-      ObjCBoolLiteralQT = QT;
-  }
-  
   return Owned(new (Context) ObjCBoolLiteralExpr(Kind == tok::kw___objc_yes,
-                                        ObjCBoolLiteralQT, OpLoc));
+                                        Context.ObjCBuiltinBoolTy, OpLoc));
 }