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
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 86b4685..58a4cdb 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -655,6 +655,12 @@
} 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);