Driver/Darwin: Eliminate invalid uses of DarwinVersion -- this fixes a number of
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
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 9e64c86..19f9012 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -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?
diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
index e17546c..e683c2d 100644
--- a/lib/Driver/ToolChains.h
+++ b/lib/Driver/ToolChains.h
@@ -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;