From 6dc9db52449255227a7cd00ed0b1283059824076 Mon Sep 17 00:00:00 2001 From: Ewan Crawford Date: Thu, 10 Mar 2016 10:31:08 +0000 Subject: [PATCH] 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 Differential Revision: http://reviews.llvm.org/D17719 llvm-svn: 263099 --- .../Clang/ClangExpressionParser.cpp | 16 +++++++--------- .../Clang/ClangExpressionParser.h | 2 ++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index d91fb7a443be..c84b825126ca 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -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: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h index 3c055380b839..288be8df4707 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h @@ -129,6 +129,8 @@ private: class LLDBPreprocessorCallbacks; LLDBPreprocessorCallbacks *m_pp_callbacks; ///< Called when the preprocessor encounters module imports std::unique_ptr m_ast_context; + lldb::LanguageType m_language; ///< The the source language of the expression + /// which may be explicitly set or inferred. }; }