summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Frontend/InitPreprocessor.cpp3
-rw-r--r--clang/test/Frontend/objc-bool-is-bool.m13
2 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 613248a7f1c..7e078fec924 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -591,6 +591,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
Builder.defineMacro("OBJC_ZEROCOST_EXCEPTIONS");
}
+ Builder.defineMacro("__OBJC_BOOL_IS_BOOL",
+ Twine(TI.useSignedCharForObjCBool() ? "0" : "1"));
+
if (LangOpts.getGC() != LangOptions::NonGC)
Builder.defineMacro("__OBJC_GC__");
diff --git a/clang/test/Frontend/objc-bool-is-bool.m b/clang/test/Frontend/objc-bool-is-bool.m
new file mode 100644
index 00000000000..464fe2ea8c0
--- /dev/null
+++ b/clang/test/Frontend/objc-bool-is-bool.m
@@ -0,0 +1,13 @@
+// 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=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=NONE %s
+
+// rdar://21170440
+
+// BOOL: #define __OBJC_BOOL_IS_BOOL 1
+// BOOL-NOT: #define __OBJC_BOOL_IS_BOOL 0
+
+// CHAR: #define __OBJC_BOOL_IS_BOOL 0
+// CHAR-NOT: #define __OBJC_BOOL_IS_BOOL 1
+
+// NONE-NOT: __OBJC_BOOL_IS_BOOL
OpenPOWER on IntegriCloud