diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-03-20 00:50:21 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-20 00:50:21 +0000 |
commit | 03d87ee556f9e11ab83f6d2f80c9ee92e3667301 (patch) | |
tree | d0e64dc3a62b4a246b7bc710402e51824d4f1191 | |
parent | 788f5a1242c04762f91eaa7565c07b9865846d88 (diff) |
Driver: Fix possible crash when targetting an unknown (unsupported) Darwin
platform, e.g. ppc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99016 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Driver/ToolChains.h | 2 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 6dd64dec9e..0d5b2a3f47 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -96,6 +96,8 @@ public: return TargetIsIPhoneOS; } + bool isTargetInitialized() const { return TargetInitialized; } + void getTargetVersion(unsigned (&Res)[3]) const { assert(TargetInitialized && "Target not initialized!"); Res[0] = TargetVersion[0]; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 86b46856d3..58a4cdb89b 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -655,6 +655,12 @@ static std::string getEffectiveClangTriple(const Driver &D, } else { const toolchains::Darwin &DarwinTC( reinterpret_cast<const toolchains::Darwin&>(TC)); + + // If the target isn't initialized (e.g., an unknown Darwin platform, return + // the default triple). + if (!DarwinTC.isTargetInitialized()) + return Triple.getTriple(); + unsigned Version[3]; DarwinTC.getTargetVersion(Version); |