For target processing, on non-Darwin systems instead of using the host triple,
we default to "i386-apple-darwin".  This is an interim solution.

Removed processing of "linux" triples from Targets.cpp, since we don't have
any sensical Linux target support (yet).

Cleaned up error processing of targets; added better diagnostics.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44560 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/Targets.cpp b/Driver/Targets.cpp
index dbc0f7a..07e0d62 100644
--- a/Driver/Targets.cpp
+++ b/Driver/Targets.cpp
@@ -18,8 +18,6 @@
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/CommandLine.h"
-#include <algorithm>
-#include <cctype>
 
 using namespace clang;
 
@@ -688,17 +686,8 @@
     else if (T.find("bogusW16W16-") == 0) // For testing portability.
       return new LinuxTargetInfo(T);
   }
-  else { 
-    // Make a copy of the triple that is all lowercase.
-    std::string T_lower(T);    
-    std::transform(T_lower.begin(), T_lower.end(),
-                   T_lower.begin(), (int(*)(int)) std::tolower);
 
-    if (T_lower.find("linux") != std::string::npos && IsX86(T))
-      return new LinuxTargetInfo(T);
-  }
-  
-  assert (false && "Unknown target!");
+  return NULL;
 }
 
 /// CreateTargetInfo - Return the set of target info objects as specified by
@@ -709,11 +698,25 @@
   assert (!triples.empty() && "No target triple.");
   
   // Create the primary target and target info.
-  TargetInfo *TI = new TargetInfo(CreateTarget(triples[0]), &Diags);
+  TargetInfoImpl* PrimaryTarget = CreateTarget(triples[0]);
+
+  if (!PrimaryTarget)
+    return NULL;
+  
+  TargetInfo *TI = new TargetInfo(PrimaryTarget, &Diags);
   
   // Add all secondary targets.
-  for (unsigned i = 1, e = triples.size(); i != e; ++i)
+  for (unsigned i = 1, e = triples.size(); i != e; ++i) {
+    TargetInfoImpl* SecondaryTarget = CreateTarget(triples[i]);
+
+    if (!SecondaryTarget) {
+      fprintf (stderr, "Warning: secondary target '%s' unrecognized.\n",
+               triples[i].c_str());
+      continue;
+    }
+
     TI->AddSecondaryTarget(CreateTarget(triples[i]));
+  }
   
   return TI;
 }