Track expression language from one place in ClangExpressionParser

The current expression language is currently tracked in a few places within the ClangExpressionParser constructor. 
This patch adds a private lldb::LanguageType attribute to the ClangExpressionParser class and tracks the expression language from that one place.

Author: Luke Drummond <luke.drummond@codeplay.com>
Differential Revision: http://reviews.llvm.org/D17719

llvm-svn: 263099
This commit is contained in:
Ewan Crawford 2016-03-10 10:31:08 +00:00
parent e2961f71d2
commit 6dc9db5244
2 changed files with 9 additions and 9 deletions

View File

@ -157,7 +157,7 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
// 1. Create a new compiler instance.
m_compiler.reset(new CompilerInstance());
lldb::LanguageType frame_lang = expr.Language(); // defaults to lldb::eLanguageTypeUnknown
m_language = expr.Language(); // defaults to lldb::eLanguageTypeUnknown
bool overridden_target_opts = false;
lldb_private::LanguageRuntime *lang_rt = nullptr;
lldb::TargetSP target_sp;
@ -176,14 +176,14 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
// 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 && m_language == lldb::eLanguageTypeUnknown)
m_language = frame->GetLanguage();
if (frame_lang != lldb::eLanguageTypeUnknown)
if (m_language != lldb::eLanguageTypeUnknown)
{
lang_rt = exe_scope->CalculateProcess()->GetLanguageRuntime(frame_lang);
lang_rt = exe_scope->CalculateProcess()->GetLanguageRuntime(m_language);
if (log)
log->Printf("Frame has language of type %s", Language::GetNameForLanguageType(frame_lang));
log->Printf("Frame has language of type %s", Language::GetNameForLanguageType(m_language));
}
// 2. Configure the compiler with a set of default options that are appropriate
@ -263,9 +263,7 @@ ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope,
assert (m_compiler->hasTarget());
// 5. Set language options.
lldb::LanguageType language = expr.Language();
switch (language)
switch (m_language)
{
case lldb::eLanguageTypeC:
case lldb::eLanguageTypeC89:

View File

@ -129,6 +129,8 @@ private:
class LLDBPreprocessorCallbacks;
LLDBPreprocessorCallbacks *m_pp_callbacks; ///< Called when the preprocessor encounters module imports
std::unique_ptr<ClangASTContext> m_ast_context;
lldb::LanguageType m_language; ///< The the source language of the expression
/// which may be explicitly set or inferred.
};
}