Index: lib/Basic/TargetInfo.cpp =================================================================== --- lib/Basic/TargetInfo.cpp +++ lib/Basic/TargetInfo.cpp @@ -75,7 +75,8 @@ Int64Type = SignedLongLong; SigAtomicType = SignedInt; ProcessIDType = SignedInt; - UseSignedCharForObjCBool = true; + // New Darwin platforms use the true bool type. + UseSignedCharForObjCBool = !Triple.isOSDarwin(); UseBitFieldTypeAlignment = true; UseZeroLengthBitfieldAlignment = false; UseExplicitBitFieldAlignment = true; Index: lib/Basic/Targets/AArch64.cpp =================================================================== --- lib/Basic/Targets/AArch64.cpp +++ lib/Basic/Targets/AArch64.cpp @@ -538,7 +538,6 @@ const TargetOptions &Opts) : DarwinTargetInfo(Triple, Opts) { Int64Type = SignedLongLong; - UseSignedCharForObjCBool = false; LongDoubleWidth = LongDoubleAlign = SuitableAlign = 64; LongDoubleFormat = &llvm::APFloat::IEEEdouble(); Index: lib/Basic/Targets/ARM.cpp =================================================================== --- lib/Basic/Targets/ARM.cpp +++ lib/Basic/Targets/ARM.cpp @@ -1051,11 +1051,11 @@ if (Triple.isWatchABI()) { // Darwin on iOS uses a variant of the ARM C++ ABI. TheCXXABI.set(TargetCXXABI::WatchOS); - - // BOOL should be a real boolean on the new ABI - UseSignedCharForObjCBool = false; - } else + } else { TheCXXABI.set(TargetCXXABI::iOS); + // BOOL should be a character on the iOS ABI. + UseSignedCharForObjCBool = true; + } } void DarwinARMTargetInfo::getOSDefines(const LangOptions &Opts, Index: lib/Basic/Targets/PPC.h =================================================================== --- lib/Basic/Targets/PPC.h +++ lib/Basic/Targets/PPC.h @@ -346,6 +346,7 @@ BoolWidth = BoolAlign = 32; // XXX support -mone-byte-bool? PtrDiffType = SignedInt; // for http://llvm.org/bugs/show_bug.cgi?id=15726 LongLongAlign = 32; + UseSignedCharForObjCBool = true; resetDataLayout("E-m:o-p:32:32-f64:32:64-n32"); } @@ -360,6 +361,7 @@ DarwinPPC64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : DarwinTargetInfo(Triple, Opts) { HasAlignMac68kSupport = true; + UseSignedCharForObjCBool = true; resetDataLayout("E-m:o-i64:64-n32:64"); } }; Index: lib/Basic/Targets/X86.h =================================================================== --- lib/Basic/Targets/X86.h +++ lib/Basic/Targets/X86.h @@ -412,8 +412,7 @@ MaxVectorAlign = 256; // The watchOS simulator uses the builtin bool type for Objective-C. llvm::Triple T = llvm::Triple(Triple); - if (T.isWatchOS()) - UseSignedCharForObjCBool = false; + UseSignedCharForObjCBool = !T.isWatchOS(); SizeType = UnsignedLong; IntPtrType = SignedLong; resetDataLayout("e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"); @@ -780,8 +779,7 @@ Int64Type = SignedLongLong; // The 64-bit iOS simulator uses the builtin bool type for Objective-C. llvm::Triple T = llvm::Triple(Triple); - if (T.isiOS()) - UseSignedCharForObjCBool = false; + UseSignedCharForObjCBool = !T.isiOS(); resetDataLayout("e-m:o-i64:64-f80:128-n8:16:32:64-S128"); } Index: test/Frontend/objc-bool-is-bool.m =================================================================== --- test/Frontend/objc-bool-is-bool.m +++ test/Frontend/objc-bool-is-bool.m @@ -1,5 +1,22 @@ // RUN: %clang_cc1 -fsyntax-only -E -dM -triple=armv7k-apple-watchos %s | FileCheck --check-prefix=BOOL %s +// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=armv7-apple-watchos %s | FileCheck --check-prefix=CHAR %s +// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=armv7-apple-ios %s | FileCheck --check-prefix=CHAR %s + +// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=arm64-apple-ios %s | FileCheck --check-prefix=BOOL %s + +// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=i686-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s +// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=i686-apple-ios %s | FileCheck --check-prefix=CHAR %s +// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=i686-apple-tvos %s | FileCheck --check-prefix=CHAR %s +// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=i686-apple-watchos %s | FileCheck --check-prefix=BOOL %s + // RUN: %clang_cc1 -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s +// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=x86_64-apple-ios %s | FileCheck --check-prefix=BOOL %s +// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=x86_64-apple-tvos %s | FileCheck --check-prefix=BOOL %s +// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=x86_64-apple-watchos %s | FileCheck --check-prefix=CHAR %s + +// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=ppc32-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s +// RUN: %clang_cc1 -fsyntax-only -E -dM -triple=ppc64-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s + // RUN: %clang_cc1 -x c -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s // RUN: %clang_cc1 -x objective-c++ -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s // RUN: %clang_cc1 -x c++ -fsyntax-only -E -dM -triple=x86_64-apple-darwin16 %s | FileCheck --check-prefix=CHAR %s