Made lldb_private::ArchSpec contain much more than just an architecture. It
now, in addition to cpu type/subtype and architecture flavor, contains:
- byte order (big endian, little endian)
- address size in bytes
- llvm::Triple for true target triple support and for more powerful plug-in
  selection.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125602 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 29d3c3e..8f27c59 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -178,11 +178,9 @@
 // Implementation of ClangExpressionParser
 //===----------------------------------------------------------------------===//
 
-ClangExpressionParser::ClangExpressionParser(const char *target_triple,
-                                             Process *process,
-                                             ClangExpression &expr) :
-    m_expr(expr),
-    m_target_triple (),
+ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
+                                              ClangExpression &expr) :
+    m_expr (expr),
     m_compiler (),
     m_code_generator (NULL),
     m_execution_engine (),
@@ -195,12 +193,7 @@
             llvm::InitializeAllAsmPrinters();
         }
     } InitializeLLVM;
-    
-    if (target_triple && target_triple[0])
-        m_target_triple = target_triple;
-    else
-        m_target_triple = llvm::sys::getHostTriple();
-    
+        
     // 1. Create a new compiler instance.
     m_compiler.reset(new CompilerInstance());    
     m_compiler->setLLVMContext(new LLVMContext());
@@ -215,6 +208,10 @@
     m_compiler->getLangOpts().ObjC1 = true;
     m_compiler->getLangOpts().ObjC2 = true;
     
+    Process *process = NULL;
+    if (exe_scope)
+        process = exe_scope->CalculateProcess();
+
     if (process)
     {
         if (process->GetObjCLanguageRuntime())
@@ -239,7 +236,19 @@
     m_compiler->getDiagnosticOpts().Warnings.push_back("no-unused-value");
     
     // Set the target triple.
-    m_compiler->getTargetOpts().Triple = m_target_triple;
+    Target *target = NULL;
+    if (exe_scope)
+        target = exe_scope->CalculateTarget();
+
+    // TODO: figure out what to really do when we don't have a valid target.
+    // Sometimes this will be ok to just use the host target triple (when we
+    // evaluate say "2+3", but other expressions like breakpoint conditions
+    // and other things that _are_ target specific really shouldn't just be 
+    // using the host triple. This needs to be fixed in a better way.
+    if (target && target->GetArchitecture().IsValid())
+        m_compiler->getTargetOpts().Triple = target->GetArchitecture().GetTriple().str();
+    else
+        m_compiler->getTargetOpts().Triple = llvm::sys::getHostTriple();
     
     // 3. Set up various important bits of infrastructure.
     m_compiler->createDiagnostics(0, 0);