r287529 - [Frontend] Add a predefined macro that describes the Objective-C bool type
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 21 03:05:15 PST 2016
Author: arphaman
Date: Mon Nov 21 05:05:15 2016
New Revision: 287529
URL: http://llvm.org/viewvc/llvm-project?rev=287529&view=rev
Log:
[Frontend] Add a predefined macro that describes the Objective-C bool type
This commit adds a new predefined macro named __OBJC_BOOL_IS_BOOL that describes
the Objective-C boolean type: its value is zero if the Objective-C boolean uses
the signed character type, otherwise its value is one as the Objective-C boolean
uses the builtin boolean type.
rdar://21170440
Differential Revision: https://reviews.llvm.org/D26234
Added:
cfe/trunk/test/Frontend/objc-bool-is-bool.m
Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=287529&r1=287528&r2=287529&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Nov 21 05:05:15 2016
@@ -591,6 +591,9 @@ static void InitializePredefinedMacros(c
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__");
Added: cfe/trunk/test/Frontend/objc-bool-is-bool.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/objc-bool-is-bool.m?rev=287529&view=auto
==============================================================================
--- cfe/trunk/test/Frontend/objc-bool-is-bool.m (added)
+++ cfe/trunk/test/Frontend/objc-bool-is-bool.m Mon Nov 21 05:05:15 2016
@@ -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
More information about the cfe-commits
mailing list