<rdar://problem/11358639>

Switch over to the "*-apple-macosx" for desktop and "*-apple-ios" for iOS triples.

Also make the selection process for auto selecting platforms based off of an arch much better.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@156354 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/TargetList.cpp b/source/Target/TargetList.cpp
index d987913..3ec4b08 100644
--- a/source/Target/TargetList.cpp
+++ b/source/Target/TargetList.cpp
@@ -68,11 +68,9 @@
     // This is purposely left empty unless it is specified by triple_cstr.
     // If not initialized via triple_cstr, then the currently selected platform
     // will set the architecture correctly.
-    ArchSpec arch;
-    
-    if (triple_cstr)
+    const ArchSpec arch(triple_cstr);
+    if (triple_cstr && triple_cstr[0])
     {
-        arch.SetTriple(triple_cstr, platform_sp.get());
         if (!arch.IsValid())
         {
             error.SetErrorStringWithFormat("invalid triple '%s'", triple_cstr);
@@ -80,6 +78,7 @@
         }
     }
 
+    ArchSpec platform_arch(arch);
     CommandInterpreter &interpreter = debugger.GetCommandInterpreter();
     if (platform_options)
     {
@@ -89,7 +88,8 @@
             platform_sp = platform_options->CreatePlatformWithOptions (interpreter,
                                                                        arch,
                                                                        select_platform, 
-                                                                       error);
+                                                                       error,
+                                                                       platform_arch);
             if (!platform_sp)
                 return error;
         }
@@ -101,15 +101,18 @@
         // current architecture if we have a valid architecture.
         platform_sp = debugger.GetPlatformList().GetSelectedPlatform ();
         
-        if (arch.IsValid() && !platform_sp->IsCompatibleWithArchitecture(arch))
+        if (arch.IsValid() && !platform_sp->IsCompatibleArchitecture(arch, &platform_arch))
         {
-            platform_sp = Platform::GetPlatformForArchitecture(arch);
+            platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
         }
     }
+    
+    if (!platform_arch.IsValid())
+        platform_arch = arch;
 
     error = TargetList::CreateTarget (debugger,
                                       file,
-                                      arch,
+                                      platform_arch,
                                       get_dependent_files,
                                       platform_sp,
                                       target_sp);
@@ -131,7 +134,7 @@
 (
     Debugger &debugger,
     const FileSpec& file,
-    const ArchSpec& arch,
+    const ArchSpec& specified_arch,
     bool get_dependent_files,
     PlatformSP &platform_sp,
     TargetSP &target_sp
@@ -141,28 +144,38 @@
                         "TargetList::CreateTarget (file = '%s/%s', arch = '%s')",
                         file.GetDirectory().AsCString(),
                         file.GetFilename().AsCString(),
-                        arch.GetArchitectureName());
+                        specified_arch.GetArchitectureName());
     Error error;
 
+    ArchSpec arch(specified_arch);
+
+    if (platform_sp)
+    {
+        if (arch.IsValid())
+        {
+            if (!platform_sp->IsCompatibleArchitecture(arch))
+                platform_sp = Platform::GetPlatformForArchitecture(specified_arch, &arch);
+        }
+    }
+    else if (arch.IsValid())
+    {
+        platform_sp = Platform::GetPlatformForArchitecture(specified_arch, &arch);
+    }
     
+    if (!platform_sp)
+        platform_sp = debugger.GetPlatformList().GetSelectedPlatform();
+
     if (file)
     {
         ModuleSP exe_module_sp;
         FileSpec resolved_file(file);
-        
         if (platform_sp)
         {
             FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
-            error = platform_sp->ResolveExecutable (file, arch, 
+            error = platform_sp->ResolveExecutable (file,
+                                                    arch,
                                                     exe_module_sp, 
                                                     executable_search_paths.GetSize() ? &executable_search_paths : NULL);
-            
-            if (exe_module_sp)
-            {
-                const ArchSpec &arch = exe_module_sp->GetArchitecture();
-                if (arch.IsValid() && !platform_sp->IsCompatibleWithArchitecture(arch))
-                    platform_sp = Platform::GetPlatformForArchitecture(arch);
-            }
         }
 
         if (error.Success() && exe_module_sp)