[PATCH] D29768: [TargetInfo] Set 'UseSignedCharForObjCBool' to false by default

2018-04-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Basic/Targets/PPC.h:349
 LongLongAlign = 32;
+UseSignedCharForObjCBool = true;
 resetDataLayout("E-m:o-p:32:32-f64:32:64-n32");

Do you need to specify this? Isn't it handled by the `TargetInfo` constructor?



Comment at: lib/Basic/Targets/PPC.h:364
 HasAlignMac68kSupport = true;
+UseSignedCharForObjCBool = true;
 resetDataLayout("E-m:o-i64:64-n32:64");

Likewise.


https://reviews.llvm.org/D29768



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29768: [TargetInfo] Set 'UseSignedCharForObjCBool' to false by default

2018-04-04 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 141070.
arphaman added a comment.

Only make the change for the Darwin platforms to avoid ObjC ABI breakage for 
non-Darwin platforms.


https://reviews.llvm.org/D29768

Files:
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/PPC.h
  lib/Basic/Targets/X86.h
  test/Frontend/objc-bool-is-bool.m

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
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: 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 , const TargetOptions )
   : DarwinTargetInfo(Triple, Opts) {
 HasAlignMac68kSupport = true;
+UseSignedCharForObjCBool = true;
 resetDataLayout("E-m:o-i64:64-n32:64");
   }
 };
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 ,
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -538,7 +538,6 @@
  const TargetOptions )
 : DarwinTargetInfo(Triple, Opts) {
   

[PATCH] D29768: [TargetInfo] Set 'UseSignedCharForObjCBool' to false by default

2018-04-04 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 141045.
arphaman marked 2 inline comments as done.
arphaman added a comment.
Herald added subscribers: jkorous-apple, kbarton, javed.absar, nemanjai.

Sorry, missed the comments last year. Updated.


Repository:
  rC Clang

https://reviews.llvm.org/D29768

Files:
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/PPC.h
  lib/Basic/Targets/X86.h
  test/Frontend/objc-bool-is-bool.m

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
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: 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 , const TargetOptions )
   : DarwinTargetInfo(Triple, Opts) {
 HasAlignMac68kSupport = true;
+UseSignedCharForObjCBool = true;
 resetDataLayout("E-m:o-i64:64-n32:64");
   }
 };
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 ,
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -538,7 +538,6 @@

[PATCH] D29768: [TargetInfo] Set 'UseSignedCharForObjCBool' to false by default

2017-04-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Basic/Targets.cpp:4340-4341
 llvm::Triple T = llvm::Triple(Triple);
-if (T.isWatchOS())
-  UseSignedCharForObjCBool = false;
+if (!T.isWatchOS())
+  UseSignedCharForObjCBool = true;
 SizeType = UnsignedLong;

Rather than using an if statement, why not assign directly? 
`UseSignedCharForObjCBool = !T.isWatchOS();`



Comment at: lib/Basic/Targets.cpp:4772-4773
 llvm::Triple T = llvm::Triple(Triple);
-if (T.isiOS())
-  UseSignedCharForObjCBool = false;
+if (!T.isiOS())
+  UseSignedCharForObjCBool = true;
 resetDataLayout("e-m:o-i64:64-f80:128-n8:16:32:64-S128");

Same here.


Repository:
  rL LLVM

https://reviews.llvm.org/D29768



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29768: [TargetInfo] Set 'UseSignedCharForObjCBool' to false by default

2017-04-28 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D29768



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29768: [TargetInfo] Set 'UseSignedCharForObjCBool' to false by default

2017-04-04 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D29768



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29768: [TargetInfo] Set 'UseSignedCharForObjCBool' to false by default

2017-02-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

The target-specific flag 'UseSignedCharForObjCBool' is used to determine the 
type for the Objective-C BOOL type. We should set it to `false` by default so 
that new targets can avoid setting it to `true`.


Repository:
  rL LLVM

https://reviews.llvm.org/D29768

Files:
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  test/Frontend/objc-bool-is-bool.m

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
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1719,6 +1719,7 @@
 PtrDiffType = SignedInt; // for http://llvm.org/bugs/show_bug.cgi?id=15726
 LongLongAlign = 32;
 SuitableAlign = 128;
+UseSignedCharForObjCBool = true;
 resetDataLayout("E-m:o-p:32:32-f64:32:64-n32");
   }
   BuiltinVaListKind getBuiltinVaListKind() const override {
@@ -1732,6 +1733,7 @@
   : DarwinTargetInfo(Triple, Opts) {
 HasAlignMac68kSupport = true;
 SuitableAlign = 128;
+UseSignedCharForObjCBool = true;
 resetDataLayout("E-m:o-i64:64-n32:64");
   }
 };
@@ -4335,8 +4337,8 @@
 MaxVectorAlign = 256;
 // The watchOS simulator uses the builtin bool type for Objective-C.
 llvm::Triple T = llvm::Triple(Triple);
-if (T.isWatchOS())
-  UseSignedCharForObjCBool = false;
+if (!T.isWatchOS())
+  UseSignedCharForObjCBool = true;
 SizeType = UnsignedLong;
 IntPtrType = SignedLong;
 resetDataLayout("e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128");
@@ -4767,8 +4769,8 @@
 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;
+if (!T.isiOS())
+  UseSignedCharForObjCBool = true;
 resetDataLayout("e-m:o-i64:64-f80:128-n8:16:32:64-S128");
   }
 
@@ -5894,11 +5896,12 @@
   // The 32-bit ABI is silent on what ptrdiff_t should be, but given that
   // size_t is long, it's a bit weird for it to be int.
   PtrDiffType = SignedLong;
-
-  // 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;
+}
   }
 };
 
@@ -6300,7 +6303,6 @@
   : DarwinTargetInfo(Triple, Opts) {
 Int64Type = SignedLongLong;
 WCharType = SignedInt;
-UseSignedCharForObjCBool = false;
 
 LongDoubleWidth = LongDoubleAlign = SuitableAlign = 64;
 LongDoubleFormat = ::APFloat::IEEEdouble();
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -72,7 +72,7 @@
   Int64Type = SignedLongLong;
   SigAtomicType = SignedInt;
   ProcessIDType = SignedInt;
-  UseSignedCharForObjCBool = true;
+  UseSignedCharForObjCBool =