[cfe-commits] r94642 - in /cfe/trunk: lib/Driver/ToolChains.cpp lib/Driver/ToolChains.h test/Driver/darwin-iphone-defaults.m

Daniel Dunbar daniel at zuster.org
Tue Jan 26 16:57:11 PST 2010


Author: ddunbar
Date: Tue Jan 26 18:57:11 2010
New Revision: 94642

URL: http://llvm.org/viewvc/llvm-project?rev=94642&view=rev
Log:
Driver/Darwin: Eliminate invalid uses of DarwinVersion -- this fixes a number of
defaults when targetting iPhoneOS (blocks, non-fragile ABI, stack protector).

Added:
    cfe/trunk/test/Driver/darwin-iphone-defaults.m
Modified:
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/lib/Driver/ToolChains.h

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=94642&r1=94641&r2=94642&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Jan 26 18:57:11 2010
@@ -34,13 +34,9 @@
                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?

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=94642&r1=94641&r2=94642&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Tue Jan 26 18:57:11 2010
@@ -47,9 +47,6 @@
 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 @@
     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 @@
   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;

Added: cfe/trunk/test/Driver/darwin-iphone-defaults.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-iphone-defaults.m?rev=94642&view=auto

==============================================================================
--- cfe/trunk/test/Driver/darwin-iphone-defaults.m (added)
+++ cfe/trunk/test/Driver/darwin-iphone-defaults.m Tue Jan 26 18:57:11 2010
@@ -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; }();
+}
+
+ at interface I0
+ at property (assign) int p0;
+ at end
+
+ at implementation I0
+ at synthesize p0 = __sythesized_p0;
+ at end





More information about the cfe-commits mailing list