]> granicus.if.org Git - clang/commitdiff
Driver/Darwin: Eliminate invalid uses of DarwinVersion -- this fixes a number of
authorDaniel Dunbar <daniel@zuster.org>
Wed, 27 Jan 2010 00:57:11 +0000 (00:57 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 27 Jan 2010 00:57:11 +0000 (00:57 +0000)
defaults when targetting iPhoneOS (blocks, non-fragile ABI, stack protector).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94642 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp
lib/Driver/ToolChains.h
test/Driver/darwin-iphone-defaults.m [new file with mode: 0644]

index 9e64c862c732616120b6580bfd1e3c0a509ab78d..19f9012a42e955a1044f06cd5225d9df279c0f31 100644 (file)
@@ -34,13 +34,9 @@ Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple,
                const unsigned (&_DarwinVersion)[3])
   : ToolChain(Host, Triple), TargetInitialized(false)
 {
-  DarwinVersion[0] = _DarwinVersion[0];
-  DarwinVersion[1] = _DarwinVersion[1];
-  DarwinVersion[2] = _DarwinVersion[2];
-
   llvm::raw_string_ostream(MacosxVersionMin)
-    << "10." << std::max(0, (int)DarwinVersion[0] - 4) << '.'
-    << DarwinVersion[1];
+    << "10." << std::max(0, (int)_DarwinVersion[0] - 4) << '.'
+    << _DarwinVersion[1];
 }
 
 // FIXME: Can we tablegen this?
index e17546c982139bee1c1aa0fcccb3a45e1e144fc6..e683c2d484284edae36bc917edb2c63434d2eaea 100644 (file)
@@ -47,9 +47,6 @@ public:
 class VISIBILITY_HIDDEN Darwin : public ToolChain {
   mutable llvm::DenseMap<unsigned, Tool*> Tools;
 
-  /// Darwin version of tool chain.
-  unsigned DarwinVersion[3];
-
   /// Whether the information on the target has been initialized.
   //
   // FIXME: This should be eliminated. What we want to do is make this part of
@@ -106,12 +103,6 @@ public:
     Res[2] = TargetVersion[2];
   }
 
-  void getDarwinVersion(unsigned (&Res)[3]) const {
-    Res[0] = DarwinVersion[0];
-    Res[1] = DarwinVersion[1];
-    Res[2] = DarwinVersion[2];
-  }
-
   /// getDarwinArchName - Get the "Darwin" arch name for a particular compiler
   /// invocation. For example, Darwin treats different ARM variations as
   /// distinct architectures.
@@ -160,18 +151,20 @@ public:
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
 
   virtual bool IsBlocksDefault() const {
-    // Blocks default to on for 10.6 (darwin10) and beyond.
-    return (DarwinVersion[0] > 9);
+    // Blocks default to on for OS X 10.6 and iPhoneOS 3.0 and beyond.
+    if (isTargetIPhoneOS())
+      return !isIPhoneOSVersionLT(3);
+    else
+      return !isMacosxVersionLT(10, 6);
   }
   virtual bool IsObjCNonFragileABIDefault() const {
-    // Non-fragile ABI default to on for 10.5 (darwin9) and beyond on x86-64.
-    return (DarwinVersion[0] >= 9 &&
-            getTriple().getArch() == llvm::Triple::x86_64);
+    // Non-fragile ABI default to on for iPhoneOS and x86-64.
+    return isTargetIPhoneOS() || getTriple().getArch() == llvm::Triple::x86_64;
   }
   virtual bool IsUnwindTablesDefault() const;
   virtual unsigned GetDefaultStackProtectorLevel() const {
-    // Stack protectors default to on for 10.6 (darwin10) and beyond.
-    return (DarwinVersion[0] > 9) ? 1 : 0;
+    // Stack protectors default to on for 10.6 and beyond.
+    return !isTargetIPhoneOS() && !isMacosxVersionLT(10, 6);
   }
   virtual const char *GetDefaultRelocationModel() const;
   virtual const char *GetForcedPicModel() const;
diff --git a/test/Driver/darwin-iphone-defaults.m b/test/Driver/darwin-iphone-defaults.m
new file mode 100644 (file)
index 0000000..61bc441
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: %clang -ccc-host-triple i386-apple-darwin9 -arch armv7 -flto -S -o - %s | FileCheck %s
+
+// CHECK: @f0
+// CHECK-NOT: ssp
+// CHECK: ) {
+// CHECK: @__f0_block_invoke
+
+int f0() {
+  return ^(){ return 0; }();
+}
+
+@interface I0
+@property (assign) int p0;
+@end
+
+@implementation I0
+@synthesize p0 = __sythesized_p0;
+@end