[cfe-commits] r44911 - /cfe/trunk/Driver/clang.cpp

Chris Lattner sabre at nondot.org
Tue Dec 11 21:01:48 PST 2007


Author: lattner
Date: Tue Dec 11 23:01:48 2007
New Revision: 44911

URL: http://llvm.org/viewvc/llvm-project?rev=44911&view=rev
Log:
Simplify some code, don't force the triple to a darwin triple if non-darwin.

Modified:
    cfe/trunk/Driver/clang.cpp

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=44911&r1=44910&r2=44911&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Tue Dec 11 23:01:48 2007
@@ -426,38 +426,27 @@
 }
 
 static void CreateTargetTriples(std::vector<std::string>& triples) {
-  std::string base_triple;
-  
   // Initialize base triple.  If a -triple option has been specified, use
   // that triple.  Otherwise, default to the host triple.
-  if (TargetTriple.getValue().empty()) {
-    // HACK: For non-darwin systems, we don't have any real target support
-    //  yet.  For these systems, set the target to darwin.
-    if (!strstr(LLVM_HOSTTRIPLE,"darwin"))
-      base_triple = "i386-apple-darwin";
-    else
-      base_triple = LLVM_HOSTTRIPLE;
-  }
-  else
-    base_triple = TargetTriple.getValue();
+  std::string Triple = TargetTriple;
+  if (Triple.empty()) Triple = LLVM_HOSTTRIPLE;
   
   // Decompose the base triple into "arch" and suffix.
-  std::string::size_type firstDash = base_triple.find("-");
+  std::string::size_type firstDash = Triple.find("-");
   
   if (firstDash == std::string::npos) {
     fprintf(stderr, 
             "Malformed target triple: \"%s\" ('-' could not be found).\n",
-            base_triple.c_str());
-    exit (1);
+            Triple.c_str());
+    exit(1);
   }
   
-  std::string suffix(base_triple,firstDash+1);
+  std::string suffix(Triple, firstDash+1);
   
   if (suffix.empty()) {
-    fprintf(stderr,
-            "Malformed target triple: \"%s\" (no vendor or OS).\n",
-            base_triple.c_str());
-    exit (1);
+    fprintf(stderr, "Malformed target triple: \"%s\" (no vendor or OS).\n",
+            Triple.c_str());
+    exit(1);
   }
 
   // Create triple cacher.
@@ -466,7 +455,7 @@
   // Add the primary triple to our set of triples if we are using the
   // host-triple with no archs or using a specified target triple.
   if (!TargetTriple.getValue().empty() || Archs.empty())
-    tp.addTriple(base_triple);
+    tp.addTriple(Triple);
            
   for (unsigned i = 0, e = Archs.size(); i !=e; ++i)
     tp.addTriple(Archs[i] + "-" + suffix);





More information about the cfe-commits mailing list