Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -64,6 +64,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Core/StringList.h" #include "lldb/Core/StreamString.h" #include "lldb/Expression/IRExecutionUnit.h" #include "lldb/Expression/IRDynamicChecks.h" @@ -82,21 +83,6 @@ using namespace llvm; using namespace lldb_private; -namespace { - void debugStringVector(Log *log, const std::vector& vec, const char *name) - { - if(!log) - return; - - log->Debug("Begin %s:", name); - for (const auto& s : vec) - log->Debug("%s", s.c_str()); - - log->Debug("End %s.", name); - } -} - - //===----------------------------------------------------------------------===// // Utility Methods for Clang //===----------------------------------------------------------------------===// @@ -186,7 +172,7 @@ // 1. Create a new compiler instance. m_compiler.reset(new CompilerInstance()); - lldb::LanguageType frame_lang = lldb::eLanguageTypeUnknown; + lldb::LanguageType frame_lang = expr.Language(); // defaults to lldb::eLanguageTypeUnknown lldb_private::LanguageRuntime::OverrideExprOptions *target_opts_override = nullptr; lldb_private::LanguageRuntime *lang_rt = nullptr; lldb::TargetSP target_sp; @@ -196,7 +182,10 @@ // If the expression is being evaluated in the context of an existing // stack frame, we introspect to see if the language runtime is available. auto frame = exe_scope->CalculateStackFrame(); - if (frame) + + // Make sure the user hasn't provided a preferred execution language + // with `expression --language X -- ...` + if (frame && frame_lang == lldb::eLanguageTypeUnknown) frame_lang = frame->GetLanguage(); if (frame_lang != lldb::eLanguageTypeUnknown) @@ -262,7 +251,7 @@ } // Supported subsets of x86 if (target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86 || - target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86_64) + target_sp->GetArchitecture().GetMachine() == llvm::Triple::x86_64) { m_compiler->getTargetOpts().Features.push_back("+sse"); m_compiler->getTargetOpts().Features.push_back("+sse2"); @@ -277,9 +266,9 @@ log->Debug("FPMath: '%s'", opts.FPMath.c_str()); log->Debug("ABI: '%s'", opts.ABI.c_str()); log->Debug("LinkerVersion: '%s'", opts.LinkerVersion.c_str()); - debugStringVector(log, opts.FeaturesAsWritten, "FeaturesAsWritten"); - debugStringVector(log, opts.Features, "Features"); - debugStringVector(log, opts.Reciprocals, "Reciprocals"); + StringList::LogDump(log, opts.FeaturesAsWritten, "FeaturesAsWritten"); + StringList::LogDump(log, opts.Features, "Features"); + StringList::LogDump(log, opts.Reciprocals, "Reciprocals"); } // 3. Create and install the target on the compiler.